Version:

salvus.flow.executors.job

salvus.flow.executors.job salvus flow executors job
The main job class.

Classes

Job

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.
SIGNATURE
class Job(builtins.object):
    def __init__(
        self,
        site: BaseExecutor,
        commands: list[executor_utils.RemoteCommand],
        job_type: str,
        job_description: str,
        job_info: dict,
        jobname: str | None = None,
        jobname_postfix: str = "",
        is_debug_job: bool = False,
        wall_time_in_seconds: salvus._core.types.float_ | None = None,
        job_groups: list[str | salvus_flow_db.JobGroup] | None = None,
        rundir_root: _RemotePathInputType | None = None,
        tmpdir_root: _RemotePathInputType | None = None,
        working_dir: _RemotePathInputType | None = None,
        allow_uninitialized_site: bool = False,
        requires_tmp_dir: bool = False,
        initialize_on_site: bool = True,
        no_db: bool = False,
    ): ...
ARGUMENTS
Required
site
Type:BaseExecutor
Description:
The site this job is to be run at.
Required
commands
Type:list[executor_utils.RemoteCommand]
Description:
A list of remote command objects.
Required
job_type
Type:str
Description:
The type of job.
Required
job_description
Type:str
Description:
Short textual description about the text.
Required
job_info
Type:dict
Description:
Additional information about the job.
Optional
jobname
Type:str | None
Default value:None
Description:
Name of the job. A random one will be created if none is given.
Optional
jobname_postfix
Type:str
Default value:''
Description:
Optional postfix string for the job name.
Optional
is_debug_job
Type:bool
Default value:False
Description:
True if this job should be executed in the fast/debug queue if the site has one.
Optional
wall_time_in_seconds
Type:salvus._core.types.float_ | None
Default value:None
Description:
Wall time in seconds for the job. Not required for jobs on all sites.
Optional
job_groups
Type:list[str | salvus_flow_db.JobGroup] | None
Default value:None
Description:
List of job groups names this job should be part of.
Optional
rundir_root
Type:_RemotePathInputType | None
Default value:None
Description:
Specify what parent folder the run directory will be created in. Defaults to the directory in the site config.
Optional
tmpdir_root
Type:_RemotePathInputType | None
Default value:None
Description:
Specify what parent folder the tmp directory will be created in. Defaults to the directory in the site config.
Optional
working_dir
Type:_RemotePathInputType | None
Default value:None
Description:
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.
Optional
allow_uninitialized_site
Type:bool
Default value:False
Description:
Allows an uninitialized site - intended to only be used for the job that initializes the site.
Optional
requires_tmp_dir
Type:bool
Default value:False
Description:
The job does require a temporary directory.
Optional
initialize_on_site
Type:bool
Default value:True
Description:
Initialize on site. Should be true in most cases. False is useful for creating a Job object from the database.
Optional
no_db
Type:bool
Default value:False
Description:
Don't use the database. Only useful for jobs that initialize things that are required to populate the database.

Properties

  • db(salvus_flow_db.DB)-The currently used database.
  • full_name(str)-Returns the full name of a job as JOB_NAME@SITE_NAME.
  • ranks(int)-Return the maximum number of ranks of all the individual commands.
  • stderr(str)-Return the stderr of the job as a string.
  • stderr_path(_RemotePathType)-The stderr path of the job.
  • stdout(str)-Return the stdout of the job as a string.
  • stdout_path(_RemotePathType)-The stdout path of the job.

Methods

Job.cancel()
Cancel job.
SIGNATURE
def cancel(self, verbosity: int = 1) -> None: ...
ARGUMENTS
Optional
verbosity
Type:int
Default value:1
Description:
Verbosity level.
Job.create_random_job_name()
Create a random name.
SIGNATURE
def create_random_job_name(prefix: str = "job") -> str: ...
ARGUMENTS
Optional
prefix
Type:str
Default value:'job'
Description:
Prefix to give some structure to the randomness.
Job.delete()
Delete all data for a given job.
Will delete all remote files and the internal database entry.
SIGNATURE
def delete(
    self, verbosity: int = 1, allow_directory_deletion_failure: bool = False
) -> None: ...
ARGUMENTS
Optional
verbosity
Type:int
Default value:1
Description:
Verbosity level.
Optional
allow_directory_deletion_failure
Type:bool
Default value:False
Description:
If True this 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.
Job.get_status_from_db()
Returns the current status of the Job from the database. Please not that this might not be up-to-date.
SIGNATURE
def get_status_from_db(self) -> JobStatus: ...
Job.launch()
Launch the job.
SIGNATURE
def launch(
    self, verbosity: int = 1, interactive_tty: bool = False
) -> None: ...
ARGUMENTS
Optional
verbosity
Type:int
Default value:1
Description:
Verbosity level.
Optional
interactive_tty
Type:bool
Default value:False
Description:
Launch the job in an interactive terminal. Useful for debugging purposes. Only available for local sites.
Job.set_status_in_db()
Set the status in SalvusFlow's database.
SIGNATURE
def set_status_in_db(self, status: JobStatus) -> None: ...
ARGUMENTS
Required
status
Type:JobStatus
Description:
The status to be set.
Job.tail_stdout()
tail -f the stdout of the job.
This will launch a remote tail command and it only suitable for interactive use.
SIGNATURE
def tail_stdout(self) -> None: ...
Job.update_status()
Update the status of the job by interacting with the remote site.
SIGNATURE
def update_status(
    self,
    progress_callback: collections.abc.Callable[[dict], None] | None = None,
    force_update: bool = False,
) -> JobStatus: ...
ARGUMENTS
Optional
progress_callback
Type:collections.abc.Callable[[dict], None] | None
Default value:None
Description:
Callback function which will receive some information about the update.
Optional
force_update
Type:bool
Default value:False
Description:
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 to True will force an update nonetheless. Uses for this are for example if a job update fails for example due to a temporary network problem.
Job.wait()
Wait for the job to finish.
SIGNATURE
def wait(
    self,
    poll_interval_in_seconds: salvus._core.types.float_ | None = None,
    timeout_in_seconds: float | None = None,
    verbosity: int = 1,
    progress_callback: (
        collections.abc.Callable[[dict | str], None] | None
    ) = None,
) -> JobStatus: ...
ARGUMENTS
Optional
poll_interval_in_seconds
Type:salvus._core.types.float_ | None
Default value:None
Description:
If given, the site will be queried with this interval. Defaults to the site's default.
Optional
timeout_in_seconds
Type:float | None
Default value:None
Description:
Time in seconds after which this function will return, independent of the status.
Optional
verbosity
Type:int
Default value:1
Description:
The verbosity level.
Optional
progress_callback
Type:collections.abc.Callable[[dict | str], None] | None
Default value:None
Description:
Optional progress callback function. Will be called if there are any status updates. Will currently only be called with the Salvus status file contents.
PAGE CONTENTS