Skip to content

Commit

Permalink
ssh: move remote_root when it changes
Browse files Browse the repository at this point in the history
Fix #177.
  • Loading branch information
njzjz committed Sep 18, 2022
1 parent 43215ae commit a8dcc6e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dpdispatcher/ssh_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ def __init__ (self,
assert os.path.isabs(remote_root), f"remote_root must be a abspath"
self.temp_remote_root = remote_root
self.remote_profile = remote_profile
self.remote_root = None

# self.job_uuid = None
self.clean_asynchronously = clean_asynchronously
Expand Down Expand Up @@ -378,8 +379,14 @@ def get_job_root(self) :
def bind_submission(self, submission):
self.submission = submission
self.local_root = pathlib.PurePath(os.path.join(self.temp_local_root, submission.work_base)).as_posix()
old_remote_root = self.remote_root
# self.remote_root = os.path.join(self.temp_remote_root, self.submission.submission_hash, self.submission.work_base )
self.remote_root = pathlib.PurePath(os.path.join(self.temp_remote_root, self.submission.submission_hash)).as_posix()
# move the working directory if remote_root changes
if old_remote_root is not None and old_remote_root != self.remote_root \
and self.check_file_exists(old_remote_root) \
and not self.check_file_exists(self.remote_root):
self.block_checkcall(f"mv {old_remote_root} {self.remote_root}")

sftp = self.ssh_session.ssh.open_sftp()
try:
Expand Down

0 comments on commit a8dcc6e

Please sign in to comment.