Skip to main content
Version: devel

common.configuration.inject

set_fun_spec

def set_fun_spec(f: AnyFun, spec: Type[BaseConfiguration]) -> None

[view_source]

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, ...]] = (),
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]

[view_source]

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 in sections. Default: False
  • auto_pipeline_section bool, optional - If True, a top level pipeline section will be added if pipeline_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 with dlt.secrets.value and dlt.config.value are included
  • base 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

[view_source]

Get configuration instance used to inject function kwargs

get_orig_args

def get_orig_args(**injection_kwargs: Any) -> Tuple[Tuple[Any], DictStrAny]

[view_source]

Get original argument with which the injectable function was called

create_resolved_partial

def create_resolved_partial(f: AnyFun,
config: Optional[BaseConfiguration] = None
) -> AnyFun

[view_source]

Create a pre-resolved partial of the with_config decorated function

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.