jobflow_remote.config.manager module#
- class jobflow_remote.config.manager.ConfigManager(exclude_unset: bool = False, exclude_none: bool = False, warn: bool = False)[source]#
Bases:
object
A 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
- 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() list[str] [source]#
Parses all the prasable 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.
- Returns:
List of project names.
- 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.manager.ProjectData(filepath, project, ext)[source]#
Bases:
NamedTuple
Create new instance of ProjectData(filepath, project, ext)