Skip to content

Commit

Permalink
BUG: Fix case where SlurmExecutor.finalize() is called but no work (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt authored Jan 24, 2025
1 parent beff0e8 commit c4f3713
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions adaptive_scheduler/_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ def submit(self, fn: Callable[..., Any], /, *args: Any, **kwargs: Any) -> Future
"""Submit a task to the executor."""

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

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

def finalize(self, *, start: bool = True) -> adaptive_scheduler.RunManager:
def finalize(self, *, start: bool = True) -> adaptive_scheduler.RunManager | None:
if self._run_manager is not None:
msg = "RunManager already initialized. Create a new SlurmExecutor instance."
raise RuntimeError(msg)
learners, fnames = self._to_learners()
if not learners:
return None
assert self.folder is not None
self._run_manager = adaptive_scheduler.slurm_run(
learners=learners,
Expand Down
3 changes: 3 additions & 0 deletions readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ build:
tools:
python: "mambaforge-4.10"

sphinx:
configuration: docs/source/conf.py

conda:
environment: docs/environment.yml

0 comments on commit c4f3713

Please # to comment.