Skip to content

Commit a610e89

Browse files
authored
fix: remove unexpected side effect in get_srun_flags (#408)
Currently, if `nemo_run_dir` is falsy, this function will append mounts to the object mounts list, resulting in unexpected extension of the list with every call. This function is called by materialize, which it turns out is even called by the `__repr__` and as such one would expect it not to have any side effects. Signed-off-by: Jakub Bliźniuk <opliko@opliko.dev>
1 parent d799b0e commit a610e89

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

nemo_run/run/ray/slurm.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,13 @@ def get_srun_flags(mounts: list[str], container_image: Optional[str]) -> str:
203203
if gres_specification:
204204
_srun_flags.append(gres_specification)
205205

206+
new_mounts = copy.deepcopy(mounts)
206207
if self.nemo_run_dir:
207-
new_mounts = copy.deepcopy(mounts)
208208
for i, mount in enumerate(new_mounts):
209209
if mount.startswith(RUNDIR_SPECIAL_NAME):
210210
new_mounts[i] = mount.replace(RUNDIR_SPECIAL_NAME, self.nemo_run_dir, 1)
211211

212212
new_mounts.append(f"{self.nemo_run_dir}:/{RUNDIR_NAME}")
213-
else:
214-
new_mounts = mounts
215213

216214
new_mounts.append(f"{self.cluster_dir}:{self.cluster_dir}")
217215
new_mounts.append(f"{logs_dir}:{logs_dir}")

0 commit comments

Comments
 (0)