nshtrainer 0.8.4__py3-none-any.whl → 0.8.6__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.
nshtrainer/model/base.py CHANGED
@@ -15,7 +15,7 @@ from lightning.fabric.utilities.types import _MAP_LOCATION_TYPE, _PATH
15
15
  from lightning.pytorch import LightningDataModule, LightningModule, Trainer
16
16
  from lightning.pytorch.callbacks import Callback
17
17
  from lightning.pytorch.utilities.types import STEP_OUTPUT
18
- from typing_extensions import Self, TypeVar, deprecated, override
18
+ from typing_extensions import Self, TypeVar, override
19
19
 
20
20
  from .config import (
21
21
  BaseConfig,
@@ -39,12 +39,6 @@ THparams = TypeVar("THparams", bound=BaseConfig, infer_variance=True)
39
39
 
40
40
 
41
41
  class Base(DebugModuleMixin, Generic[THparams]):
42
- @deprecated("Use `ll.nn.MLP` instead.")
43
- def mlp(self, *args, **kwargs):
44
- from ..nn.mlp import MLP
45
-
46
- return MLP(*args, **kwargs)
47
-
48
42
  @torch.jit.unused
49
43
  @property
50
44
  def config(self) -> THparams:
@@ -150,7 +150,7 @@ class _SignalConnector(_LightningSignalConnector):
150
150
  cmd = ["scontrol", "requeue", job_id]
151
151
 
152
152
  # requeue job
153
- log.info(f"requeing job {job_id}...")
153
+ log.info(f"Requeuing job {job_id}...")
154
154
  try:
155
155
  result = subprocess.call(cmd)
156
156
  except FileNotFoundError:
@@ -202,18 +202,46 @@ class _SignalConnector(_LightningSignalConnector):
202
202
  exe = str((Path(bin_dir) / exe).resolve().absolute())
203
203
 
204
204
  log.info(f"Using LSF requeue executable: {exe}")
205
- cmd = [exe, job_id]
206
-
207
- # Requeue job
208
- log.info(f"Requeuing job {job_id}...")
209
- try:
210
- result = subprocess.call(cmd)
211
- except FileNotFoundError:
212
- # Retry with shell context if subprocess call fails
213
- result = subprocess.call(" ".join(cmd), shell=True)
214
205
 
215
- # Print result text
216
- if result == 0:
217
- log.info(f"Requeued LSF job: {job_id}")
206
+ # If NSHRUNNER_LSF_EXIT_SCRIPT_DIR exists, we should emit a bash script in that directory
207
+ # rather than calling the requeue command directly. This is because the requeue command
208
+ # is only available outside of the `jsrun` context, and the exit script is called within
209
+ # the `jsrun` context.
210
+ if not (exit_script_dir := os.getenv("NSHRUNNER_LSF_EXIT_SCRIPT_DIR")):
211
+ cmd = [exe, job_id]
212
+
213
+ # Requeue job
214
+ log.info(f"Requeuing job {job_id}...")
215
+ try:
216
+ result = subprocess.call(cmd)
217
+ except FileNotFoundError:
218
+ # Retry with shell context if subprocess call fails
219
+ result = subprocess.call(" ".join(cmd), shell=True)
220
+
221
+ # Print result text
222
+ if result == 0:
223
+ log.info(f"Requeued LSF job: {job_id}")
224
+ else:
225
+ log.warning(
226
+ f"Requeuing LSF job {job_id} failed with error code {result}"
227
+ )
218
228
  else:
219
- log.warning(f"Requeuing LSF job {job_id} failed with error code {result}")
229
+ log.critical(
230
+ "Environment variable NSHRUNNER_LSF_EXIT_SCRIPT_DIR found.\n"
231
+ "Writing requeue script to exit script directory."
232
+ )
233
+ exit_script_dir = Path(exit_script_dir)
234
+ assert (
235
+ exit_script_dir.is_dir()
236
+ ), f"Exit script directory {exit_script_dir} does not exist"
237
+
238
+ exit_script_path = exit_script_dir / f"requeue_{job_id}.sh"
239
+ log.info(f"Writing requeue script to {exit_script_path}")
240
+
241
+ with exit_script_path.open("w") as f:
242
+ f.write(f"#!/bin/bash\n{exe} {job_id}\n")
243
+
244
+ # Make the script executable
245
+ os.chmod(exit_script_path, 0o755)
246
+
247
+ log.info(f"Requeue script written to {exit_script_path}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nshtrainer
3
- Version: 0.8.4
3
+ Version: 0.8.6
4
4
  Summary:
5
5
  Author: Nima Shoghi
6
6
  Author-email: nimashoghi@gmail.com
@@ -46,7 +46,7 @@ nshtrainer/lr_scheduler/_base.py,sha256=7xOIuxQ86YHbFWG5a3gX46emQj1WN_LaY4-i0Q1T
46
46
  nshtrainer/lr_scheduler/linear_warmup_cosine.py,sha256=mn6cyizyI_stkXtg6zxIEGF9btIxMRWigUHUTlUYCSw,5221
47
47
  nshtrainer/lr_scheduler/reduce_lr_on_plateau.py,sha256=h76oTHYpMxauV_l6lviya5DW-WKArwxxf7ZQizhmbCw,2782
48
48
  nshtrainer/model/__init__.py,sha256=y32Hla-5whpzLL2BtCJpBakSp8o-1nQbpO0j_-xq_Po,1864
49
- nshtrainer/model/base.py,sha256=k2Qk_rH4FsBOib2PISXnG97SBlgeD1w_jw02NE4zEQI,21460
49
+ nshtrainer/model/base.py,sha256=YtqnjiMf0cLVjFEQuOLm5WwCkVnZftiHlIdCrxdax3s,21297
50
50
  nshtrainer/model/config.py,sha256=6lATW6-Z1SIDgQ1IWrGBVQKTr8DhL5b_rFbJHQz0d5o,66796
51
51
  nshtrainer/model/modules/callback.py,sha256=JF59U9-CjJsAIspEhTJbVaGN0wGctZG7UquE3IS7R8A,6408
52
52
  nshtrainer/model/modules/debug.py,sha256=DTVty8cKnzj1GCULRyGx_sWTTsq9NLi30dzqjRTnuCU,1127
@@ -65,13 +65,13 @@ nshtrainer/runner.py,sha256=7EumpnBkdNWjSNT9Gm-pkxAJ3W6-iMC-yae-WNeZcLw,3771
65
65
  nshtrainer/scripts/check_env.py,sha256=IMl6dSqsLYppI0XuCsVq8lK4bYqXwY9KHJkzsShz4Kg,806
66
66
  nshtrainer/scripts/find_packages.py,sha256=FbdlfmAefttFSMfaT0A46a-oHLP_ioaQKihwBfBeWeA,1467
67
67
  nshtrainer/trainer/__init__.py,sha256=P2rmr8oBVTHk-HJHYPcUwWqDEArMbPR4_rPpATbWK3E,40
68
- nshtrainer/trainer/signal_connector.py,sha256=QAoPM_C5JJOVQebcrJOimUUD3GHyoeZUqCEAvzZlT4U,8710
68
+ nshtrainer/trainer/signal_connector.py,sha256=WlB7yB7d6F-dKyJEcdsxxkpYq4lWVSl2OoiZKlFAuaw,10001
69
69
  nshtrainer/trainer/trainer.py,sha256=eYEYfY9v70MuorHcSf8nqM7f2CkmUHhpPcjCk4FJD7k,14034
70
70
  nshtrainer/util/environment.py,sha256=_SEtiQ_s5bL5pllUlf96AOUv15kNvCPvocVC13S7mIk,4166
71
71
  nshtrainer/util/seed.py,sha256=HEXgVs-wldByahOysKwq7506OHxdYTEgmP-tDQVAEkQ,287
72
72
  nshtrainer/util/slurm.py,sha256=rofIU26z3SdL79SF45tNez6juou1cyDLz07oXEZb9Hg,1566
73
73
  nshtrainer/util/typed.py,sha256=NGuDkDzFlc1fAoaXjOFZVbmj0mRFjsQi1E_hPa7Bn5U,128
74
74
  nshtrainer/util/typing_utils.py,sha256=8ptjSSLZxlmy4FY6lzzkoGoF5fGNClo8-B_c0XHQaNU,385
75
- nshtrainer-0.8.4.dist-info/METADATA,sha256=PS0Z7icSp22Ok5Bs6SnOc0PEBqg42kjXTnpW5jqQaxw,647
76
- nshtrainer-0.8.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
77
- nshtrainer-0.8.4.dist-info/RECORD,,
75
+ nshtrainer-0.8.6.dist-info/METADATA,sha256=5BOWb0DXYCmqYGIzVTApTBj9wOoo9V8so3yfRuYzE6g,647
76
+ nshtrainer-0.8.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
77
+ nshtrainer-0.8.6.dist-info/RECORD,,