resubmit 0.0.6__tar.gz → 0.0.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: resubmit
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Small wrapper around submitit to simplify cluster submissions
5
5
  Author: Amir Mehrpanah
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "resubmit"
7
- version = "0.0.6"
7
+ version = "0.0.8"
8
8
  description = "Small wrapper around submitit to simplify cluster submissions"
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -153,6 +153,8 @@ def submit_jobs(
153
153
  block: bool = False,
154
154
  prompt: bool = True,
155
155
  local_run: bool = False,
156
+ debug: bool = False,
157
+ job_name: Optional[str] = "resubmit",
156
158
  slurm_additional_parameters: Dict | None = None,
157
159
  ) -> Any:
158
160
  """
@@ -173,6 +175,8 @@ def submit_jobs(
173
175
  block: Whether to block until jobs complete.
174
176
  prompt: Whether to prompt for confirmation before submission.
175
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.
176
180
  slurm_additional_parameters: Additional Slurm parameters as a dict. If not provided, defaults to {"gpus": num_gpus}.
177
181
  Returns:
178
182
  The result of `submit_jobs` from `.__submit`.
@@ -193,5 +197,7 @@ def submit_jobs(
193
197
  block=block,
194
198
  prompt=prompt,
195
199
  local_run=local_run,
200
+ debug=debug,
201
+ job_name=job_name,
196
202
  slurm_additional_parameters=slurm_additional_parameters,
197
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
- - If `local_run` is True, the function is called directly: `func(jobs_args)`.
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: resubmit
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Small wrapper around submitit to simplify cluster submissions
5
5
  Author: Amir Mehrpanah
6
6
  License: MIT
@@ -31,6 +31,26 @@ 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(monkeypatch):
35
+ jobs = [{"id": 1}, {"id": 2}, {"id": 3}]
36
+
37
+ res = _submit_jobs(
38
+ jobs,
39
+ dummy_func,
40
+ timeout_min=1,
41
+ local_run=True,
42
+ num_gpus=0,
43
+ cpus_per_task=1,
44
+ mem_gb=8,
45
+ folder="dummy/%j",
46
+ block=False,
47
+ prompt=False,
48
+ debug=True,
49
+ )
50
+ # only the first job should be run in debug mode
51
+ assert res == ["ok-1"]
52
+
53
+
34
54
  def test_slurm_parameters_optional(monkeypatch):
35
55
  events = {}
36
56
 
@@ -65,9 +85,10 @@ def test_slurm_parameters_optional(monkeypatch):
65
85
  mem_gb=16,
66
86
  folder="logs/%j",
67
87
  block=False,
88
+ slurm_additional_parameters={},
68
89
  )
69
90
  slurm = events["update"]["slurm_additional_parameters"]
70
- assert slurm["gpus"] == 2
91
+
71
92
  assert "constraint" not in slurm
72
93
  assert "reservation" not in slurm
73
94
 
@@ -112,4 +133,3 @@ def test_slurm_parameters_settable(monkeypatch):
112
133
  slurm = events["update"]["slurm_additional_parameters"]
113
134
  assert slurm["constraint"] == "thin"
114
135
  assert slurm["reservation"] == "safe"
115
-
File without changes
File without changes
File without changes