Skip to main content
Version: devel

dlt.common.runtime.run_context

RunContext Objects

class RunContext(RunContextBase)

View source on GitHub

A default run context used by dlt

run_dir

@property
def run_dir() -> str

View source on GitHub

The default run dir is the current working directory but may be overridden by DLT_PROJECT_DIR env variable.

settings_dir

@property
def settings_dir() -> str

View source on GitHub

Returns a path to dlt settings directory. If not overridden it resides in current working directory

The name of the setting folder is '.dlt'. The path is current working directory '.' but may be overridden by DLT_PROJECT_DIR env variable.

get_run_entity

def get_run_entity(entity: str) -> str

View source on GitHub

Default run context assumes that entities are defined in root dir

switch_context

def switch_context(run_dir: Optional[str],
profile: str = None,
required: str = None,
validate: bool = False) -> RunContextBase

View source on GitHub

Switch the run context to a project at run_dir with an optional profile.

Calls reload on PluggableRunContext to re-trigger the plugin hook (plug_run_context spec), which will query all active context plugins.

The required argument is passed to each context plugin via the _required key of runtime_kwargs and should cause an exception if a given plugin cannot instantiate its context at run_dir.

The validate argument is passed to each context plugin via the _validate key of runtime_kwargs and should cause a strict validation of any config files and manifests associated with the run context.

Arguments:

  • run_dir str - Filesystem path of the project directory to activate. If None, plugins may resolve the directory themselves.
  • profile str - Profile name to activate for the run context.
  • required str, optional - A class name of the context be instantiated at run_dir ie. setting it to WorkspaceRunContext will cause the workspace context plugin to raise if workspace is not found at run_dir.
  • validate str, optional - If True, plugins should perform strict validation of config files and manifests associated with the run context.

Returns:

  • SupportsProfilesRunContext - The new run context.

switched_run_context

@contextmanager
def switched_run_context(new_context: RunContext) -> Iterator[RunContext]

View source on GitHub

Context manager that switches run context to new_context into pluggable run context.

global_dir

def global_dir() -> str

View source on GitHub

Gets default directory where pipelines' data (working directories) will be stored

  1. if XDG_DATA_HOME is set in env then it is used
  2. in user home directory: ~/.dlt/
  3. if current user is root: in /var/dlt/
  4. if current user does not have a home directory: in /tmp/dlt/

get_plugin_modules

def get_plugin_modules() -> List[str]

View source on GitHub

Return top level module names of all discovered plugins, including dlt.

If current run context is a top level module it is also included, otherwise empty string.

active

def active() -> RunContextBase

View source on GitHub

Returns currently active run context

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.