common.configuration.inject
with_config
def with_config(
func: Optional[AnyFun] = None,
spec: Type[BaseConfiguration] = None,
sections: Tuple[str, ...] = (),
sections_merge_style: ConfigSectionContext.
TMergeFunc = ConfigSectionContext.prefer_incoming,
auto_pipeline_section: bool = False,
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 ().prefer_existing_sections
- (bool, optional): When joining existing section context, the existing context will be preferred to the one insections
. Default: Falseauto_pipeline_section
bool, optional - If True, a top level pipeline section will be added ifpipeline_name
argument is present . Defaults to False.include_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(**kwargs: Any) -> Any
Get configuration instance used to inject function arguments
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