Skip to content

Commit

Permalink
ref(basic python jobs): merge generation of script and submission
Browse files Browse the repository at this point in the history
The create_sbatch_script method is used nowhere else => No need to
seperate generation of job script from its submission
  • Loading branch information
leclairm committed Feb 6, 2024
1 parent 069502a commit 5541007
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,11 @@ def submit(self, job_name, script, add_dep=None):

return job_id

def create_sbatch_script(self, job_name):
"""Create an sbatch script to launch jobs individually.
def submit_basic_python(self, job_name):
"""Create an sbatch script to launch basic python jobs individually.
Use run_chain.py arguments to submit those jobs.
"""
# Build job script
walltime = getattr(self, 'walltime', {}).get(job_name, "00:30:00")
script_lines = [
'#!/usr/bin/env bash',
Expand All @@ -442,7 +443,8 @@ def create_sbatch_script(self, job_name):
with open(job_file, mode='w') as job_script:
job_script.write('\n'.join(script_lines))

return job_file
# Submit job
self.submit(job_name, job_file)

def wait_for_previous(self):
"""Wait for all jobs of the previous stage to be finished.
Expand Down
5 changes: 2 additions & 3 deletions run_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def run_chunk(cfg, force, resume):
print(f' └── Skipping "{job_name}" job')
skip = True
else:
print(f' └── Starting "{job_name}" job')
print(f' └── Submitting "{job_name}" job')

# Logfile settings
cfg.logfile = cfg.log_working_dir / job_name
Expand All @@ -179,8 +179,7 @@ def run_chunk(cfg, force, resume):
# Submit the job
job = getattr(jobs, job_name)
if hasattr(job, 'BASIC_PYTHON_JOB') and job.BASIC_PYTHON_JOB:
script = cfg.create_sbatch_script(job_name)
cfg.submit(job_name, script)
cfg.submit_basic_python(job_name)
else:
job.main(cfg)

Expand Down

0 comments on commit 5541007

Please sign in to comment.