Skip to content

Commit

Permalink
Save slurm logs in a dedicated directory with a readable filename
Browse files Browse the repository at this point in the history
And set a readable job name.
  • Loading branch information
JamesWrigley committed Jul 5, 2023
1 parent 79e8ff8 commit 6a97fd0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions damnit/backend/extract_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,19 @@ def extract_and_ingest(self, proposal, run, cluster=False,
ctx = self.ctx_whole.filter(run_data=run_data, name_matches=match, cluster=cluster)
ctx_slurm = self.ctx_whole.filter(run_data=run_data, name_matches=match, cluster=True)
if set(ctx_slurm.vars) > set(ctx.vars):
slurm_logs_dir = Path.cwd() / "slurm_logs"
slurm_logs_dir.mkdir(exist_ok=True)
slurm_logs_dir.chmod(0o777)

python_cmd = [sys.executable, '-m', 'damnit.backend.extract_data',
'--cluster-job', str(proposal), str(run), run_data.value]
res = subprocess.run([
'sbatch', '--parsable',
*self.slurm_options(),
'-o', str(slurm_logs_dir / f"r{run}-p{proposal}-%j.out"),
# Note: we put the run number first so that it's visible in
# squeue's default 11-character column for the JobName.
'--job-name', f"r{run}-p{proposal}-damnit",
'--wrap', shlex.join(python_cmd)
], stdout=subprocess.PIPE, text=True)
job_id = res.stdout.partition(';')[0]
Expand Down

0 comments on commit 6a97fd0

Please sign in to comment.