dlt.common.configuration.plugins
TCliCommandCompose
How a CLI command merges with other plugins' commands of the same (parent, command).
manager
def manager() -> pluggy.PluginManager
Returns current plugin context
load_setuptools_entrypoints
def load_setuptools_entrypoints(m: pluggy.PluginManager) -> List[str]
Loads entry points in group dlt and instantiates them to initialize plugins.
Returns a list of names of top level modules/packages from detected entry points.
plug_run_context
@hookspec(firstresult=True)
def plug_run_context(
run_dir: Optional[str],
runtime_kwargs: Optional[Dict[str, Any]]) -> Optional[RunContextBase]
Spec for plugin hook that returns current run context.
Arguments:
run_dirstr - An initial run directory of the contextruntime_kwargs- Any additional arguments passed to the context via PluggableRunContext.reload
Returns:
SupportsRunContext- A run context implementing SupportsRunContext protocol
SupportsCliCommand Objects
class SupportsCliCommand(Protocol)
Protocol for defining one dlt cli command.
command
name of the command
help_string
the help string for argparse
description
the more detailed description for argparse, may include markdown for the docs
docs_url
the default docs url to be printed in case of an exception
parent
When set, this command is registered as a subcommand under the top-level parent command
compose
How this command merges when multiple plugins register the same (parent, command).
replace(default): first registered wins; rest dropped.extend: first plugin'sconfigure_parserruns; ALL plugins'executefire in order.additive: additional subparsers may be added to top level command
profile_options
Profile options that the dlthub CLI host reads from the command. With None, the command
takes --profile.
configure_parser
def configure_parser(parser: argparse.ArgumentParser) -> None
Configures the parser for the given argument.
execute
def execute(args: argparse.Namespace) -> None
Executes the command with the given arguments
only_host
def only_host(
hosts: Union[str, Iterable[str]]
) -> Callable[[_TCommandDefFunc], _TCommandDefFunc]
Emits cli command only if one if hosts was requested via plugin hook.
plug_cli
@hookspec()
def plug_cli(host: str) -> Optional[Type[SupportsCliCommand]]
Spec for plugin hook that returns a CLI command class for a given CLI host.
Arguments:
host- Name of the CLI host requesting commands (e.g."dlt","dlthub"). Plugins return their command class only if they contribute to this host;
Returns:
Optional[Type[SupportsCliCommand]]- Command class to register, orNonewhen the plugin does not contribute to the requested host.
SupportsAgentLoop Objects
class SupportsAgentLoop(Protocol)
Protocol for an agent loop implementation returned by the plug_agent_loop hook
LOOP_TYPE
loop type string this class answers to
init
def init(agent_spec: Any) -> None
Prepares the loop from the agent declaration
run
async def run(instructions: Optional[str] = None,
inputs: Optional[Dict[str, Any]] = None,
model: Optional[str] = None,
limits: Optional[Any] = None,
run_args: Optional[Dict[str, Any]] = None) -> Dict[str, Any]
Builds the native agent from the runtime arguments and runs it to completion
native
@property
def native() -> Any
The underlying framework object, e.g. a Pydantic AI Agent
trace
@property
def trace() -> Any
Trace of the completed run
plug_agent_loop
@hookspec()
def plug_agent_loop(loop_type: str) -> Optional[Type[SupportsAgentLoop]]
Spec for plugin hook that returns an agent loop class for a given loop type.
Arguments:
loop_type- Loop type requested by the launcher, e.g."pydantic-ai".
Returns:
Optional[Type[SupportsAgentLoop]]- Loop class to instantiate, orNonewhen the plugin does not implement the requested loop.
plug_config_providers
@hookspec()
def plug_config_providers() -> Optional[Sequence["ConfigProvider"]]
Spec for plugin hook that contributes config providers to the run context.
A run context calls it when it adds its extra providers, in every process that uses dlt. Providers that need settings must resolve them from the initial providers: environment variables and toml files.
Returns:
Optional[Sequence[ConfigProvider]]- Providers to add, orNoneto add none.