Skip to content

Commit fa33e23

Browse files
authored
Merge pull request #18 from yimuchen/fix_shipenv
Added virtual_env detection for ship_env flag
2 parents 93d6e4b + 7742f94 commit fa33e23

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/lpcjobqueue/cluster.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class LPCCondorJob(HTCondorJob):
4343
container_prefix = "/cvmfs/unpacked.cern.ch/registry.hub.docker.com/"
4444
config_name = "lpccondor"
4545
known_jobs = set()
46+
env_name = os.path.basename(os.getenv('VIRTUAL_ENV', '.env'))
4647

4748
def __init__(
4849
self,
@@ -55,7 +56,7 @@ def __init__(
5556
):
5657
image = self.container_prefix + image
5758
if ship_env:
58-
base_class_kwargs["python"] = ".env/bin/python"
59+
base_class_kwargs["python"] = f"{self.env_name}/bin/python"
5960
base_class_kwargs.setdefault(
6061
"worker_extra_args", list(dask.config.get("jobqueue.%s.worker_extra_args" % self.config_name))
6162
)
@@ -252,8 +253,9 @@ def _build_scratch(self):
252253
self.scratch_area = tempfile.TemporaryDirectory(dir=tmproot)
253254
infiles = []
254255
if self._ship_env:
255-
shutil.copytree("/srv/.env", os.path.join(self.scratch_area.name, ".env"))
256-
infiles.append(".env")
256+
env_path = os.getenv('VIRTUAL_ENV', '/srv/.env')
257+
shutil.copytree(env_path, os.path.join(self.scratch_area.name, os.path.basename(env_path)))
258+
infiles.append(os.path.basename(env_path))
257259
for fn in self._transfer_input_files:
258260
fn = os.path.abspath(fn)
259261
if any(os.path.commonprefix([fn, p]) == p for p in self.schedd_safe_paths):

0 commit comments

Comments
 (0)