Skip to content

Commit b00e520

Browse files
authored
fix: initializing self.slurm_logdir (#206)
setting `self.slurm_logdir` in `post_init`, else starts without something… to do, will encounter uninitialized `self.slurm_logdir attribute This PR ought to fix #198 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Improvements** - Enhanced SLURM log directory management - Added flexibility for custom log directory configuration - Simplified log directory initialization process <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 6dd0105 commit b00e520

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

snakemake_executor_plugin_slurm/__init__.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ def __post_init__(self):
122122
self._fallback_account_arg = None
123123
self._fallback_partition = None
124124
self._preemption_warning = False # no preemption warning has been issued
125-
self.slurm_logdir = None
125+
self.slurm_logdir = (
126+
Path(self.workflow.executor_settings.logdir)
127+
if self.workflow.executor_settings.logdir
128+
else Path(".snakemake/slurm_logs").resolve()
129+
)
126130
atexit.register(self.clean_old_logs)
127131

128132
def clean_old_logs(self) -> None:
@@ -180,12 +184,6 @@ def run_job(self, job: JobExecutorInterface):
180184
except AttributeError:
181185
wildcard_str = ""
182186

183-
self.slurm_logdir = (
184-
Path(self.workflow.executor_settings.logdir)
185-
if self.workflow.executor_settings.logdir
186-
else Path(".snakemake/slurm_logs").resolve()
187-
)
188-
189187
self.slurm_logdir.mkdir(parents=True, exist_ok=True)
190188
slurm_logfile = self.slurm_logdir / group_or_rule / wildcard_str / "%j.log"
191189
slurm_logfile.parent.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)