Skip to content

Commit

Permalink
Merge e003df7 into 5a684ca
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Jun 7, 2023
2 parents 5a684ca + e003df7 commit ad1ff27
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 87 deletions.
76 changes: 21 additions & 55 deletions pyiron_base/jobs/job/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,8 @@
run_job_with_status_collect,
run_job_with_status_suspended,
run_job_with_status_finished,
run_job_with_runmode_manually,
run_job_with_runmode_modal,
run_job_with_runmode_non_modal,
run_job_with_runmode_interactive,
run_job_with_runmode_interactive_non_modal,
run_job_with_runmode_queue,
run_job_with_runmode_srun,
run_job_with_runmode_flux,
execute_job_with_external_executable,
)
from pyiron_base.jobs.job.util import (
Expand Down Expand Up @@ -739,6 +733,15 @@ def run_static(self):
"""
execute_job_with_external_executable(job=self)

def run_if_scheduler(self):
"""
The run if queue function is called by run if the user decides to submit the job to and queing system. The job
is submitted to the queuing system using subprocess.Popen()
Returns:
int: Returns the queue ID for the job.
"""
return run_job_with_runmode_queue(job=self)

def transfer_from_remote(self):
state.queue_adapter.get_job_from_remote(
working_directory="/".join(self.working_directory.split("/")[:-1]),
Expand Down Expand Up @@ -799,7 +802,18 @@ def run_if_interactive(self):
For jobs which executables are available as Python library, those can also be executed with a library call
instead of calling an external executable. This is usually faster than a single core python job.
"""
run_job_with_runmode_interactive(job=self)
raise NotImplementedError(
"This function needs to be implemented in the specific class."
)

def run_if_interactive_non_modal(self):
"""
For jobs which executables are available as Python library, those can also be executed with a library call
instead of calling an external executable. This is usually faster than a single core python job.
"""
raise NotImplementedError(
"This function needs to be implemented in the specific class."
)

def interactive_close(self):
"""
Expand Down Expand Up @@ -831,54 +845,6 @@ def interactive_flush(self, path="generic", include_last_step=True):
"This function needs to be implemented in the specific class."
)

def run_if_interactive_non_modal(self):
"""
For jobs which executables are available as Python library, those can also be executed with a library call
instead of calling an external executable. This is usually faster than a single core python job.
"""
run_job_with_runmode_interactive_non_modal(job=self)

def run_if_non_modal(self):
"""
The run if non modal function is called by run to execute the simulation in the background. For this we use
multiprocessing.Process()
"""
run_job_with_runmode_non_modal(job=self)

def run_if_srun(self):
"""
The run if srun function is called by run to execute the simulation using srun, this allows distributing
calculation to separate nodes in a SLURM based HPC cluster.
"""
run_job_with_runmode_srun(job=self)

def run_if_flux(self):
"""
The run if flux function is called by run to execute the simulation using flux, this allows distributing
calculation to separate nodes in a flux based HPC cluster.
"""
return run_job_with_runmode_flux(job=self, executor=self._flux_executor)

def run_if_manually(self, _manually_print=True):
"""
The run if manually function is called by run if the user decides to execute the simulation manually - this
might be helpful to debug a new job type or test updated executables.
Args:
_manually_print (bool): Print explanation how to run the simulation manually - default=True.
"""
run_job_with_runmode_manually(job=self, _manually_print=_manually_print)

def run_if_scheduler(self):
"""
The run if queue function is called by run if the user decides to submit the job to and queing system. The job
is submitted to the queuing system using subprocess.Popen()
Returns:
int: Returns the queue ID for the job.
"""
return run_job_with_runmode_queue(job=self)

def send_to_database(self):
"""
if the jobs should be store in the external/public database this could be implemented here, but currently it is
Expand Down
40 changes: 8 additions & 32 deletions pyiron_base/jobs/job/runfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@ def run_job_with_status_created(job):

# Different run modes
if job.server.run_mode.manual:
job.run_if_manually()
run_job_with_runmode_manually(job=job, _manually_print=True)
elif job.server.run_mode.worker:
job.run_if_manually(_manually_print=False)
run_job_with_runmode_manually(job=job, _manually_print=True)
elif job.server.run_mode.modal:
job.run_static()
elif job.server.run_mode.srun:
job.run_if_srun()
run_job_with_runmode_srun(job=job)
elif job.server.run_mode.flux:
return job.run_if_flux()
return run_job_with_runmode_flux(job=job, executor=job.flux_executor)
elif (
job.server.run_mode.non_modal
or job.server.run_mode.thread
or job.server.run_mode.worker
):
job.run_if_non_modal()
run_job_with_runmode_non_modal(job=job)
elif job.server.run_mode.queue:
job.run_if_scheduler()
elif job.server.run_mode.interactive:
Expand Down Expand Up @@ -293,32 +293,6 @@ def run_job_with_runmode_modal(job):
job.run_static()


def run_job_with_runmode_interactive(job):
"""
For jobs which executables are available as Python library, those can also be executed with a library call
instead of calling an external executable. This is usually faster than a single core python job.
Args:
job (GenericJob): pyiron job object
"""
raise NotImplementedError(
"This function needs to be implemented in the specific class."
)


def run_job_with_runmode_interactive_non_modal(job):
"""
For jobs which executables are available as Python library, those can also be executed with a library call
instead of calling an external executable. This is usually faster than a single core python job.
Args:
job (GenericJob): pyiron job object
"""
raise NotImplementedError(
"This function needs to be implemented in the specific class."
)


def run_job_with_runmode_non_modal(job):
"""
The run if non modal function is called by run to execute the simulation in the background. For this we use
Expand Down Expand Up @@ -446,7 +420,9 @@ def run_job_with_runmode_srun(job):
+ job.job_id
)
else:
raise ValueError("run_if_srun() does not support local databases.")
raise ValueError(
"run_job_with_runmode_srun() does not support local databases."
)
else:
command = (
"srun python -m pyiron_base.cli wrapper -p "
Expand Down

0 comments on commit ad1ff27

Please sign in to comment.