genvid.sdk.ConfigurationLoader

class genvid.sdk.ConfigurationLoader(tool: BaseTool, renderer: Optional[Callable[[Union[Path, str], Optional[Mapping[str, str]]], Any]] = None)

Bases: object

This class provides methods to load or update configurations described by templates.

New in version 1.33.0.

Changed in version 1.43.0: Moved to genvid.sdk from the genvid.toolbox.

TemplateRenderer

alias of Callable[[Union[Path, str], Optional[Mapping[str, str]]], Any]

template_renderer

An optional template renderer to render the configuration files before loading them.

load_config_folder(source: Union[Path, str], *, env: Optional[Mapping[str, str]] = None, job_template_dir: Optional[Union[Path, str]] = None, with_consul_template: bool = False) dict

Loads the configuration file(s) (all files in a directory or a specific file) from the source and returns it.

Parameters:
  • source – Path to the configuration file/folder.

  • with_consul_template – Render the configuration file as template with the template_renderer before loading them if set to true.

  • job_template_dir – Path to Folder from where nomad templates should be loaded. If not mentioned, no jobs will be loaded.

  • env – An optional environment to use with the template_renderer. If None, the default environment will be used.

Returns:

The configuration as a dictionary that can be used directly with set_config().

Raises:

FileNotFoundError – If the job_template_dir is not None and is not a valid directory.

New in version 1.30.0.

Changed in version 1.33.0: Moved from ProjectTool.

load_nomad_job_template(name, job_folder: Union[Path, str])

Read nomad job templates from the specific directory. Files only with extension of .nomad.tmpl are read.

Parameters:
  • name – Name of the file without extension.

  • job_folder – Path to directory containing jobs.

New in version 1.30.0: Add support for pathlib.Path as job_folder.

Changed in version 1.33.0: Moved from ProjectTool.

update_config(config: dict, isLocal: bool)

Update the specified configuration.

Parameters:
  • config – The configuration to update.

  • isLocal – If the configuration is for a local cluster or a remote cluster.

Returns:

The updated configuration.

New in version 1.31.0.

Changed in version 1.33.0: Moved from ProjectTool.

class project.ConfigurationLoader

Implementation of genvid.sdk.ConfigurationLoader