metron_shared.config.config module#

This module defines variable <config> which stores configuration of given Metron’s component obtained by Hydra framework.

<config> has to be initialized by using provided function decorator <set_hydra_config>, which has to be used right after Hydra’s <hydra.main> decorator. See the sample code:

` @hydra.main(config_path="...", config_name="...") @set_hydra_config def main(cfg: DictConfig) -> None: `

<config> is obtained by using provided function / class method decorated <GetHydraConfig>, which passes Hydra’s config as the first argument. See the sample code:

``` @GetHydraConfig def do_something(hydra_config: DictConfig):

```

class metron_shared.config.config.GetHydraConfig(decorated_func: Any)#

Bases: object

Decorator used to get global <config> variable storing Hydra’s config. The decorated might be applied on a function or a class method. It passes into decorated function / method the config as the first argument.

_decorated_func#

Function / method on which the decorator is applied.

Type:

Any

__call__(*args: Any, **kwargs: Any) Any#

Passes Hydra’s config, stored in <config> global variable, as a first argument of the function / method. The method is called when decorator is applied on class method or function.

Parameters:
  • *args (Any) – Positional arguments.

  • **kwargs (Any) – Key-worded arguments.

Returns (typing.Any): Calls decorated function which takes Hydra’s config as the

first input argument.

__get__(instance: Any, owner: Any) Any#

The method is needed to work with class method.

Parameters:
  • instance (Any) – Class instance.

  • owner (Any) – Instance class owner.

Returns (typing.Any):

__init__(decorated_func: Any)#

Saves decorated function / method as attribute, for later lookup.

Parameters:

decorated_func (Any) – Decorated function / method.