jobflow_remote.config package#
Submodules#
- jobflow_remote.config.base module
BaseRemoteWorkerBaseRemoteWorker.connect_kwargsBaseRemoteWorker.connect_timeoutBaseRemoteWorker.forward_agentBaseRemoteWorker.gatewayBaseRemoteWorker.hostBaseRemoteWorker.inline_ssh_envBaseRemoteWorker.interactive_loginBaseRemoteWorker.keepaliveBaseRemoteWorker.key_filenameBaseRemoteWorker.login_shellBaseRemoteWorker.model_configBaseRemoteWorker.passphraseBaseRemoteWorker.passwordBaseRemoteWorker.portBaseRemoteWorker.shell_cmdBaseRemoteWorker.user
BatchConfigConfigErrorConnectionDataExecutionConfigLocalWorkerLogLevelProjectProject.base_dirProject.check_base_dir()Project.check_daemon_dir()Project.check_jobstore()Project.check_log_dir()Project.check_optional_jobstore()Project.check_tmp_dir()Project.check_unique_jobs_handle_dir()Project.daemon_dirProject.exec_configProject.get_job_controller()Project.get_jobstore()Project.get_queue_store()Project.has_interactive_workersProject.jobstoreProject.log_dirProject.log_levelProject.metadataProject.model_configProject.nameProject.optional_jobstoresProject.queueProject.remote_jobstoreProject.runnerProject.tmp_dirProject.workers
ProjectParsingErrorProjectUndefinedErrorQueueConfigRemoteWorkerRunnerOptionsRunnerOptions.delay_advance_statusRunnerOptions.delay_check_run_statusRunnerOptions.delay_checkoutRunnerOptions.delay_ping_dbRunnerOptions.delay_refresh_limitedRunnerOptions.delay_update_batchRunnerOptions.delete_tmp_folderRunnerOptions.delta_retryRunnerOptions.get_delta_retry()RunnerOptions.lock_timeoutRunnerOptions.max_step_attemptsRunnerOptions.model_config
SeparatedTransferWorkerWorkerBaseWorkerBase.batchWorkerBase.check_execution_cmd()WorkerBase.check_scheduler_type()WorkerBase.check_work_dir()WorkerBase.cli_infoWorkerBase.delay_downloadWorkerBase.execution_cmdWorkerBase.get_host()WorkerBase.get_scheduler_io()WorkerBase.is_batchWorkerBase.is_localWorkerBase.max_jobsWorkerBase.model_configWorkerBase.post_runWorkerBase.pre_runWorkerBase.resourcesWorkerBase.sanitize_commandWorkerBase.scheduler_typeWorkerBase.scheduler_usernameWorkerBase.timeout_executeWorkerBase.typeWorkerBase.work_dir
- jobflow_remote.config.helper module
- jobflow_remote.config.jobconfig module
- jobflow_remote.config.manager module
ConfigManagerConfigManager.backup_project()ConfigManager.create_project()ConfigManager.dump_project()ConfigManager.get_exec_config()ConfigManager.get_project()ConfigManager.get_project_data()ConfigManager.get_worker()ConfigManager.load_projects_data()ConfigManager.project_names_from_files()ConfigManager.projectsConfigManager.projects_extConfigManager.remove_exec_config()ConfigManager.remove_project()ConfigManager.remove_worker()ConfigManager.select_project_name()ConfigManager.set_exec_config()ConfigManager.set_jobstore()ConfigManager.set_queue_db()ConfigManager.set_worker()ConfigManager.update_project()
ProjectDataWorkerData
- jobflow_remote.config.settings module
JobflowRemoteSettingsJobflowRemoteSettings.cli_full_excJobflowRemoteSettings.cli_job_list_columnsJobflowRemoteSettings.cli_load_pluginsJobflowRemoteSettings.cli_log_levelJobflowRemoteSettings.cli_suggestionsJobflowRemoteSettings.config_fileJobflowRemoteSettings.load_default_settings()JobflowRemoteSettings.model_configJobflowRemoteSettings.projectJobflowRemoteSettings.projects_folder
Module contents#
- exception jobflow_remote.config.ConfigError[source]#
Bases:
ExceptionA generic Exception related to the configuration.
- class jobflow_remote.config.ConfigManager(exclude_unset: bool = False, exclude_none: bool = False, warn: bool = False)[source]#
Bases:
objectA manager for the projects configuration files.
Provides tool to parse project information from the selected projects folder as well as methods to update the properties of each project.
- Parameters:
exclude_unset – when dumping projects determine whether fields which were not explicitly set when creating the model should be excluded from the dictionary
exclude_none – when dumping projects determine whether fields which are equal to None should be excluded from the dictionary
warn – if True print warnings related to the parsing of the files in the projects folder
- backup_project(project_name: str) None[source]#
Create the backup of a project file using the naming convention $FILENAME.bak.$N
- Parameters:
project_name – Name of the project to be removed.
- create_project(project: Project, ext='yaml') None[source]#
Create a new Project in the project folder by dumping the project to file.
- Parameters:
project – The data of the project to be created.
ext –
- The extension of the file to which the project will be dumped (yaml, json
or toml)
- dump_project(project_data: ProjectData) None[source]#
Dump the project to filepath specified in the ProjectData.
- Parameters:
project_data – The project data to be dumped
- get_exec_config(exec_config_name: str, project_name: str | None = None) ExecutionConfig[source]#
Return the ExecutionConfig object based on the name.
- Parameters:
exec_config_name – Name of the ExecutionConfig.
project_name – Name of the project from which the ExecutionConfig should be retrieved, or None to use the one from the settings.
- Returns:
The selected ExecutionConfig
- Return type:
- get_project(project_name: str | None = None) Project[source]#
Get the Project object based from the project name.
- Parameters:
project_name – The name of the project or None to use the value from the settings
- Returns:
The selected Project
- Return type:
- get_project_data(project_name: str | None = None) ProjectData[source]#
Get the ProjectData object based from the project name.
- Parameters:
project_name – The name of the project or None to use the value from the settings
- Returns:
The selected ProjectData
- Return type:
- get_worker(worker_name: str, project_name: str | None = None) WorkerBase[source]#
Return the worker object based on the name.
- Parameters:
worker_name – Name of the worker to retrieve.
project_name – Name of the project from which the Worker should be retrieved, or None to use the one from the settings.
- Returns:
The selected Worker.
- Return type:
- load_projects_data() dict[str, ProjectData][source]#
Load projects from the selected projects folder.
- Returns:
Dictionary with project name as key and ProjectData as value.
- Return type:
- project_names_from_files(*, suppress_warnings: bool = False) tuple[list[str], list[str]][source]#
Parses all the parsable files and only checks for the “name” attribute to return a list of potential project file names.
Useful in case some projects cannot be properly parsed, but the full list needs to be returned.
- Parameters:
suppress_warnings – If set to True, suppress warnings related to the parsing of the files in the projects folder.
- Returns:
List of project names + List of erroneous files
- Return type:
- property projects: dict[str, Project]#
returns: Dictionary with project name as key and Project as value. :rtype: dict
- projects_ext = ('json', 'yaml', 'toml')#
- remove_exec_config(exec_config_name: str, project_name: str | None = None) None[source]#
Remove an ExecutionConfig from the selected project.
- Parameters:
exec_config_name – Name of the ExecutionConfig to be removed
project_name – Name of the project from which the ExecutionConfig should be removed, or None to use the one from the settings.
- remove_project(project_name: str, remove_folders: bool = True) None[source]#
Remove a project from the projects folder.
- Parameters:
project_name – Name of the project to be removed.
remove_folders – Optionally remove the folders related to the project (e.g. tmp, log).
- remove_worker(worker_name: str, project_name: str | None = None) None[source]#
Remove a worker from the selected project.
- Parameters:
worker_name – Name of the worker to be removed
project_name – Name of the project from which the Worker should be removed, or None to use the one from the settings.
- select_project_name(project_name: str | None = None) str[source]#
Determine the project name to be used based on the passed value and on the general settings.
- Parameters:
project_name – The name of the project or None to use the value from the settings
- Returns:
The name of the selected project.
- Return type:
- set_exec_config(exec_config_name: str, exec_config: ExecutionConfig, project_name: str | None = None, replace: bool = False) None[source]#
Set an ExecutionConfig in the selected project. Can add a new ExecutionConfig or replace an existing one.
- Parameters:
exec_config_name – Name of the ExecutionConfig to be added or replaced.
exec_config – The ExecutionConfig.
project_name –
- Name of the project where the ExecutionConfig is set, or None to use
the one from the settings.
replace – Raise an exception if False and an ExecutionConfig with the chosen name already exists.
- set_jobstore(jobstore: JobStore, project_name: str | None = None) None[source]#
Set the project specific store used for jobflow.
- Parameters:
jobstore – A maggma Store
project_name – Name of the project where the Store is set, or None to use the one from the settings.
- set_queue_db(store: MongoStore, project_name: str | None = None) None[source]#
Set the project specific store used for managing the queue.
- Parameters:
store – A maggma Store
project_name – Name of the project where the Store is set, or None to use the one from the settings.
- set_worker(name: str, worker: WorkerBase, project_name: str | None = None, replace: bool = False) None[source]#
Set a worker in the selected project. Can add a new worker or replace an existing one.
- Parameters:
name – Name of the worker to be added or replaced.
worker – Worker to be set.
project_name – Name of the project where the Worker is set, or None to use the one from the settings.
replace – Raise an exception if False and a Worker with the chosen name already exists.
- class jobflow_remote.config.LocalWorker(*, type: Literal['local'] = 'local', scheduler_type: str | dict, work_dir: Path, resources: dict | None = None, pre_run: str | None = None, post_run: str | None = None, execution_cmd: str | None = None, timeout_execute: int = 60, max_jobs: Annotated[int | None, Ge(ge=0)] = None, batch: BatchConfig | None = None, scheduler_username: str | None = None, sanitize_command: bool = False, delay_download: int | None = None)[source]#
Bases:
WorkerBaseWorker representing the local host.
Executes command directly.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- property cli_info: dict#
Short information about the worker to be displayed in the command line interface.
- Return type:
A dictionary with the Worker short information.
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal['local']#
- class jobflow_remote.config.Project(*, name: str, base_dir: str | None = None, tmp_dir: str | None = None, log_dir: str | None = None, daemon_dir: str | None = None, log_level: LogLevel = LogLevel.INFO, runner: RunnerOptions = <factory>, workers: dict[str, ~types.Annotated[~jobflow_remote.config.base.LocalWorker | ~jobflow_remote.config.base.RemoteWorker | ~jobflow_remote.config.base.SeparatedTransferWorker, FieldInfo(annotation=NoneType, required=True, discriminator='type')]] = <factory>, queue: QueueConfig, exec_config: dict[str, ~jobflow_remote.config.base.ExecutionConfig]=<factory>, jobstore: dict = <factory>, remote_jobstore: dict | None = None, metadata: dict | None = None, optional_jobstores: dict[str, dict] | None=<factory>)[source]#
Bases:
BaseModelThe configurations of a Project.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- classmethod check_base_dir(base_dir: str, info: ValidationInfo) str[source]#
Validator to set the default of base_dir based on the project name.
- classmethod check_daemon_dir(daemon_dir: str, info: ValidationInfo) str[source]#
Validator to set the default of daemon_dir based on the base_dir.
- classmethod check_jobstore(jobstore: dict) dict[source]#
Check that the jobstore configuration could be converted to a JobStore.
- classmethod check_log_dir(log_dir: str, info: ValidationInfo) str[source]#
Validator to set the default of log_dir based on the base_dir.
- classmethod check_optional_jobstore(optional_jobstores: dict) dict[source]#
Check that the jobstore configuration could be converted to a JobStore.
- classmethod check_tmp_dir(tmp_dir: str, info: ValidationInfo) str[source]#
Validator to set the default of tmp_dir based on the base_dir.
- check_unique_jobs_handle_dir() Project[source]#
Ensure
batch.jobs_handle_diris unique among batch workers that share a host.Sharing the same directory on the same host among multiple batch workers leads to unpredictable behaviour at run time, since the runner uses it to exchange information with the jobs being executed. The same path on different hosts is fine, as the two filesystems are independent. Hosts are compared via the
__eq__of theBaseHostreturned byworker.get_host().
- exec_config: dict[str, ExecutionConfig]#
- get_jobstore(name: str | None = None) JobStore | None[source]#
Generate an instance of the JobStore based on the configuration.
- Parameters:
name – name of the JobStore to fetch. If None the default JobStore, otherwise one of the optional_jobstores.
- Return type:
A JobStore
- get_queue_store()[source]#
Generate an instance of a maggma Store based on the queue configuration.
- Return type:
A maggma Store
- property has_interactive_workers: bool#
True if any of the workers have interactive_login set to True.
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- queue: QueueConfig#
- runner: RunnerOptions#
- class jobflow_remote.config.ProjectData(filepath, project, ext)[source]#
Bases:
NamedTupleCreate new instance of ProjectData(filepath, project, ext)
- class jobflow_remote.config.RemoteWorker(*, type: Literal['remote'] = 'remote', scheduler_type: str | dict, work_dir: Path, resources: dict | None = None, pre_run: str | None = None, post_run: str | None = None, execution_cmd: str | None = None, timeout_execute: int = 60, max_jobs: Annotated[int | None, Ge(ge=0)] = None, batch: BatchConfig | None = None, scheduler_username: str | None = None, sanitize_command: bool = False, delay_download: int | None = None, host: str, user: str | None = None, port: int | None = None, password: str | None = None, key_filename: str | list[str] | None = None, passphrase: str | None = None, gateway: str | ConnectionData | None = None, forward_agent: bool | None = None, connect_timeout: int | None = None, connect_kwargs: dict | None = None, inline_ssh_env: bool | None = None, keepalive: int | None = 60, shell_cmd: str | None = 'bash', login_shell: bool = True, interactive_login: bool = False)[source]#
Bases:
BaseRemoteWorkerWorker representing a remote host reached through an SSH connection.
Uses a Fabric Connection. Check Fabric documentation for more details on the options defining a Connection.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- property cli_info: dict#
Short information about the worker to be displayed in the command line interface.
- Return type:
A dictionary with the Worker short information.
- get_host() BaseHost[source]#
Return the RemoteHost for this worker.
- Returns:
The RemoteHost instance for this worker.
- Return type:
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal['remote']#
- class jobflow_remote.config.RunnerOptions(*, delay_checkout: float = 30, delay_check_run_status: float = 30, delay_advance_status: float = 30, delay_refresh_limited: float = 600, delay_update_batch: float = 60, delay_ping_db: float = 3600, lock_timeout: float | None = 86400, delete_tmp_folder: bool = True, max_step_attempts: int = 3, delta_retry: tuple[float, ...] = (30, 300, 1200))[source]#
Bases:
BaseModelOptions to tune the execution of the Runner.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- get_delta_retry(step_attempts: int) float[source]#
The time to wait before retrying a failed advancement of the remote state, based on the number of attempts.
If exceeding the size of the list delta_retry, the last value is returned.
- Parameters:
step_attempts – The number of attempts advancing a remote state.
- Return type:
The delay in seconds.
- model_config = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].