Skip to content

Shared Modules

hera.shared

GlobalConfig module-attribute

GlobalConfig = _GlobalConfig()

global_config module-attribute

global_config = _GlobalConfig()

register_pre_build_hook module-attribute

register_pre_build_hook = global_config.register_pre_build_hook

BaseMixin

Source code in src/hera/shared/_global_config.py
class BaseMixin(BaseModel):
    # Note this is pydantic private method that
    # is called after __init__
    # In order to inject __hera_init__ after __init__
    # without destroying the autocomplete, we have opted
    # for this method. We also tried other ways
    # including creating a metaclass that invokes hera_init
    # after init, but that always broke auto-complete for vscode
    def _init_private_attributes(self):
        super()._init_private_attributes()
        self.__hera_init__()

    def __hera_init__(self):
        ...

    @root_validator(pre=True)
    def _set_defaults(cls, values):
        defaults = global_config._get_class_defaults(cls)
        for key, value in defaults.items():
            if values.get(key) is None:
                values[key] = value
        return values

Comments