Skip to content

Commit

Permalink
move write_script function into the abstract worker class to fix simi…
Browse files Browse the repository at this point in the history
…larity linting error
  • Loading branch information
leahh committed Feb 25, 2025
1 parent 283abf5 commit b5f820a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
9 changes: 0 additions & 9 deletions beeflow/common/worker/lsf_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ def __init__(self, bee_workdir, **kwargs):
# Check for extra runner options
self.runner_opts = kwargs['runner_opts'] if 'runner_opts' in kwargs else ''

def write_script(self, task):
"""Build task script; returns filename of script."""
task_text = self.build_text(task)
task_script = f'{self.task_save_path(task)}/{task.name}-{task.id}.sh'
with open(task_script, 'w', encoding='UTF-8') as script_f:
script_f.write(task_text)
script_f.close()
return task_script

def query_job(self, job_id):
"""Query lsf for job status."""
job_st = subprocess.check_output(['bjobs', '-aX', str(job_id), '-noheader'],
Expand Down
10 changes: 0 additions & 10 deletions beeflow/common/worker/slurm_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,6 @@ def srun(script_lines, script_cmd):

return '\n'.join(script)

def write_script(self, task):
"""Build task script; returns filename of script."""
task_text = self.build_text(task)

task_script = f'{self.task_save_path(task)}/{task.name}-{task.id}.sh'
with open(task_script, 'w', encoding='UTF-8') as script_f:
script_f.write(task_text)
script_f.close()
return task_script

def submit_job(self, script):
"""Worker submits job-returns (job_id, job_state)."""
res = subprocess.run(['sbatch', '--parsable', script], text=True, # pylint: disable=W1510
Expand Down
9 changes: 9 additions & 0 deletions beeflow/common/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ def task_save_path(self, task):
"""Return the task save path used for storing submission scripts output logs."""
return f'{self.workdir}/workflows/{task.workflow_id}/{task.name}-{task.id}'

def write_script(self, task):
"""Build task script; returns filename of script."""
task_text = self.build_text(task)
task_script = f'{self.task_save_path(task)}/{task.name}-{task.id}.sh'
with open(task_script, 'w', encoding='UTF-8') as script_f:
script_f.write(task_text)
script_f.close()
return task_script

def prepare(self, task):
"""Prepare for the task; create the task save directory, etc."""
task_save_path = self.task_save_path(task)
Expand Down

0 comments on commit b5f820a

Please sign in to comment.