hyrax.verbs.verb_registry#

Attributes#

Classes#

Verb

Base class for all hyrax verbs

Functions#

hyrax_verb(→ type[Verb])

Decorator to register a hyrax verb

all_verbs(→ list[str])

Returns all verbs that are currently registered

all_class_verbs(→ list[str])

Returns all verbs that are currently registered with a class-based implementation

is_verb_class(→ bool)

Returns true if the verb has a class based implementation

fetch_verb_class(→ type[Verb] | None)

Gives the class object for the named verb

Module Contents#

logger[source]#
class Verb(config)[source]#

Bases: abc.ABC

Base class for all hyrax verbs

__init__()[source]#

Overall initialization for all verbs that saves the config

add_parser_kwargs: dict[str, str][source]#
REQUIRED_DATA_GROUPS: tuple[str, ...] = ()[source]#
OPTIONAL_DATA_GROUPS: tuple[str, ...] = ()[source]#
cli_name = 'VERB'[source]#
description = ''[source]#
config[source]#
classmethod __init_subclass__(**kwargs)[source]#

Give every verb a run context for the duration of its run().

Wrapping here rather than in each verb means a verb cannot forget to establish a context, and cannot leave one behind when it finishes or raises. Verbs still record their own results directory, with hyrax.context.update_context(), once they have created it.

Only run is wrapped. Every verb’s run_cli delegates to run, so wrapping both would establish two contexts per CLI invocation.

classmethod information()[source]#

Returns a string describing this verb. Includes the following: - Name of the verb - Required Data Groups - Optional Data Groups - One line description of what this verb does

If a data group is empty then it will be printed as an empty tuple.

Returns:

<name>: Data Groups: Req. (<req1>, <req2>, …), Opt. (<opt1>, <opt2>, …). <Description>

Return type:

str

validate_data_request() → None[source]#

Validate the data_request configuration for this verb’s known groups.

Reads data_request from the verb’s config and verifies that every group listed in REQUIRED_DATA_GROUPS is present. Verbs that define neither REQUIRED_DATA_GROUPS nor OPTIONAL_DATA_GROUPS skip validation entirely.

Raises:

RuntimeError – If a required group is absent from the data_request config.

VERB_REGISTRY: dict[str, type[Verb] | None][source]#
hyrax_verb(cls: type[Verb]) → type[Verb][source]#

Decorator to register a hyrax verb

all_verbs() → list[str][source]#

Returns all verbs that are currently registered

all_class_verbs() → list[str][source]#

Returns all verbs that are currently registered with a class-based implementation

is_verb_class(cli_name: str) → bool[source]#

Returns true if the verb has a class based implementation

Parameters:

cli_name (str) – The name of the verb on the command line interface

Returns:

True if the verb has a class-based implementation

Return type:

bool

fetch_verb_class(cli_name: str) → type[Verb] | None[source]#

Gives the class object for the named verb

Parameters:

cli_name (str) – The name of the verb on the command line interface

Returns:

The verb class or None if no such verb class exists.

Return type:

Optional[type[Verb]]