salvus.flow.functions
Various functions to interact with SalvusFlow in a more direct way.
Functions
add_job_group()
add_job_group()def add_job_group(
name: str, description: str, info: Optional[Dict] = None
) -> None: ...Add a new job group to the database.
namestr — Name of the job group.descriptionstr — Description of the job group.infoOptional[Dict] — Optional info dictionary.
cancel_all_running_jobs()
cancel_all_running_jobs()def cancel_all_running_jobs(site_name: str, verbosity: int = 1) -> None: ...Cancel all running or pending jobs for a given site.
site_namestr — Name of the site which’s jobs to cancel.verbosityint — Verbosity level.
get_all_job_groups()
get_all_job_groups()def get_all_job_groups(
include_job_count: bool = False,
) -> List[salvus.flow.db.JobGroup]: ...Get all job groups from the database.
include_job_countbool — Count the jobs for each group. Potentially somewhat slow.
get_job()
get_job()def get_job(
site_name: str, job_name: str
) -> salvus.flow.executors.salvus_job.SalvusJob: ...Get a SalvusJob object by querying the database.
site_namestr — The site this job is on.job_namestr — The name of the job.
get_job_array()
get_job_array()def get_job_array(
site_name: str, job_array_name: str
) -> salvus.flow.executors.salvus_job_array.SalvusJobArray: ...Get a SalvusJobArray object.
site_namestr — The site this job array is on.job_array_namestr — The name of the job array.
get_job_arrays()
get_job_arrays()def get_job_arrays(
limit: Union[int, numpy.int32, numpy.int64] = 100,
site_name: Optional[str] = None,
job_array_status: Optional[
List[Union[salvus.flow.executors.types.JobStatus, str]]
] = None,
order_by: Iterable[str] = ("last_updated", "desc"),
update_job_arrays: bool = False,
) -> List[salvus.flow.executors.salvus_job_array.SalvusJobArray]: ...Query for a list of SalvusJobArray objects.
limitUnion[int, numpy.int32, numpy.int64] — Maximum number of returned job arrays.site_nameOptional[str] — Only return job arrays from this site.job_array_statusOptional[List[Union[salvus.flow.executors.types.JobStatus, str]]] — Limit returned jobs to job arrays with these statuses. Will return any job if not given.order_byIterable[str] — Choose how to order by (database column, direction). Available database columns are"last_updated","job_array_start_time","job_array_end_time", and"status".update_job_arraysbool — Update pending/running job arrays.
get_jobs()
get_jobs()def get_jobs(
limit: Union[int, numpy.int32, numpy.int64] = 100,
site_name: Optional[str] = None,
job_status: Optional[
List[Union[salvus.flow.executors.types.JobStatus, str]],
salvus.flow.executors.types.JobStatus,
] = None,
order_by: Iterable[str] = ("last_updated", "desc"),
update_jobs: bool = False,
skip_jobs_from_job_arrays: bool = True,
) -> List[salvus.flow.executors.salvus_job.SalvusJob]: ...Query for a list of SalvusJob objects.
limitUnion[int, numpy.int32, numpy.int64] — Maximum number of returned jobs.site_nameOptional[str] — Only return jobs from this site.job_statusOptional[List[Union[salvus.flow.executors.types.JobStatus, str]], salvus.flow.executors.types.JobStatus] — Limit returned jobs to jobs with these statuses. Will return jobs job if not given.order_byIterable[str] — Choose how to order by (database column, direction). Available database columns are"last_updated","job_start_time","job_end_time", and"status".update_jobsbool — Update pending/running jobs.skip_jobs_from_job_arraysbool — Don’t return jobs that are part of a job array.
get_site()
get_site()def get_site(
site_name: str, verbosity: int = 1, skip_version_number_check: bool = False
) -> salvus.flow.executors.base_executor.BaseExecutor: ...Get an initialized site object from the chose site.
site_namestr — Name of the remote executor.verbosityint — Verbosity level.skip_version_number_checkbool — Skip the version number check of the local Python version vs the remote site. Useful for initializing and updating sites.
get_task_chain()
get_task_chain()def get_task_chain(
site_name: str, job_name: str
) -> salvus.flow.executors.task_chain.task_chain.TaskChain: ...Get a TaskChain object by querying the database.
site_namestr — The site this job is on.job_namestr — The name of the job of the task chain.
initialize_site()
initialize_site()def initialize_site(
site_name: str,
verbosity: int = 1,
wait_for_initial_run_in_seconds: Union[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = 3.0,
) -> salvus.flow.executors.base_executor.BaseExecutor: ...Initialize a site using information from the config TOML file.
site_namestr — The name of the site.verbosityint — Verbosity level.wait_for_initial_run_in_secondsUnion[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — How long to wait for the job to finish before querying for the first time. 3 seconds is a good number for most cases, for testing this can be shortened.
run()
run()def run(
site_name: str,
input_file: Union[
str, pathlib.Path, Dict, salvus.flow.utils.deep_setters._DeepSetter
],
output_folder: Union[str, pathlib.Path],
ranks: Optional[int, numpy.int32, numpy.int64] = None,
wall_time_in_seconds: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
ping_interval_in_seconds: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
job_groups: Optional[List[str]] = None,
job_name: Optional[str] = None,
get_all: bool = False,
overwrite: bool = False,
delete_remote_files: bool = True,
raise_on_deletion_failure: bool = False,
verbosity: int = 1,
) -> salvus.flow.executors.salvus_job.SalvusJob: ...Run one Salvus simulation and block until it is done.
Will run the simulation, wait for it to be done, download all output files, and finally delete all remote files and the job’s entry in the Salvus internal database.
site_namestr — The remote executor to use.input_fileUnion[str, pathlib.Path, Dict, salvus.flow.utils.deep_setters._DeepSetter] — The input file or simulation object for the run.output_folderUnion[str, pathlib.Path] — Output files will be copied here.ranksOptional[int, numpy.int32, numpy.int64] — The number of ranks to run with. Defaults to the site’s configuration value.wall_time_in_secondsOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — The wall time in seconds if the site requires one.ping_interval_in_secondsOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — How often to query the remote site about the job status. Defaults to the site’s configuration value.job_groupsOptional[List[str]] — Job groups to attach to the job in the database.job_nameOptional[str] — Custom job name. Be careful with this.get_allbool — Get all output files. Wavefield outputs are omitted by default.overwritebool — Delete the output folder before running if it already exists.delete_remote_filesbool — Delete remote files after the run has finished.raise_on_deletion_failurebool — If True this function will raise if, after everything ran, there is an error in the cleanup stage. This can happen for example on networked file systems.verbosityint — The verbosity level.
salvus.flow.executors.salvus_job.SalvusJob object representing the job.run_async()
run_async()def run_async(
site_name: str,
input_file: Union[
str, pathlib.Path, Dict, salvus.flow.utils.deep_setters._DeepSetter
],
ranks: Optional[int, numpy.int32, numpy.int64] = None,
wall_time_in_seconds: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
job_groups: Optional[List[str]] = None,
job_name: Optional[str] = None,
verbosity: int = 1,
) -> salvus.flow.executors.salvus_job.SalvusJob: ...Launch one Salvus simulation asynchronously.
This function will return immediately upon successful submission of the job.
site_namestr — Name of the remote executor.input_fileUnion[str, pathlib.Path, Dict, salvus.flow.utils.deep_setters._DeepSetter] — The input file or simulation object for the run.ranksOptional[int, numpy.int32, numpy.int64] — The number of ranks to run with. Defaults to the site’s configuration value.wall_time_in_secondsOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — The wall time in seconds if the site requires one.job_groupsOptional[List[str]] — Job groups to attach to the job in the database.job_nameOptional[str] — Custom job name. Be careful with this.verbosityint — The verbosity level.
salvus.flow.executors.salvus_job.SalvusJob object representing the just submitted job.run_many()
run_many()def run_many(
site_name: str,
input_files: Iterable[
Union[
str, pathlib.Path, Dict, salvus.flow.utils.deep_setters._DeepSetter
]
],
output_folder: Union[str, pathlib.Path],
ranks_per_job: Optional[int, numpy.int32, numpy.int64] = None,
wall_time_in_seconds_per_job: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
ping_interval_in_seconds: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
get_all: bool = False,
overwrite: bool = False,
copy_partial_results: bool = True,
delete_remote_files: bool = True,
raise_on_deletion_failure: bool = False,
verbosity: int = 1,
) -> salvus.flow.executors.salvus_job_array.SalvusJobArray: ...Run many Salvus simulations and block until they are done.
Will run the simulations, wait them to be done, download all output files, and finally delete all remote files as well as the jobs’ entry in the Salvus internal database.
site_namestr — The remote executor to use.input_filesIterable[Union[str, pathlib.Path, Dict, salvus.flow.utils.deep_setters._DeepSetter]] — A list of input files or simulation objects to be run.output_folderUnion[str, pathlib.Path] — Output files will be copied here.ranks_per_jobOptional[int, numpy.int32, numpy.int64] — The number of ranks to run each job with. Defaults to the site’s configuration value.wall_time_in_seconds_per_jobOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — The wall time in seconds per job if the site requires one.ping_interval_in_secondsOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — How often to query the remote site about the jobs’ status. Defaults to the site’s configuration value.get_allbool — Get all output files. Wavefield outputs are omitted by default.overwritebool — Delete the output folder before running if it already exists.copy_partial_resultsbool — If this isTrue(the default) partial results will be copied over. This means that as long as a few jobs in the job array succeeded, these will be copied over. The function will still raise an exception but the data will be copied. Otherwise it will just raise.delete_remote_filesbool — Delete remote files after the run has finished.raise_on_deletion_failurebool — If True this function will raise if, after everything ran, there is an error in the cleanup stage. This can happen for example on networked file systems.verbosityint — The verbosity level.
run_many_async()
run_many_async()def run_many_async(
site_name: str,
input_files: Iterable[
Union[
str, pathlib.Path, Dict, salvus.flow.utils.deep_setters._DeepSetter
]
],
ranks_per_job: Optional[int, numpy.int32, numpy.int64] = None,
wall_time_in_seconds_per_job: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
job_groups: Optional[List[str]] = None,
verbosity: int = 1,
) -> salvus.flow.executors.salvus_job_array.SalvusJobArray: ...Launch many Salvus simulations asynchronously.
This function will return immediately upon successful submission of the jobs.
site_namestr — The remote executor to use.input_filesIterable[Union[str, pathlib.Path, Dict, salvus.flow.utils.deep_setters._DeepSetter]] — A list of input files or simulation objects to be run.ranks_per_jobOptional[int, numpy.int32, numpy.int64] — The number of ranks to run each job with. Defaults to the site’s configuration value.wall_time_in_seconds_per_jobOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — The wall time in seconds per job if the site requires one.job_groupsOptional[List[str]] — Job groups to attach to the job in the database.verbosityint — The verbosity level.
SalvusJobArray object representing the just submitted job array.run_task_chain()
run_task_chain()def run_task_chain(
site_name: str,
tasks: List[Union[salvus.flow.utils.deep_setters._DeepSetter, Callable]],
ranks: Union[int, numpy.int32, numpy.int64],
wall_time_in_seconds: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
data_files_to_upload: Optional[List[Union[pathlib.Path, str]]] = None,
ping_interval_in_seconds: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
job_name: Optional[str] = None,
verbosity: int = 1,
interactive_tty: bool = False,
) -> salvus.flow.executors.task_chain.task_chain.TaskChain: ...Launch a new task chain and wait for it to finish.
Contrary to the run() and run_many() functions this does not automatically download the results and cleans up all remote files. This still has to be done manually. The reasons for this is that task chains usually execute more complicated things and only some outputs are, in the end, required.
site_namestr — The remote executor to use.tasksList[Union[salvus.flow.utils.deep_setters._DeepSetter, Callable]] — A list of tasks. Each task can either be a Salvus simulation or a Python function.ranksUnion[int, numpy.int32, numpy.int64] — The number of ranks to run with. Will only affect the Salvus runs.wall_time_in_secondsOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — The wall time in seconds if the site requires one.data_files_to_uploadOptional[List[Union[pathlib.Path, str]]] — List of optional data files to upload to the task chain directory.ping_interval_in_secondsOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — How often to query the remote site about the job status. Defaults to the site’s configuration value.job_nameOptional[str] — Name of the task chain job.verbosityint — The verbosity level.interactive_ttybool — Flag for interactive tty.
run_task_chain_async()
run_task_chain_async()def run_task_chain_async(
site_name: str,
tasks: List[Union[salvus.flow.utils.deep_setters._DeepSetter, Callable]],
ranks: Union[int, numpy.int32, numpy.int64],
wall_time_in_seconds: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
data_files_to_upload: Optional[List[Union[pathlib.Path, str]]] = None,
job_name: Optional[str] = None,
verbosity: int = 1,
interactive_tty: bool = False,
) -> salvus.flow.executors.task_chain.task_chain.TaskChain: ...Launch a new task chain and return it.
site_namestr — The remote executor to use.tasksList[Union[salvus.flow.utils.deep_setters._DeepSetter, Callable]] — A list of tasks. Each task can either be a Salvus simulation or a Python function.ranksUnion[int, numpy.int32, numpy.int64] — The number of ranks to run with. Will only affect the Salvus runs.wall_time_in_secondsOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — The wall time in seconds if the site requires one.data_files_to_uploadOptional[List[Union[pathlib.Path, str]]] — List of optional data files to upload to the task chain directory.job_nameOptional[str] — Name of the task chain job.verbosityint — The verbosity level.interactive_ttybool — Flag for interactive tty.
set_config()
set_config()def set_config(
site_settings: Union[pathlib.Path, Dict], db_path: str
) -> None: ...Set the configuration for all API calls in this Python session.
site_settingsUnion[pathlib.Path, Dict] — Filename or existing dictionary with the site settings.db_pathstr — Path to the sqlite database used to internally keep track of things.
set_default_config()
set_default_config()def set_default_config() -> None: ...Reset the configuration for all API calls to the defaults.
Classes
add_new_executor
add_new_executorclass add_new_executor(builtins.object):
def __init__(
self,
site_name: str,
executor_type: str,
salvus_binary: types,
salvus_floating_point_size: Literal[32, 64] = 32,
run_directory: types,
tmp_directory: types,
use_cuda_capable_gpus: bool,
default_ranks: int,
max_ranks: int,
ssh_settings: types = None,
site_specific: types = None,
verbosity: int = 1,
overwrite: bool = False,
): ...Add a new site/executor to Salvus.
This is an alternative to the usual way of adding a site/executor via
add salvus-cli add-site and salvus-flow init-site. This function
will not test the configuration but just assume that it works. The
new site/executor will be immediately available for use.
site_namestr — The name of the site.executor_typestr — The type of executor. Can be “local”, “ssh”, or one of the other supported types.salvus_binarytypes — Path to the Salvus binary.salvus_floating_point_sizeLiteral[32, 64] — The floating point size of the Salvus binary in bit. Either 32 or 64. No check if performed if this is correct.run_directorytypes — The run directory of Salvus.tmp_directorytypes — The temp directory of Salvus.use_cuda_capable_gpusbool — Whether to use GPUs or not.default_ranksint — The default number of ranks to use.max_ranksint — The maximum number of ranks to use.ssh_settingstypes — SSH settings if the executor requires communication over SSH.site_specifictypes — Site specific settings.verbosityint — The verbosity level.overwritebool — Overwrite the site if it already exists.