resubmit 0.0.2__py3-none-any.whl → 0.0.3__py3-none-any.whl

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/__init__.py CHANGED
@@ -2,6 +2,5 @@
2
2
 
3
3
  from .submit import submit_jobs
4
4
  from .debug import maybe_attach_debugger
5
- from .slurm import make_default_slurm_params
6
5
 
7
- __all__ = ["submit_jobs", "maybe_attach_debugger", "make_default_slurm_params"]
6
+ __all__ = ["submit_jobs", "maybe_attach_debugger"]
resubmit/submit.py CHANGED
@@ -16,11 +16,18 @@ def submit_jobs(
16
16
  prompt: bool = True,
17
17
  local_run: bool = False,
18
18
  slurm_additional_parameters: Optional[Dict] = None,
19
+ constraint: Optional[str] = None,
20
+ reservation: Optional[str] = None,
19
21
  ):
20
22
  """Submit jobs described by `jobs_args` where each entry is a dict of kwargs for `func`.
21
23
 
22
24
  - If `local_run` is True, the function is called directly: `func(jobs_args)`.
23
25
  - Otherwise, submits via submitit.AutoExecutor and returns job objects or, if `block` is True, waits and returns results.
26
+
27
+ Optional Slurm settings `constraint` and `reservation` can be provided via explicit
28
+ parameters (they take precedence) or by passing `slurm_additional_parameters`.
29
+ If not provided, they are omitted so the code is not tied to cluster-specific
30
+ defaults.
24
31
  """
25
32
  jobs_list = list(jobs_args) if not isinstance(jobs_args, list) else jobs_args
26
33
 
