dlt.common.configuration.inject
set_fun_spec
def set_fun_spec(f: AnyFun, spec: Type[BaseConfiguration]) -> None
Assigns a spec to a unwrapped f from which it was inferred
set_fun_last_config
def set_fun_last_config(f: AnyFun, config: BaseConfiguration) -> None
Assigns a resolved config to a unwrapped f when it is called
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:
funcOptional[AnyFun], optional - A function with arguments to be injected. Defaults to None.specType[BaseConfiguration], optional - A specification of injectable arguments. Defaults to None.sectionsTuple[str, ...], optional - A set of config sections in which to look for arguments values. Defaults to ().section_arg_namebool, optional - Name of the argument in the signature of the decorated function which will be used to extendsectionstuple. A top level pipeline section will be added if argument name ispipeline_nameprefer_existing_sections- (bool, optional): When joining existing section context, the existing context will be preferred to the one insections. Default: Falseinclude_defaultsbool, optional - If True then arguments with default values will be included in synthesized spec. If False only the required arguments marked withdlt.secrets.valueanddlt.config.valueare includedbaseType[BaseConfiguration], optional - A base class for synthesized spec. Defaults to BaseConfiguration.lock_context_on_injectionbool, 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