common.configuration.inject
set_fun_spec
def set_fun_spec(f: AnyFun, spec: Type[BaseConfiguration]) -> None
Assigns a spec to a callable from which it was inferred
with_config
def with_config(
func: Optional[AnyFun] = None,
spec: Type[BaseConfiguration] = None,
sections: Union[str, Tuple[str, ...]] = (),
section_arg_name: str = None,
sections_merge_style: ConfigSectionContext.
TMergeFunc = ConfigSectionContext.prefer_incoming,
include_defaults: bool = True,
accept_partial: bool = False,
initial_config: Optional[BaseConfiguration] = None,
base: Type[BaseConfiguration] = BaseConfiguration,
lock_context_on_injection: bool = True) -> Callable[[TFun], TFun]
Injects values into decorated function arguments following the specification in spec
or by deriving one from function's signature.
The synthesized spec contains the arguments marked with dlt.secrets.value
and dlt.config.value
which are required to be injected at runtime.
Optionally (and by default) arguments with default values are included in spec as well.
Arguments:
func
Optional[AnyFun], optional - A function with arguments to be injected. Defaults to None.spec
Type[BaseConfiguration], optional - A specification of injectable arguments. Defaults to None.sections
Tuple[str, ...], optional - A set of config sections in which to look for arguments values. Defaults to ().section_arg_name
bool, optional - Name of the argument in the signature of the decorated function which will be used to extendsections
tuple. A top level pipeline section will be added if argument name ispipeline_name
prefer_existing_sections
- (bool, optional): When joining existing section context, the existing context will be preferred to the one insections
. Default: Falseinclude_defaults
bool, optional - If True then arguments with default values will be included in synthesized spec. If False only the required arguments marked withdlt.secrets.value
anddlt.config.value
are includedbase
Type[BaseConfiguration], optional - A base class for synthesized spec. Defaults to BaseConfiguration.lock_context_on_injection
bool, optional - If True, the thread context will be locked during injection to prevent race conditions. Defaults to True.
Returns:
Callable[[TFun], TFun]: A decorated function
last_config
def last_config(**injection_kwargs: Any) -> Any
Get configuration instance used to inject function kwargs
get_orig_args
def get_orig_args(**injection_kwargs: Any) -> Tuple[Tuple[Any], DictStrAny]
Get original argument with which the injectable function was called
create_resolved_partial
def create_resolved_partial(f: AnyFun,
config: Optional[BaseConfiguration] = None
) -> AnyFun
Create a pre-resolved partial of the with_config decorated function