Skip to content

Commit

Permalink
fix: always create logdir before sbatch (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Apr 12, 2024
1 parent ecaa88b commit 79fb961
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions snakemake_executor_plugin_slurm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,25 @@ def run_job(self, job: JobExecutorInterface):
# with job_info being of type
# snakemake_interface_executor_plugins.executors.base.SubmittedJobInfo.

log_folder = f"group_{job.name}" if job.is_group() else f"rule_{job.name}"
group_or_rule = f"group_{job.name}" if job.is_group() else f"rule_{job.name}"

try:
wildcard_str = f"_{'_'.join(job.wildcards)}" if job.wildcards else ""
except AttributeError:
wildcard_str = ""

slurm_logfile = os.path.abspath(
f".snakemake/slurm_logs/{log_folder}/%j{wildcard_str}.log"
f".snakemake/slurm_logs/{group_or_rule}/{wildcard_str}/%j.log"
)
os.makedirs(os.path.dirname(slurm_logfile), exist_ok=True)
logdir = os.path.dirname(slurm_logfile)
# this behavior has been fixed in slurm 23.02, but there might be plenty of
# older versions around, hence we should rather be conservative here.
assert "%j" not in logdir, (
"bug: jobid placeholder in parent dir of logfile. This does not work as "
"we have to create that dir before submission in order to make sbatch "
"happy. Otherwise we get silent fails without logfiles being created."
)
os.makedirs(logdir, exist_ok=True)

# generic part of a submission string:
# we use a run_uuid as the job-name, to allow `--name`-based
Expand Down

0 comments on commit 79fb961

Please sign in to comment.