dlt.common.runtime.run_context
RunContext Objects
class RunContext(RunContextBase)
A default run context used by dlt
run_dir
@property
def run_dir() -> str
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
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
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
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_dirstr - Filesystem path of the project directory to activate. If None, plugins may resolve the directory themselves.profilestr - Profile name to activate for the run context.requiredstr, optional - A class name of the context be instantiated atrun_dirie. setting it toWorkspaceRunContextwill cause the workspace context plugin to raise if workspace is not found atrun_dir.validatestr, 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]
Context manager that switches run context to new_context into pluggable run context.
global_dir
def global_dir() -> str
Gets default directory where pipelines' data (working directories) will be stored
- if XDG_DATA_HOME is set in env then it is used
- in user home directory: ~/.dlt/
- if current user is root: in /var/dlt/
- if current user does not have a home directory: in /tmp/dlt/
get_plugin_modules
def get_plugin_modules() -> List[str]
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
Returns currently active run context