Skip to content

Commit c4f3713

Browse files
authored
BUG: Fix case where SlurmExecutor.finalize() is called but no work (#256)
1 parent beff0e8 commit c4f3713

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

adaptive_scheduler/_executor.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ def submit(self, fn: Callable[..., Any], /, *args: Any, **kwargs: Any) -> Future
3636
"""Submit a task to the executor."""
3737

3838
@abc.abstractmethod
39-
def finalize(self, *, start: bool = True) -> adaptive_scheduler.RunManager:
40-
"""Finalize the executor and return the RunManager."""
39+
def finalize(self, *, start: bool = True) -> adaptive_scheduler.RunManager | None:
40+
"""Finalize the executor and return the RunManager.
41+
42+
Returns None if no learners were submitted.
43+
"""
4144

4245
def map( # type: ignore[override]
4346
self,
@@ -408,11 +411,13 @@ def _to_learners(self) -> tuple[list[SequenceLearner], list[Path]]:
408411
fnames.append(self.folder / f"{name}-{i}-{uuid.uuid4().hex}.pickle")
409412
return learners, fnames
410413

411-
def finalize(self, *, start: bool = True) -> adaptive_scheduler.RunManager:
414+
def finalize(self, *, start: bool = True) -> adaptive_scheduler.RunManager | None:
412415
if self._run_manager is not None:
413416
msg = "RunManager already initialized. Create a new SlurmExecutor instance."
414417
raise RuntimeError(msg)
415418
learners, fnames = self._to_learners()
419+
if not learners:
420+
return None
416421
assert self.folder is not None
417422
self._run_manager = adaptive_scheduler.slurm_run(
418423
learners=learners,

readthedocs.yml

+3
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ build:
55
tools:
66
python: "mambaforge-4.10"
77

8+
sphinx:
9+
configuration: docs/source/conf.py
10+
811
conda:
912
environment: docs/environment.yml

0 commit comments

Comments
 (0)