Skip to content

Commit

Permalink
Add some docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaehn committed Jan 8, 2024
1 parent 44b9cd0 commit 192383d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ def finish_time_logging(self, job, launch_time):

def get_dep_ids(self, job_name, add_dep=None):
"""Get dependency job ids for `job_name`"""

# Initial list of dependencies
if add_dep is not None:
if type(add_dep) is int:
Expand Down Expand Up @@ -450,7 +449,6 @@ def get_dep_cmd(self, job_name, add_dep=None):

def submit(self, job_name, script, add_dep=None, logfile=None):
"""Submit job with dependencies"""

script_path = Path(script)
sbatch_cmd = ['sbatch', '--parsable']
if dep_cmd := self.get_dep_cmd(job_name, add_dep=add_dep):
Expand All @@ -474,7 +472,9 @@ def submit(self, job_name, script, add_dep=None, logfile=None):
return job_id

def check_job(self, exitcode, logfile=None):
# In case of ICON-ART, ignore the "invalid pointer" error on successful run
"""Check the exitcode returned by a job.
In case of ICON-ART, ignore the "invalid pointer" error on a successful run.
"""
if logfile and tools.grep("ART: ", logfile)['success'] and \
tools.grep("free(): invalid pointer", logfile)['success'] and \
tools.grep("clean-up finished", logfile)['success']:
Expand All @@ -484,6 +484,9 @@ def check_job(self, exitcode, logfile=None):
raise RuntimeError(f"sbatch returned exitcode {exitcode}")

def create_sbatch_script(self, job_name, log_file):
"""Create an sbatch script to launch jobs individually.
Use run_chain.py arguments to submit those jobs.
"""
script_lines = [
'#!/usr/bin/env bash',
f'#SBATCH --job-name="{job_name}_{self.job_id}"',
Expand All @@ -508,12 +511,11 @@ def create_sbatch_script(self, job_name, log_file):
return job_file

def wait_for_previous(self):
"""wait for all jobs of the previous stage to be finished
"""Wait for all jobs of the previous stage to be finished.
Do this by submitting a fake job depending on all jobs from the
'previous' stage.
"""

dep_ids = []
for ids in self.job_ids['previous'].values():
dep_ids.extend(ids)
Expand All @@ -539,7 +541,6 @@ def get_job_info(jobid, slurm_keys=['Elapsed']):
"""Return information from slurm job as given by sacct
All possible keys are given by `sacct --helpformat`"""

# Get info from sacct
cmd = [
'sacct', f'--format={', '.join(slurm_keys)}', '--parsable', '-j',
Expand Down

0 comments on commit 192383d

Please sign in to comment.