hermes.commands.base

Classes

HermesSettings

Root class for HERMES configuration model.

HermesCommand

Base class for a HERMES workflow command.

HermesPlugin

Base class for all HERMES plugins.

HermesHelpSettings

Intentionally empty settings class for the help command.

HermesHelpCommand

Show help page and exit.

HermesVersionSettings

Intentionally empty settings class for the version command.

HermesVersionCommand

Show HERMES version and exit.

Module Contents

class hermes.commands.base.HermesSettings(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_prefix_target: pydantic_settings.sources.EnvPrefixTarget | None = None, _env_file: pydantic_settings.sources.DotenvType | None = ENV_FILE_SENTINEL, _env_file_encoding: str | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_nested_max_split: int | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: pydantic_settings.sources.CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_show_env_vars: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None, _cli_shortcuts: collections.abc.Mapping[str, str | list[str]] | None = None, _secrets_dir: pydantic_settings.sources.PathType | None = None, _build_sources: tuple[tuple[pydantic_settings.sources.PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None, **values: Any)

Bases: pydantic_settings.BaseSettings

Root class for HERMES configuration model.

model_config

The settings config dict for the settings of hermes.

Type:

SettingsConfigDict

class hermes.commands.base.HermesCommand(parser: argparse.ArgumentParser)

Bases: abc.ABC

Base class for a HERMES workflow command.

command_name

(class attribute) Only defined here for highlighting, the value of the subclass is is used.

Type:

str

settings_class

(class attribute) The settings class for the general hermes command settings

Type:

type

init_plugins() dict[str, type[HermesPlugin]]

Collect and initialize the plugins available for the HERMES command.

Returns:

A map mapping the plugin name to the plugin class for the current step.

Return type:

dict[str, HermesPlugin]

classmethod derive_settings_class(setting_types: dict[str, type[HermesPlugin]]) None

Build a new Pydantic data model class for configuration.

This will create a new class that includes all settings from the plugins available.

Parameters:

settings_types (dict[str, type]) – The settings classes for the plugins.

Return type:

None

Raises:

ValueError – If the command has no settings.

init_common_parser(parser: argparse.ArgumentParser) None

Initialize the common command line arguments available for all HERMES sub-commands.

Parameters:

parser (ArgumentsParser) – The base command line parser used as entry point when reading command line arguments.

Return type:

None

init_command_parser(command_parser: argparse.ArgumentParser) None

Initialize the command line arguments available for this specific HERMES sub-commands.

You should override this method to add your custom arguments to the command line parser of the respective sub-command.

Parameters:

command_parser (ArgumentParser) – The command line sub-parser responsible for the HERMES sub-command.

Return type:

None

load_settings(args: argparse.Namespace) None

Load settings from the configuration file (passed in from command line).

Parameters:

args (Namespace) – The namespace that was returned by the command line parser when reading the arguments.

Return type:

None

patch_settings(args: argparse.Namespace) None

Process command line options for the settings.

Parameters:

args (Namespace) – The namespace that was returned by the command line parser when reading the arguments.

Return type:

None

abstractmethod __call__(args: argparse.Namespace) None

Execute the HERMES sub-command.

Parameters:

args (Namespace) – The namespace that was returned by the command line parser when reading the arguments.

Return type:

None

class hermes.commands.base.HermesPlugin

Bases: abc.ABC

Base class for all HERMES plugins.

plugin_node

settings_class

The settings_class of the plugin.

abstractmethod __call__(command: HermesCommand) None

Execute the plugin.

Parameters:

command (HermesCommand) – The command that triggered this plugin to run.

Return type:

None

class hermes.commands.base.HermesHelpSettings(/, **data: Any)

Bases: pydantic.BaseModel

Intentionally empty settings class for the help command.

class hermes.commands.base.HermesHelpCommand(parser: argparse.ArgumentParser)

Bases: HermesCommand

Show help page and exit.

command_name

(class attribute) The name of the command.

Type:

str

settings_class

(class attribute) The settings class for general help settings.

Type:

type

init_command_parser(command_parser: argparse.ArgumentParser) None

Add arguments for help command.

Parameters:

command_parser (ArgumentParser) – The used argument parser.

Return type:

None

__call__(args: argparse.Namespace) None

Execute the hermes command self.

Parameters:

args (Namespace) – The namespace that was returned by the command line parser when reading the arguments.

Return type:

None

class hermes.commands.base.HermesVersionSettings(/, **data: Any)

Bases: pydantic.BaseModel

Intentionally empty settings class for the version command.

class hermes.commands.base.HermesVersionCommand(parser: argparse.ArgumentParser)

Bases: HermesCommand

Show HERMES version and exit.

command_name

(class attribute) The name of the command.

Type:

str

settings_class

(class attribute) The settings class for general help settings.

Type:

type

load_settings(args: argparse.Namespace) None

Pass loading settings as not necessary for this command.

Parameters:

args (Namespace) – The namespace that was returned by the command line parser when reading the arguments.

Return type:

None

__call__(args: argparse.Namespace) None

Execute the hermes command self.

Parameters:

args (Namespace) – The namespace that was returned by the command line parser when reading the arguments.

Return type:

None