Skip to content

Commit 75db4ae

Browse files
committed
Make user_local_exports a non-optional dict
1 parent c7d8d7e commit 75db4ae

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

fractal_server/runner/config/_slurm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@ class JobRunnerConfigSLURM(BaseModel):
126126
default_slurm_config: _SlurmConfigSet
127127
gpu_slurm_config: _SlurmConfigSet | None = None
128128
batching_config: _BatchingConfigSet
129-
user_local_exports: DictStrStr | None = None
129+
user_local_exports: DictStrStr = Field(default_factory=dict)

fractal_server/runner/executors/slurm_common/get_slurm_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _get_slurm_config_internal(
7777
else:
7878
needs_gpu = False
7979
logger.debug(f"[get_slurm_config] {needs_gpu=}")
80-
if needs_gpu:
80+
if needs_gpu and shared_config.gpu_slurm_config is not None:
8181
for key, value in shared_config.gpu_slurm_config.model_dump(
8282
exclude_unset=True, exclude={"mem"}
8383
).items():

fractal_server/runner/executors/slurm_common/slurm_config.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class SlurmConfig(BaseModel):
8686
extra_lines: list[str] = Field(default_factory=list)
8787

8888
# Variables that will be `export`ed in the SLURM submission script
89-
user_local_exports: dict[str, str] | None = None
89+
user_local_exports: dict[str, str] = Field(default=dict)
9090

9191
# Metaparameters needed to combine multiple tasks in each SLURM job
9292
tasks_per_job: int | None = None
@@ -189,14 +189,13 @@ def to_sbatch_preamble(
189189
for line in self._sorted_extra_lines():
190190
lines.append(line)
191191

192-
if self.user_local_exports:
193-
if remote_export_dir is None:
194-
raise ValueError(
195-
f"remote_export_dir=None but {self.user_local_exports=}"
196-
)
197-
for key, value in self.user_local_exports.items():
198-
tmp_value = str(Path(remote_export_dir) / value)
199-
lines.append(f"export {key}={tmp_value}")
192+
if self.user_local_exports != {} and remote_export_dir is None:
193+
raise ValueError(
194+
f"{remote_export_dir=} but {self.user_local_exports=}"
195+
)
196+
for key, value in self.user_local_exports.items():
197+
tmp_value = str(Path(remote_export_dir) / value)
198+
lines.append(f"export {key}={tmp_value}")
200199

201200
"""
202201
FIXME export SRUN_CPUS_PER_TASK

tests/v2/test_08_backends/test_slurm_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def test_get_slurm_config_internal_gpu_options():
138138
"max_num_jobs": 10,
139139
},
140140
)
141+
assert shared_slurm_config.user_local_exports == {}
141142
assert shared_slurm_config.default_slurm_config.extra_lines == []
142143

143144
# In absence of `needs_gpu`, parameters in `gpu_slurm_config` are not used

0 commit comments

Comments
 (0)