Skip to content

tdfs4ds.deploy.plan

tdfs4ds.deploy.plan

plan_deployment: compare a bundle of definitions with the TARGET store (the active session) and decide, object by object, what a deployment does (0.3.8.15). Read-only on the target.

Situations: create (absent), identical (same fingerprint), different (another definition under the name), unavailable (a required outside object is missing), to_initialise (a manager that exists but is empty). The conflict policy turns each into a decision: create, skip, replace or fail. A plan holding a fail cannot be applied.

FS_DB module-attribute

FS_DB = 'FS_DB'

FS_VIEW_DB module-attribute

FS_VIEW_DB = 'FS_VIEW_DB'

PLAN_FORMAT module-attribute

PLAN_FORMAT = 1

SITUATIONS module-attribute

SITUATIONS = ('create', 'identical', 'different', 'unavailable', 'to_initialise')

DeploymentError

Bases: RuntimeError

A deployment cannot proceed.

DeploymentPlan

What a deployment of a bundle to one environment does. Deterministic JSON (save).

data instance-attribute

data = data

actions property

actions: List[Dict[str, Any]]

counts property

counts: Dict[str, Dict[str, int]]

has_unresolved_conflicts property

has_unresolved_conflicts: bool

environment property

environment: str

definitions_path property

definitions_path: str

target_state_fingerprint property

target_state_fingerprint: str

__init__

__init__(data: Dict[str, Any])

to_json

to_json() -> str

save

save(path) -> str

summary

summary() -> str

report

report(path=None, fmt: str = 'md') -> str

The plan as Markdown (fmt='md') or a standalone HTML page; written when path is given. Returns the text.

__repr__

__repr__() -> 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.

bundle_root

bundle_root(path) -> Tuple[Path, Path]

(root, definitions folder) of a bundle given its root or its definitions folder.

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.

load_policy

load_policy(policy=None, root: Optional[Path] = None) -> Dict[str, Any]

The conflict policy: policy (dict or path), else <root>/conflict_policy.yaml, else the defaults.

documentation_covered

documentation_covered(definition: Dict[str, Any], target: Optional[Dict[str, Any]]) -> bool

True when every part of definition is in target with the same text (extra target parts are allowed: a deployment never deletes documentation). Pure.

fingerprint

fingerprint(defn: Optional[Dict[str, Any]]) -> Optional[str]

The fingerprint of a definition (None for None). Pure.

sha

sha(obj: Any) -> str

documentation_parts

documentation_parts(d: Dict[str, Any]) -> Dict[str, str]

{part key: normalised text} of a documentation definition.

resolve_value

resolve_value(text, values: Dict[str, str])

{{VAR}} -> the raw value (a database name as it is, for a YAML field or a catalog value). A non-string passes through; an unknown variable raises KeyError naming it.

reverse_refs

reverse_refs(values: Dict[str, str], prefer: Iterable[str] = (FS_VIEW_DB, FS_DB)) -> Dict[str, str]

{DB (normalised): VAR} for a database-level rewrite of target text; when two variables share a value, the first of prefer wins, then the alphabetical order.

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.

split_qualified

split_qualified(name: Optional[str]) -> Tuple[str, str]

Split 'db.obj' / '"db"."obj"' / 'obj' into (db, obj) (raw, de-quoted but original case preserved). db is '' when unqualified.

_u

_u(x) -> str

map_domain

map_domain(domain, domain_map: Dict[str, str])

for_environment

for_environment(defn: Dict[str, Any], domain_map: Dict[str, str]) -> Dict[str, Any]

defn with its data domains renamed by the environment's domain_map. Pure.

resolved_name

resolved_name(defn: Dict[str, Any], values: Dict[str, str]) -> Tuple[str, str]

(database, object) of a definition in the environment (raw database name).

target_namer

target_namer(defs: List[Dict[str, Any]], values: Dict[str, str]) -> M.Namer

collect_target

collect_target(defs: List[Dict[str, Any]], values: Dict[str, str]) -> Dict[str, Dict[str, Any]]

{key: {"defn": target definition or None, "state": ..., ...}} for every definition (already mapped to the environment). Read-only.

_restricted

_restricted(defn: Dict[str, Any], target: Dict[str, Any]) -> Dict[str, Any]

target limited to what defn declares (a deployment adds, it never deletes settings, terms, properties or documentation parts the target holds besides). Pure.

classify

classify(defn: Dict[str, Any], target: Dict[str, Any]) -> Tuple[str, Optional[str], str]

(situation, target fingerprint, reason) of one definition against what the target holds. Pure.

_domain_missing_properties_only

_domain_missing_properties_only(defn: Dict[str, Any], tdef: Dict[str, Any]) -> bool

True when the target holds the domain's clock and settings as the bundle has them and only some of its feature properties are missing (none differs): what an apply stopped before the properties leaves. Pure.

decide

decide(situation: str, kind: str, key: str, name: str, policy: Dict[str, Any]) -> str

The decision of the policy for one object. Pure.

load_plan

load_plan(path) -> DeploymentPlan

target_state_fingerprint

target_state_fingerprint(actions: List[Dict[str, Any]]) -> str

build_plan

build_plan(defs: List[Dict[str, Any]], files: Dict[str, str], target: Dict[str, Dict[str, Any]], env: Dict[str, Any], policy: Dict[str, Any], *, definitions_path: str = '', manifest: Optional[Dict[str, Any]] = None) -> DeploymentPlan

The plan from definitions (mapped to the environment) and what the target holds. Pure.

cross_database_grants

cross_database_grants(defs: List[Dict[str, Any]], values: Dict[str, str], schema: Optional[str], view_schema: Optional[str]) -> List[Dict[str, Any]]

The SELECT ... WITH GRANT OPTION each target view database needs on what its views read in another database (Teradata resolves a view with the rights of the database holding it: Error 3523 / 5315 at apply otherwise). Same rule and text as the migration's Databases group (migration.access). Pure; statements only, never executed.

An object the bundle requires (it exists on the target) is granted by name; an object the deployment creates is granted on its database (an object right on a missing object is refused).

check_grants

check_grants(grants: List[Dict[str, Any]]) -> Dict[str, Any]

Fill each grant's status (granted / missing / unknown) from what the session can read in DBC (migration.access.read_rights). Read-only, never raises: unreadable = unknown.

plan_deployment

plan_deployment(definitions_path, environment, *, policy=None) -> DeploymentPlan

Compare a bundle with the target store (the active session) and plan the deployment. Read-only.

Parameters

definitions_path : str The bundle folder (or its definitions folder). environment : str | dict The environment file (environments/<env>.yaml) or its content. policy : dict | str | None Conflict policy; None = the bundle's conflict_policy.yaml, else the defaults (create -> create, identical -> skip, different -> fail, unavailable -> fail).

Returns

DeploymentPlan .actions, .counts, .has_unresolved_conflicts, .save(path), .report(path, fmt).

_placeholders

_placeholders(defn) -> set