Skip to content

Commit

Permalink
Adds non-blocking mode to hydra_submitit_launcher (facebookresearch#2479
Browse files Browse the repository at this point in the history
)
  • Loading branch information
OWissett committed Oct 4, 2024
1 parent 2321051 commit 977871c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class BaseQueueConf:
# redirect stderr to stdout
stderr_to_stdout: bool = False

# If True, the launcher will not wait for the job to finish (useful for very long runs)
no_block: bool = False


@dataclass
class SlurmQueueConf(BaseQueueConf):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class BaseSubmititLauncher(Launcher):
_EXECUTOR = "abstract"

def __init__(self, **params: Any) -> None:
self.no_block = params.pop("no_block", False)
self.params = {}
for k, v in params.items():
if OmegaConf.is_config(v):
Expand Down Expand Up @@ -142,7 +143,11 @@ def launch(
)

jobs = executor.map_array(self, *zip(*job_params))
return [j.results()[0] for j in jobs]

if self.no_block:
return []
else:
return [j.results()[0] for j in jobs]


class LocalLauncher(BaseSubmititLauncher):
Expand Down
13 changes: 13 additions & 0 deletions plugins/hydra_submitit_launcher/tests/test_submitit_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,16 @@ def test_example(tmpdir: Path) -> None:
],
allow_warnings=True,
)


def test_example_no_block(tmpdir: Path) -> None:
run_python_script(
[
"example/my_app.py",
"-m",
f"hydra.sweep.dir={tmpdir}",
"hydra/launcher=submitit_local",
"hydra.launcher.no_block=True",
],
allow_warnings=True,
)

0 comments on commit 977871c

Please sign in to comment.