nshtrainer 0.8.5__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.
@@ -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.5
3
+ Version: 0.8.6
4
4
  Summary:
5
5
  Author: Nima Shoghi
6
6
  Author-email: nimashoghi@gmail.com
@@ -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.5.dist-info/METADATA,sha256=swroihBvsK71kkd51ekyULjRaBGr3ujP9fZ4HDQqhN8,647
76
- nshtrainer-0.8.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
77
- nshtrainer-0.8.5.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,,