Skip to content

tdfs4ds.deploy.apply

tdfs4ds.deploy.apply

apply_deployment: carry out a deployment plan on the target store (0.3.8.15). No interaction.

  1. The target is read again. An object whose definition on the target is neither the one the plan saw nor the one the bundle deploys means someone changed the target since the plan: refused (TargetChangedError, deploy.py exit code 2). An object already holding the bundle's definition is skipped, so running apply again after a failure resumes where it stopped and a second apply of a deployed plan does nothing.
  2. Actions run in the plan's order (tables, upstream views, managers, processes, domain clocks and settings, datasets, downstream views, glossary, documentation). The first failure stops the run: the action, the whole database error and the actions not done are reported.
  3. Lineage of what was written, storage statistics of the registered processes, optionally the vector index. Then apply.json, apply.md, managers_to_initialise.json and run_order.json are written.

Processes are registered, never run (run_now=False): computing is compute_deployment or the environment's own orchestrator.

TargetChangedError

Bases: DeploymentError

The target changed since the plan was made: plan again (deploy.py apply exits with 2).

changed: the keys of the objects whose definition on the target is neither the one the plan saw nor the one the bundle deploys.

changed instance-attribute

changed = list(changed)

__init__

__init__(message, changed=())

UnresolvedConflictsError

Bases: DeploymentError

The plan holds a fail decision: resolve it in conflict_policy.yaml and plan again.

DeploymentResult

Bases: dict

The outcome of an apply: status (ok | failed | nothing_to_do | dry_run), done / already / skipped / not_done lists, failed (the failing action and its whole error), process_ids (target view -> PROCESS_ID), managers_to_initialise, run_order, post (lineage, statistics, index), files.

ok property

ok: bool

summary

summary() -> str

logger_safe

logger_safe(level, message, *args, **kwargs)

Wrapper around the global logger that only emits logs when tdfs4ds.DISPLAY_LOGS is True. level is a string like "info", "error", etc.

load_definitions

load_definitions(path) -> Tuple[List[Dict[str, Any]], Dict[str, str], Dict[str, Any]]

(definitions in deployment order, {key: relative file}, manifest) of a bundle.

load_environment

load_environment(environment, environ=None) -> Dict[str, Any]

An environment as a dict: a path to a YAML file or a dict. ${NAME} is expanded from the process environment (environ). Keys: name, connection, variables, domain_map, options.

dump_json

dump_json(obj: Any) -> str

Deterministic JSON (sorted keys, 2-space indent, LF, trailing newline).

write_text

write_text(path, text: str) -> str

Write text UTF-8 with LF line ends; parents created. Returns the path.

_current

_current(plan, values, defs_by_key) -> Dict[str, Dict[str, Any]]

target_changes

target_changes(plan_actions: List[Dict[str, Any]], current: Dict[str, Dict[str, Any]], defs_by_key: Dict[str, Dict[str, Any]]) -> List[str]

Keys whose target is neither what the plan saw nor the bundle's definition. Pure.

_domain_written_without_properties

_domain_written_without_properties(defn, target) -> bool

True when the target holds the domain's clock and settings as the bundle has them, its feature properties not (yet) written: what an apply stopped after the domain step leaves. Pure.

_pid_lookup

_pid_lookup(ctx)

'DB.VIEW' -> target PROCESS_ID, from what this apply registered, else the target catalog.

_post_steps

_post_steps(ctx, env, dry_run) -> Dict[str, Any]

run_order

run_order(plan, defs_by_key, ctx, current) -> Dict[str, Any]

Waves of the processes this apply registered (or replaced) and the calls that compute them.

managers_to_initialise

managers_to_initialise(plan, defs_by_key, done_keys, current) -> List[Dict[str, Any]]

apply_deployment

apply_deployment(plan, environment, *, dry_run: bool = False, out_dir=None) -> DeploymentResult

Carry out plan (a :class:DeploymentPlan or a saved plan path) on the active target store.

Parameters

plan : DeploymentPlan | str environment : str | dict The same environment file the plan was made with. dry_run : bool List what would be done, write nothing (the target is still read and compared). out_dir : str | None Where apply.json, apply.md, managers_to_initialise.json and run_order.json go (default: the bundle's plans folder).

Raises

UnresolvedConflictsError The plan holds a fail decision. TargetChangedError The target changed since the plan (plan again).