resubmit 0.0.7__tar.gz → 0.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {resubmit-0.0.7/src/resubmit.egg-info → resubmit-0.0.9}/PKG-INFO +1 -1
- {resubmit-0.0.7 → resubmit-0.0.9}/pyproject.toml +1 -1
- {resubmit-0.0.7 → resubmit-0.0.9}/src/resubmit/__bookkeeping.py +4 -0
- {resubmit-0.0.7 → resubmit-0.0.9}/src/resubmit/__submit.py +22 -2
- {resubmit-0.0.7 → resubmit-0.0.9/src/resubmit.egg-info}/PKG-INFO +1 -1
- {resubmit-0.0.7 → resubmit-0.0.9}/tests/test_resubmit.py +25 -2
- {resubmit-0.0.7 → resubmit-0.0.9}/LICENSE +0 -0
- {resubmit-0.0.7 → resubmit-0.0.9}/README.md +0 -0
- {resubmit-0.0.7 → resubmit-0.0.9}/setup.cfg +0 -0
- {resubmit-0.0.7 → resubmit-0.0.9}/src/resubmit/__debug.py +0 -0
- {resubmit-0.0.7 → resubmit-0.0.9}/src/resubmit/__init__.py +0 -0
- {resubmit-0.0.7 → resubmit-0.0.9}/src/resubmit.egg-info/SOURCES.txt +0 -0
- {resubmit-0.0.7 → resubmit-0.0.9}/src/resubmit.egg-info/dependency_links.txt +0 -0
- {resubmit-0.0.7 → resubmit-0.0.9}/src/resubmit.egg-info/requires.txt +0 -0
- {resubmit-0.0.7 → resubmit-0.0.9}/src/resubmit.egg-info/top_level.txt +0 -0
- {resubmit-0.0.7 → resubmit-0.0.9}/tests/test_bookkeeping.py +0 -0
|
@@ -153,6 +153,7 @@ def submit_jobs(
|
|
|
153
153
|
block: bool = False,
|
|
154
154
|
prompt: bool = True,
|
|
155
155
|
local_run: bool = False,
|
|
156
|
+
debug: bool = False,
|
|
156
157
|
job_name: Optional[str] = "resubmit",
|
|
157
158
|
slurm_additional_parameters: Dict | None = None,
|
|
158
159
|
) -> Any:
|
|
@@ -174,6 +175,8 @@ def submit_jobs(
|
|
|
174
175
|
block: Whether to block until jobs complete.
|
|
175
176
|
prompt: Whether to prompt for confirmation before submission.
|
|
176
177
|
local_run: If True, runs the function locally instead of submitting.
|
|
178
|
+
debug: If True, it runs only the first job in the queue for debugging.
|
|
179
|
+
job_name: Name of the job.
|
|
177
180
|
slurm_additional_parameters: Additional Slurm parameters as a dict. If not provided, defaults to {"gpus": num_gpus}.
|
|
178
181
|
Returns:
|
|
179
182
|
The result of `submit_jobs` from `.__submit`.
|
|
@@ -194,6 +197,7 @@ def submit_jobs(
|
|
|
194
197
|
block=block,
|
|
195
198
|
prompt=prompt,
|
|
196
199
|
local_run=local_run,
|
|
200
|
+
debug=debug,
|
|
197
201
|
job_name=job_name,
|
|
198
202
|
slurm_additional_parameters=slurm_additional_parameters,
|
|
199
203
|
)
|
|
@@ -15,12 +15,28 @@ def _submit_jobs(
|
|
|
15
15
|
block: bool,
|
|
16
16
|
prompt: bool,
|
|
17
17
|
local_run: bool,
|
|
18
|
+
debug: bool = False,
|
|
18
19
|
job_name: Optional[str] = "resubmit",
|
|
19
20
|
slurm_additional_parameters: Optional[Dict] = None,
|
|
20
21
|
):
|
|
21
22
|
"""Submit jobs described by `jobs_args` where each entry is a dict of kwargs for `func`.
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
Args:
|
|
25
|
+
jobs_args: Iterable of dicts of job parameters.
|
|
26
|
+
func: Function to be submitted for each job.
|
|
27
|
+
timeout_min: Job timeout in minutes.
|
|
28
|
+
cpus_per_task: Number of CPUs per task.
|
|
29
|
+
mem_gb: Memory in GB.
|
|
30
|
+
num_gpus: Number of GPUs.
|
|
31
|
+
folder: Folder for logs.
|
|
32
|
+
block: Whether to block until jobs complete.
|
|
33
|
+
prompt: Whether to prompt for confirmation before submission.
|
|
34
|
+
local_run: If True, runs the function locally instead of submitting.
|
|
35
|
+
debug: If True, runs only the first job in the queue for debugging.
|
|
36
|
+
job_name: Name of the job.
|
|
37
|
+
slurm_additional_parameters: Additional Slurm parameters as a dict. If not provided,
|
|
38
|
+
|
|
39
|
+
- If `local_run` is True, the function is called directly on the local machine: `func(jobs_args[0])`.
|
|
24
40
|
- Otherwise, submits via submitit.AutoExecutor and returns job objects or, if `block` is True, waits and returns results.
|
|
25
41
|
|
|
26
42
|
Optional Slurm settings `constraint` and `reservation` can be provided via explicit
|
|
@@ -30,12 +46,16 @@ def _submit_jobs(
|
|
|
30
46
|
"""
|
|
31
47
|
jobs_list = list(jobs_args) if not isinstance(jobs_args, list) else jobs_args
|
|
32
48
|
|
|
49
|
+
if debug:
|
|
50
|
+
print("Debug mode: only running the first job locally")
|
|
51
|
+
return func(jobs_list[0])
|
|
52
|
+
|
|
33
53
|
if len(jobs_list) == 0:
|
|
34
54
|
print("No jobs to run exiting")
|
|
35
55
|
return
|
|
36
56
|
|
|
37
57
|
if local_run:
|
|
38
|
-
print("Running locally (local_run=True)")
|
|
58
|
+
print("Running the jobs locally (local_run=True)")
|
|
39
59
|
return func(jobs_list)
|
|
40
60
|
|
|
41
61
|
if prompt:
|
|
@@ -31,6 +31,29 @@ def test_maybe_attach_debugger_noop():
|
|
|
31
31
|
maybe_attach_debugger(0)
|
|
32
32
|
|
|
33
33
|
|
|
34
|
+
def test_runs_only_the_first_job_in_debug_mode():
|
|
35
|
+
jobs = [{"id": 1}, {"id": 2}, {"id": 3}]
|
|
36
|
+
|
|
37
|
+
def dummy_func_single(job):
|
|
38
|
+
return f"ok-{job['id']}"
|
|
39
|
+
|
|
40
|
+
res = _submit_jobs(
|
|
41
|
+
jobs,
|
|
42
|
+
dummy_func_single,
|
|
43
|
+
timeout_min=1,
|
|
44
|
+
local_run=True,
|
|
45
|
+
num_gpus=0,
|
|
46
|
+
cpus_per_task=1,
|
|
47
|
+
mem_gb=8,
|
|
48
|
+
folder="dummy/%j",
|
|
49
|
+
block=False,
|
|
50
|
+
prompt=False,
|
|
51
|
+
debug=True,
|
|
52
|
+
)
|
|
53
|
+
# only the first job should be run in debug mode
|
|
54
|
+
assert res == "ok-1"
|
|
55
|
+
|
|
56
|
+
|
|
34
57
|
def test_slurm_parameters_optional(monkeypatch):
|
|
35
58
|
events = {}
|
|
36
59
|
|
|
@@ -65,9 +88,10 @@ def test_slurm_parameters_optional(monkeypatch):
|
|
|
65
88
|
mem_gb=16,
|
|
66
89
|
folder="logs/%j",
|
|
67
90
|
block=False,
|
|
91
|
+
slurm_additional_parameters={},
|
|
68
92
|
)
|
|
69
93
|
slurm = events["update"]["slurm_additional_parameters"]
|
|
70
|
-
|
|
94
|
+
|
|
71
95
|
assert "constraint" not in slurm
|
|
72
96
|
assert "reservation" not in slurm
|
|
73
97
|
|
|
@@ -112,4 +136,3 @@ def test_slurm_parameters_settable(monkeypatch):
|
|
|
112
136
|
slurm = events["update"]["slurm_additional_parameters"]
|
|
113
137
|
assert slurm["constraint"] == "thin"
|
|
114
138
|
assert slurm["reservation"] == "safe"
|
|
115
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|