Skip to content

Commit 3b2be74

Browse files
committed
slurm_submit_python() don't print cmd if running slurm interactively
only in log file or at job submission time
1 parent 9a41f7b commit 3b2be74

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ paper
2727
meeting-notes
2828
models/voronoi/*
2929
!models/voronoi/*.py
30+
pretrained

matbench_discovery/slurm.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ def slurm_submit_python(
6767
if array:
6868
cmd += ["--array", array]
6969

70-
running_as_slurm_job = "SLURM_JOB_ID" in os.environ
71-
if running_as_slurm_job or "slurm-submit" in sys.argv:
70+
is_log_file = not sys.stdout.isatty()
71+
is_slurm_job = "SLURM_JOB_ID" in os.environ
72+
if (is_slurm_job and is_log_file) or "slurm-submit" in sys.argv:
7273
# print sbatch command at submission time and into slurm log file
7374
# but not when running in command line or Jupyter
7475
print(" ".join(cmd))

models/wrenformer/slurm_array_wrenformer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
timestamp = f"{datetime.now():%Y-%m-%d@%H-%M-%S}"
5757

5858
print(f"Job started running {datetime.now():%Y-%m-%d@%H-%M}")
59-
slurm_job_id = os.environ["SLURM_JOB_ID"]
59+
slurm_job_id = os.environ.get("SLURM_JOB_ID")
6060
slurm_array_task_id = int(os.environ.get("SLURM_ARRAY_TASK_ID", 0))
6161

6262
print(f"{slurm_job_id=}")

0 commit comments

Comments
 (0)