Skip to content

Commit 29cea36

Browse files
authored
Fix: install mantaray and maxlibrary in the virtual environment (GoogleCloudPlatform#1074)
Install mantaray and maxlibrary in a virtual environment. mantaray installs older versions of some common dependencies, which would downgrade the libraries used by other DAGs and cause them to fail.
1 parent 949b114 commit 29cea36

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

xlml/utils/mantaray.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import tempfile
1818
from airflow.decorators import task
1919
from airflow.hooks.subprocess import SubprocessHook
20-
from dags import composer_env
2120

2221

2322
MANTARAY_G3_GS_BUCKET = "gs://borgcron/cmcs-benchmark-automation/mantaray"
@@ -32,7 +31,7 @@ def load_file_from_gcs(gs_file_path):
3231
check=False,
3332
shell=True,
3433
)
35-
with open(f"{tmpdir}/file", "r") as f:
34+
with open(f"{tmpdir}/file", "r") as f: # pylint: disable=unspecified-encoding
3635
return f.read()
3736

3837

@@ -45,12 +44,16 @@ def run_workload(
4544
with tempfile.TemporaryDirectory() as tmpdir:
4645
cmds = (
4746
f"cd {tmpdir}",
47+
# Create a virtual environment to install dependencies
48+
# without affecting other DAGs.
49+
"python -m venv --system-site-packages .venv",
50+
"source .venv/bin/activate",
4851
f"gsutil -m cp -r {mantaray_gcs_bucket} .",
4952
"sudo apt-get update && sudo apt-get install -y rsync", # Install rsync
50-
f"cd mantaray && pip install -e .",
53+
"cd mantaray && pip install -e .",
5154
# Install maxlibrary
5255
f"gsutil -m cp -r {maxlibrary_gcs_bucket} ./xlml_jobs",
53-
f"pip install -e ./xlml_jobs/maxlibrary",
56+
"pip install -e ./xlml_jobs/maxlibrary",
5457
f"python xlml_jobs/{workload_file_name}", # Run the workload
5558
)
5659
hook = SubprocessHook()
@@ -69,7 +72,10 @@ def build_docker_image():
6972
f"cd {tmpdir}",
7073
f"gsutil -m cp -r {MANTARAY_G3_GS_BUCKET} .",
7174
"cd mantaray",
72-
"gcloud builds submit --config docker/cloudbuild.yaml --substitutions _DATE=$(date +%Y%m%d)", # Create nightly docker image
75+
(
76+
"gcloud builds submit --config docker/cloudbuild.yaml"
77+
" --substitutions _DATE=$(date +%Y%m%d)"
78+
), # Create nightly docker image
7379
)
7480
hook = SubprocessHook()
7581
result = hook.run_command(

0 commit comments

Comments
 (0)