salvus.flow.sites.job
Classes
Job
Jobclass Job(builtins.object):
def __init__(
self,
site: salvus.flow.sites.base_site.BaseSite,
commands: List[salvus.flow.sites.site_utils.RemoteCommand],
job_type: str,
job_description: str,
job_info: Dict,
jobname: Optional[str] = None,
jobname_postfix: str = "",
is_debug_job: bool = False,
wall_time_in_seconds: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
job_groups: Optional[List[Union[str, salvus.flow.db.JobGroup]]] = None,
rundir_root: Optional[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
] = None,
tmpdir_root: Optional[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
] = None,
working_dir: Optional[
str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath
] = None,
allow_uninitialized_site: bool = False,
requires_tmp_dir: bool = False,
initialize_on_site: bool = True,
no_db: bool = False,
):
...A class representing a concrete job associated with a certain site.
A job is defined as a series of commands that require interaction with the job scheduler.
All interactions like updating the job or persisting some things to the database should flow over this class.
sitesalvus.flow.sites.base_site.BaseSite — The site this job is to be run at.commandsList[salvus.flow.sites.site_utils.RemoteCommand] — A list of remote command objects.job_typestr — The type of job.job_descriptionstr — Short textual description about the text.job_infoDict — Additional information about the job.jobnameOptional[str] — Name of the job. A random one will be created if none is given.jobname_postfixstr — Optional postfix string for the job name.is_debug_jobbool — True if this job should be executed in the fast/debug queue if the site has one.wall_time_in_secondsOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Wall time in seconds for the job. Not required for jobs on all sites.job_groupsOptional[List[Union[str, salvus.flow.db.JobGroup]]] — List of job groups names this job should be part of.rundir_rootOptional[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Specify what parent folder the run directory will be created in. Defaults to the directory in the site config.tmpdir_rootOptional[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Specify what parent folder the tmp directory will be created in. Defaults to the directory in the site config.working_dirOptional[str, pathlib.Path, pathlib.PurePosixPath, pathlib.PureWindowsPath] — Working directory. If not given it will be set to the job directory. Should only be set if the job is part of a job array.allow_uninitialized_sitebool — Allows an uninitialized site - intended to only be used for the job that initializes the site.requires_tmp_dirbool — The job does require a temporary directory.initialize_on_sitebool — Initialize on site. Should be true in most cases. False is useful for creating a Job object from the database.no_dbbool — Don’t use the database. Only useful for jobs that initialize things that are required to populate the database.
db salvus.flow.db.DB
db salvus.flow.db.DBThe currently used database.
full_name str
full_name strThe job’s full name.
ranks int
ranks intReturn the maximum number of ranks of all the individual commands.
stderr str
stderr strReturn the stderr of the job as a string.
stderr_path Union[pathlib.PurePosixPath, pathlib.PureWindowsPath]
stderr_path Union[pathlib.PurePosixPath, pathlib.PureWindowsPath]The stderr path of the job.
stdout str
stdout strReturn the stdout of the job as a string.
stdout_path Union[pathlib.PurePosixPath, pathlib.PureWindowsPath]
stdout_path Union[pathlib.PurePosixPath, pathlib.PureWindowsPath]The stdout path of the job.
cancel()
cancel()def cancel(self, verbosity: int = 1) -> None:
...Cancel job.
verbosityint — Verbosity level.
create_random_job_name()
create_random_job_name()def create_random_job_name(prefix: str = "job") -> str:
...Create a random name.
prefixstr — Prefix to give some structure to the randomness.
delete()
delete()def delete(
self, verbosity: int = 1, allow_directory_deletion_failure: bool = False
) -> None:
...Deletes the data of a job if it is not running or pending.
Will delete all remote files and the internal database entry.
verbosityint — Verbosity level.allow_directory_deletion_failurebool — IfTruethis function will still return successfully (but raise a warning) if the deletion of the remote Salvus managed files failed for some reason. This can easily happen on for example networked file systems.
get_status_from_db()
get_status_from_db()def get_status_from_db(self) -> salvus.flow.sites.types.JobStatus:
...Returns the current status of the Job from the database. Please not that this might not be up-to-date.
launch()
launch()def launch(self, verbosity: int = 1, interactive_tty: bool = False) -> None:
...Launch the job.
verbosityint — Verbosity level.interactive_ttybool — Launch the job in an interactive terminal. Useful for debugging purposes. Only available forlocalsites.
set_status_in_db()
set_status_in_db()def set_status_in_db(self, status: salvus.flow.sites.types.JobStatus) -> None:
...Set the status in SalvusFlow’s database.
statussalvus.flow.sites.types.JobStatus — The status to be set.
tail_stdout()
tail_stdout()def tail_stdout(self) -> None:
...tail -f the stdout of the job.
This will launch a remote tail command and it only suitable for
interactive use.
update_status()
update_status()def update_status(
self,
progress_callback: Optional[Callable[[Dict], NoneType]] = None,
force_update: bool = False,
) -> salvus.flow.sites.types.JobStatus:
...Update the status of the job by interacting with the remote site.
progress_callbackOptional[Callable[[Dict], NoneType]] — Callback function which will receive some information about the update.force_updatebool — Jobs that are not running and not pending will by default only query the local job database and not check the remote site. In most cases this is correct as the jobs are done with and will not change again. Setting this toTruewill force an update nonetheless. Uses for this are for example if a job update fails for example due to a temporary network problem.
wait()
wait()def wait(
self,
poll_interval_in_seconds: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
timeout_in_seconds: Optional[float] = None,
verbosity: int = 1,
progress_callback: Optional[Callable[[Union[Dict, str]], NoneType]] = None,
) -> salvus.flow.sites.types.JobStatus:
...Wait for the job to finish.
poll_interval_in_secondsOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — If given, the site will be queried with this interval. Defaults to the site’s default.timeout_in_secondsOptional[float] — Time in seconds after which this function will return, independent of the status.verbosityint — The verbosity level.progress_callbackOptional[Callable[[Union[Dict, str]], NoneType]] — Optional progress callback function. Will be called if there are any status updates. Will currently only be called with the Salvus status file contents.