Skip to main content
Version: devel

dlt.common.configuration.specs.pluggable_run_context

RunContextBase Objects

class RunContextBase(ABC)

View source on GitHub

Describes where dlt looks for settings, pipeline working folder. Implementations must be picklable.

__init__

@abstractmethod
def __init__(run_dir: Optional[str], *args: Any, **kwargs: Any)

View source on GitHub

An explicit run_dir, if None, run_dir should be auto-detected by particular implementation

name

@property
@abstractmethod
def name() -> str

View source on GitHub

Name of the run context. Entities like sources and destinations added to registries when this context is active, will be scoped to it. Typically corresponds to Python package name ie. dlt.

uri

@property
@abstractmethod
def uri() -> str

View source on GitHub

Uniquely identifies the context. By default it is a combination of run_dir and runtime_kwargs to create file:// uri

global_dir

@property
@abstractmethod
def global_dir() -> str

View source on GitHub

Directory in which global settings are stored ie ~/.dlt/

run_dir

@property
@abstractmethod
def run_dir() -> str

View source on GitHub

Defines the context working directory, defaults to cwd()

local_dir

@property
@abstractmethod
def local_dir() -> str

View source on GitHub

Defines data dir where local relative dirs and files are created, defaults to run_dir

settings_dir

@property
@abstractmethod
def settings_dir() -> str

View source on GitHub

Defines where the current settings (secrets and configs) are located

data_dir

@property
@abstractmethod
def data_dir() -> str

View source on GitHub

Defines where the pipelines working folders are stored.

module

@property
@abstractmethod
def module() -> Optional[ModuleType]

View source on GitHub

if run_dir is a top level importable python module, returns it, otherwise return None

runtime_kwargs

@property
@abstractmethod
def runtime_kwargs() -> Dict[str, Any]

View source on GitHub

Additional kwargs used to initialize this instance of run context, used for reloading

initial_providers

@abstractmethod
def initial_providers() -> List[ConfigProvider]

View source on GitHub

Returns initial providers for this context

initialize_runtime

@abstractmethod
def initialize_runtime(runtime_config: RuntimeConfiguration = None) -> None

View source on GitHub

Initializes runtime (ie. log, telemetry) using RuntimeConfiguration

runtime_config

@property
@abstractmethod
def runtime_config() -> RuntimeConfiguration

View source on GitHub

Runtime configuration used for initialize_runtime

config

@property
@abstractmethod
def config() -> BaseConfiguration

View source on GitHub

Returns (optionally resolves) run context configuration

get_data_entity

@abstractmethod
def get_data_entity(entity: str) -> str

View source on GitHub

Gets path in data_dir where entity (ie. pipelines, repos) are stored

get_run_entity

@abstractmethod
def get_run_entity(entity: str) -> str

View source on GitHub

Gets path in run_dir where entity (ie. sources, destinations etc.) are stored

get_setting

@abstractmethod
def get_setting(setting_path: str) -> str

View source on GitHub

Gets path in settings_dir where setting (ie. secrets.toml) are stored

unplug

@abstractmethod
def unplug() -> None

View source on GitHub

Called when context removed from container

plug

@abstractmethod
def plug() -> None

View source on GitHub

Called when context is added to container

reload

def reload() -> "RunContextBase"

View source on GitHub

This will reload current context by triggering run context plugin via Container

import_run_dir_module

@staticmethod
def import_run_dir_module(run_dir: str) -> ModuleType

View source on GitHub

Returns a top Python module of the workspace (if importable)

ProfilesRunContext Objects

class ProfilesRunContext(RunContextBase)

View source on GitHub

Adds profile support on run context. Note: runtime checkable protocols are slow on isinstance

profile

@property
@abstractmethod
def profile() -> str

View source on GitHub

Returns current profile name

default_profile

@property
@abstractmethod
def default_profile() -> str

View source on GitHub

Returns default profile name

available_profiles

@abstractmethod
def available_profiles() -> List[str]

View source on GitHub

Returns available profiles

switch_profile

@abstractmethod
def switch_profile(new_profile: str) -> Self

View source on GitHub

Switches current profile and returns new run context

PluggableRunContext Objects

class PluggableRunContext(ContainerInjectableContext)

View source on GitHub

Injectable run context taken via plugin

reload

def reload(run_dir_or_context: Optional[Union[str, RunContextBase]] = None,
runtime_kwargs: Dict[str, Any] = None) -> None

View source on GitHub

Reloads the context, using existing settings if not overwritten with method args

initialize_runtime

def initialize_runtime() -> None

View source on GitHub

Calls initialize_runtime on context only if active in container. We do not want to initialize runtime if instance is not active

push_context

def push_context() -> str

View source on GitHub

Pushes current context on stack and returns assert cookie

pop_context

def pop_context(cookie: str) -> None

View source on GitHub

Pops context from stack and re-initializes it if in container

drop_context

def drop_context(cookie: str) -> None

View source on GitHub

Pops context form stack but leaves new context for good

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.