Skip to content

Commit

Permalink
fix: reordered such that functions follow 'post_init'
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeesters committed Jan 2, 2025
1 parent 6f74d18 commit 63b4f59
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions snakemake_executor_plugin_slurm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 63b4f59

Please sign in to comment.