Skip to content

Commit

Permalink
Keep original tmp slurm submission file as a hidden symlink (#1771)
Browse files Browse the repository at this point in the history
* keep origina tmp slurm submission file

* recreate temporary submission file as symlink

* use submission_file as hidden file

* bump to 1.5.2

---------

Co-authored-by: Jérémy Rapin <[email protected]>
  • Loading branch information
xman1979 and jrapin authored Sep 18, 2024
1 parent abc4eb4 commit 59db80d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion submitit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
from .slurm.slurm import SlurmExecutor as SlurmExecutor
from .slurm.slurm import SlurmJob as SlurmJob

__version__ = "1.5.1"
__version__ = "1.5.2"
4 changes: 2 additions & 2 deletions submitit/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def _submit_command(self, command: str) -> Job[tp.Any]:
"""
tmp_uuid = uuid.uuid4().hex
submission_file_path = (
utils.JobPaths.get_first_id_independent_folder(self.folder) / f"submission_file_{tmp_uuid}.sh"
utils.JobPaths.get_first_id_independent_folder(self.folder) / f".submission_file_{tmp_uuid}.sh"
)
with submission_file_path.open("w") as f:
f.write(self._make_submission_file_text(command, tmp_uuid))
Expand All @@ -935,7 +935,7 @@ def _submit_command(self, command: str) -> Job[tp.Any]:
job_id = self._get_job_id_from_submission_command(output)
tasks_ids = list(range(self._num_tasks()))
job: Job[tp.Any] = self.job_class(folder=self.folder, job_id=job_id, tasks=tasks_ids)
job.paths.move_temporary_file(submission_file_path, "submission_file")
job.paths.move_temporary_file(submission_file_path, "submission_file", keep_as_symlink=True)
self._write_job_id(job.job_id, tmp_uuid)
self._set_job_permissions(job.paths.folder)
return job
Expand Down
4 changes: 3 additions & 1 deletion submitit/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ def _format_id(self, path: tp.Union[Path, str]) -> Path:
replaced_path = replaced_path.replace("%a", array_index[0])
return Path(replaced_path.replace("%A", array_id))

def move_temporary_file(self, tmp_path: tp.Union[Path, str], name: str) -> None:
def move_temporary_file(self, tmp_path: tp.Union[Path, str], name: str, keep_as_symlink: bool = False) -> None:
self.folder.mkdir(parents=True, exist_ok=True)
Path(tmp_path).rename(getattr(self, name))
if keep_as_symlink:
Path(tmp_path).symlink_to(getattr(self, name))

@staticmethod
def get_first_id_independent_folder(folder: tp.Union[Path, str]) -> Path:
Expand Down

0 comments on commit 59db80d

Please sign in to comment.