Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep original tmp slurm submission file as a hidden symlink #1771

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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