@@ -42,19 +49,20 @@ def submit_jobs(
42
49
  print("submitting jobs")
43
50
  executor = submitit.AutoExecutor(folder=folder)
44
51
 
45
- # default slurm params
52
+ # default slurm params (keep cluster-specific options out unless explicitly set)
46
53
  if slurm_additional_parameters is None:
47
- slurm_additional_parameters = {
48
- "constraint": "thin",
49
- "reservation": "safe",
50
- "gpus": num_gpus,
51
- }
54
+ slurm_additional_parameters = {"gpus": num_gpus}
52
55
  else:
53
56
  slurm_additional_parameters = dict(slurm_additional_parameters)
54
57
  slurm_additional_parameters.setdefault("gpus", num_gpus)
55
58
 
59
+ # Allow explicit overrides similar to `account`.
56
60
  if account is not None:
57
61
  slurm_additional_parameters["account"] = account
62
+ if reservation is not None:
63
+ slurm_additional_parameters["reservation"] = reservation
64
+ if constraint is not None:
65
+ slurm_additional_parameters["constraint"] = constraint
58
66
 
59
67
  print("Slurm additional parameters:", slurm_additional_parameters)
60
68
 
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.4
2
+ Name: resubmit
3
+ Version: 0.0.3
4
+ Summary: Small wrapper around submitit to simplify cluster submissions
5
+ Author: Amir Mehrpanah
6
+ License: MIT
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: submitit>=0.8
10
+ Provides-Extra: debug
11
+ Requires-Dist: debugpy; extra == "debug"
12
+ Dynamic: license-file
13
+
14
+ # resubmit
15
+
16
+ Small utility library to simplify job submission with Submitit on SLURM clusters.
17
+
18
+ Quick usage:
19
+
20
+ - Install locally for development:
21
+
22
+ ```bash
23
+ pip install -e .[debug]
24
+ ```
25
+
26
+ - Use in your project:
27
+
28
+ ```python
29
+ from resubmit import submit_jobs, maybe_attach_debugger
30
+
31
+ # attach remote debugger if requested
32
+ maybe_attach_debugger(args.get("port", None))
33
+
34
+ # submit jobs (list of dicts)
35
+ submit_jobs(jobs_list, my_entrypoint, timeout_min=60, block=True)
36
+ ```
37
+
38
+ ## API
39
+
40
+ ### submit_jobs(...) 🔧
41
+
42
+ Submit multiple jobs to a Slurm cluster using Submitit.
43
+
44
+ Signature (short):
45
+
46
+ `submit_jobs(jobs_args: Iterable[dict], func: Callable[[List[dict]], Any], *, timeout_min: int, cpus_per_task: int = 16, mem_gb: int = 64, num_gpus: int = 1, account: Optional[str] = None, folder: str = "logs/%j", block: bool = False, prompt: bool = True, local_run: bool = False, slurm_additional_parameters: Optional[Dict] = None, constraint: Optional[str] = None, reservation: Optional[str] = None)`
47
+
48
+ - `jobs_args`: iterable of per-job kwargs (each item is passed to `func`).
49
+ - `func`: entrypoint called for each job (should accept a list or single job dict depending on your usage).
50
+ - `timeout_min`, `cpus_per_task`, `mem_gb`, `num_gpus`: common Slurm resources.
51
+ - `account`: optional Slurm account name.
52
+ - `folder`: logs folder for Submitit files (supports `%j` for job id).
53
+ - `block`: if True, waits for all jobs and returns results.
54
+ - `prompt`: if True, asks for confirmation interactively; set to `False` for CI or tests.
55
+ - `local_run`: run the jobs locally without Submitit (useful for debugging).
56
+ - `slurm_additional_parameters`: pass any extra Slurm key/value pairs to Submitit.
57
+ - `constraint` / `reservation`: cluster-specific options kept out of defaults — provide them explicitly if you need them (they take precedence over values in `slurm_additional_parameters`).
58
+
59
+ Example:
60
+
61
+ ```python
62
+ submit_jobs(
63
+ jobs_list,
64
+ my_entrypoint,
65
+ timeout_min=60,
66
+ num_gpus=2,
67
+ prompt=False,
68
+ constraint="gpu",
69
+ )
70
+ ```
71
+
72
+ ### maybe_attach_debugger(port: Optional[int]) 🐞
73
+
74
+ Attach `debugpy` to the job when `port` is provided (> 0). Safe no-op if `port` is `None` or `<= 0`.
75
+
76
+ - If `debugpy` (and `submitit`) are not available on the node, a `RuntimeError` is raised with an explanatory message.
77
+
78
+ Example:
79
+
80
+ ```python
81
+ # attach remote debugger only when a port is provided (e.g., from CLI args)
82
+ maybe_attach_debugger(args.get("port"))
83
+ ```
84
+
85
+ ---
86
+
87
+ Tips:
88
+ - Use `prompt=False` when calling `submit_jobs` from scripts or CI to avoid interactive prompts.
89
+ - Tests demonstrate non-interactive behavior (`prompt=False`) and optional `constraint`/`reservation` handling.
@@ -0,0 +1,8 @@
1
+ resubmit/__init__.py,sha256=E9oorHt7ntQZgLeV9GtB79jHJCCC9WR5_skifBMHnGQ,210
2
+ resubmit/debug.py,sha256=8RINyz7eSAiT47d018wR0R3B_u4PllQJCiLy0zTSQDE,887
3
+ resubmit/submit.py,sha256=iyL-VTDmL_2YvdOAbfeJTH9m4FVb7lLXQLnOIoHqIZI,2874
4
+ resubmit-0.0.3.dist-info/licenses/LICENSE,sha256=v2spsd7N1pKFFh2G8wGP_45iwe5S0DYiJzG4im8Rupc,1066
5
+ resubmit-0.0.3.dist-info/METADATA,sha256=lVUYWXWkdtlco8409sxgQAzjvTp60_lM_FOrKRrj72I,2976
6
+ resubmit-0.0.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
7
+ resubmit-0.0.3.dist-info/top_level.txt,sha256=BfCexfX-VhUZuNi8sI88i0HF_e3ppausQ76hxPeXjYc,9
8
+ resubmit-0.0.3.dist-info/RECORD,,
resubmit/slurm.py DELETED
@@ -1,10 +0,0 @@
1
- """Small helpers for SLURM parameter construction."""
2
-
3
-
4
- from typing import Optional
5
-
6
- def make_default_slurm_params(gpus: int = 1, constraint: str = "thin", reservation: str = "safe", account: Optional[str] = None) -> dict:
7
- params = {"constraint": constraint, "reservation": reservation, "gpus": gpus}
8
- if account is not None:
9
- params["account"] = account
10
- return params
@@ -1,36 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: resubmit
3
- Version: 0.0.2
4
- Summary: Small wrapper around submitit to simplify cluster submissions
5
- Author: Amir Mehrpanah
6
- License: MIT
7
- Description-Content-Type: text/markdown
8
- License-File: LICENSE
9
- Requires-Dist: submitit>=0.8
10
- Provides-Extra: debug
11
- Requires-Dist: debugpy; extra == "debug"
12
- Dynamic: license-file
13
-
14
- # resubmit
15
-
16
- Small utility library to simplify job submission with Submitit on SLURM clusters.
17
-
18
- Quick usage:
19
-
20
- - Install locally for development:
21
-
22
- ```bash
23
- pip install -e .[debug]
24
- ```
25
-
26
- - Use in your project:
27
-
28
- ```python
29
- from resubmit import submit_jobs, maybe_attach_debugger
30
-
31
- # attach remote debugger if requested
32
- maybe_attach_debugger(args.get("port", None))
33
-
34
- # submit jobs (list of dicts)
35
- submit_jobs(jobs_list, my_entrypoint, timeout_min=60, block=True)
36
- ```
@@ -1,9 +0,0 @@
1
- resubmit/__init__.py,sha256=nuOlPF_zmRDxn_bmCE_rseLYL-DNC8f4UC6vHicEcig,284
2
- resubmit/debug.py,sha256=8RINyz7eSAiT47d018wR0R3B_u4PllQJCiLy0zTSQDE,887
3
- resubmit/slurm.py,sha256=-mez8sQh0ADTL8xL3cV2ureGn1uvNaR-Uuu7K_qePAY,387
4
- resubmit/submit.py,sha256=KBN4RDCjmn5Gg7wDogbtytEbTT66xMteTXGpHpHEYFo,2319
5
- resubmit-0.0.2.dist-info/licenses/LICENSE,sha256=v2spsd7N1pKFFh2G8wGP_45iwe5S0DYiJzG4im8Rupc,1066
6
- resubmit-0.0.2.dist-info/METADATA,sha256=V2YBAdAukURde6IKVC6TDUIsNMoV679OyUlGfvbC0iE,794
7
- resubmit-0.0.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
8
- resubmit-0.0.2.dist-info/top_level.txt,sha256=BfCexfX-VhUZuNi8sI88i0HF_e3ppausQ76hxPeXjYc,9
9
- resubmit-0.0.2.dist-info/RECORD,,