Skip to content

Commit adeec06

Browse files
authored
Fix slurm execution (#864)
* do not assert that SLURM_ARRAY_JOB_ID is always set, because it is not * fix order * update changelog
1 parent 75d07dd commit adeec06

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

cluster_tools/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ For upgrade instructions, please check the respective *Breaking Changes* section
1616
### Changed
1717

1818
### Fixed
19+
- Fixed the execution of non-array jobs using slurm. [#864](https://github.com/scalableminds/webknossos-libs/pull/864)
1920

2021

2122
## [0.11.3](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.11.3) - 2023-02-06

cluster_tools/cluster_tools/schedulers/slurm.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@ def get_job_array_index() -> Optional[int]:
107107
return None
108108

109109
@staticmethod
110-
def get_job_array_id() -> str:
111-
r = os.environ.get("SLURM_ARRAY_JOB_ID")
112-
assert r is not None
113-
return r
110+
def get_job_array_id() -> Optional[str]:
111+
try:
112+
return os.environ.get("SLURM_ARRAY_JOB_ID")
113+
except KeyError:
114+
return None
114115

115116
@staticmethod
116117
def get_current_job_id() -> str:
@@ -131,7 +132,9 @@ def get_job_id_string(cls) -> str:
131132
# This variable needs to be kept in sync with the job_id_string variable in the
132133
# inner_submit function.
133134
job_id_string = (
134-
job_id if job_array_index is None else f"{job_array_id}_{job_array_index}"
135+
job_id
136+
if job_array_id is None or job_array_index is None
137+
else f"{job_array_id}_{job_array_index}"
135138
)
136139
return job_id_string
137140

0 commit comments

Comments
 (0)