Skip to content

Commit 5785a78

Browse files
authored
ssh: move remote_root when it changes (#261)
Fix #177.
1 parent 43215ae commit 5785a78

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

dpdispatcher/ssh_context.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def __init__ (self,
311311
assert os.path.isabs(remote_root), f"remote_root must be a abspath"
312312
self.temp_remote_root = remote_root
313313
self.remote_profile = remote_profile
314+
self.remote_root = None
314315

315316
# self.job_uuid = None
316317
self.clean_asynchronously = clean_asynchronously
@@ -378,8 +379,14 @@ def get_job_root(self) :
378379
def bind_submission(self, submission):
379380
self.submission = submission
380381
self.local_root = pathlib.PurePath(os.path.join(self.temp_local_root, submission.work_base)).as_posix()
382+
old_remote_root = self.remote_root
381383
# self.remote_root = os.path.join(self.temp_remote_root, self.submission.submission_hash, self.submission.work_base )
382384
self.remote_root = pathlib.PurePath(os.path.join(self.temp_remote_root, self.submission.submission_hash)).as_posix()
385+
# move the working directory if remote_root changes
386+
if old_remote_root is not None and old_remote_root != self.remote_root \
387+
and self.check_file_exists(old_remote_root) \
388+
and not self.check_file_exists(self.remote_root):
389+
self.block_checkcall(f"mv {old_remote_root} {self.remote_root}")
383390

384391
sftp = self.ssh_session.ssh.open_sftp()
385392
try:

0 commit comments

Comments
 (0)