From 63b4f59a679fc26cae408f90d0261ed44a5cbf8b Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Thu, 2 Jan 2025 15:45:22 +0100 Subject: [PATCH] fix: reordered such that functions follow 'post_init' --- snakemake_executor_plugin_slurm/__init__.py | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/snakemake_executor_plugin_slurm/__init__.py b/snakemake_executor_plugin_slurm/__init__.py index 941ed49..6fff17d 100644 --- a/snakemake_executor_plugin_slurm/__init__.py +++ b/snakemake_executor_plugin_slurm/__init__.py @@ -124,6 +124,17 @@ class ExecutorSettings(ExecutorSettingsBase): # Required: # Implementation of your executor class Executor(RemoteExecutor): + def __post_init__(self): + # run check whether we are running in a SLURM job context + self.warn_on_jobcontext() + self.run_uuid = str(uuid.uuid4()) + self.logger.info(f"SLURM run ID: {self.run_uuid}") + self._fallback_account_arg = None + self._fallback_partition = None + self._preemption_warning = False # no preemption warning has been issued + + atexit.register(self.clean_old_logs) + def clean_old_logs(self) -> None: """Delete files older than specified age from the SLURM log directory.""" # shorthands: @@ -146,17 +157,6 @@ def clean_old_logs(self) -> None: except (OSError, FileNotFoundError) as e: self.logger.warning(f"Could not delete file {path}: {e}") - def __post_init__(self): - # run check whether we are running in a SLURM job context - self.warn_on_jobcontext() - self.run_uuid = str(uuid.uuid4()) - self.logger.info(f"SLURM run ID: {self.run_uuid}") - self._fallback_account_arg = None - self._fallback_partition = None - self._preemption_warning = False # no preemption warning has been issued - - atexit.register(self.clean_old_logs) - def warn_on_jobcontext(self, done=None): if not done: if "SLURM_JOB_ID" in os.environ: