Skip to content

tdfs4ds.deploy.actions

tdfs4ds.deploy.actions

What apply_deployment does for each kind of object (0.3.8.15): the only writers of a deployment.

Each apply_<kind>(defn, values, ctx, replace) creates (or, when the plan says replace, replaces) one object on the target from its definition, resolved to the environment. A database error raises: apply_deployment stops there and reports it whole. The contents of an existing manager (dates, segments) are never touched.

_PROVENANCE_SOURCES module-attribute

_PROVENANCE_SOURCES = ('MANUAL', 'IMPORTED', 'PROPAGATED', 'GENERATED')

APPLIERS module-attribute

APPLIERS = {'requires': apply_requires, 'table': apply_table, 'view': apply_view, 'time_manager': apply_time_manager, 'filter_manager': apply_filter_manager, 'process': apply_process, 'domain': apply_domain, 'dataset': apply_dataset, 'glossary': apply_glossary, 'documentation': apply_documentation}

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.

resolve_sql

resolve_sql(text: str, values: Dict[str, str]) -> str

{{VAR}} -> the database as an identifier (quoted only when needed), for SQL text.

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.

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.

_execute

_execute(sql: str)

_q

_q(name) -> str

_qual

_qual(db, obj) -> str

_u

_u(x) -> str

_lit

_lit(value) -> str

_resolved_view

_resolved_view(qname: str, values) -> str

'{{VAR}}.OBJ' -> 'DB.OBJ' (raw, as catalog columns and tdfs4ds arguments take it).

apply_requires

apply_requires(defn, values, ctx, replace=False)

apply_table

apply_table(defn, values, ctx, replace=False)

apply_view

apply_view(defn, values, ctx, replace=False)

_literal

_literal(value, type_text: str) -> str

_table_present

_table_present(db, table) -> bool

The table exists now (DBC). An earlier table action of the same plan creates a manager's hidden table before the manager itself is applied (CREATE TABLE twice = Error 3803, live 0.3.8.15). Fail-open to False: an unreadable answer keeps the old behaviour.

manager_names

manager_names(defn, values)

load_manager_contents

load_manager_contents(defn, values) -> int

Insert the bundled dates / rows into the (empty) table of a manager. Returns the rows inserted.

manager_statistics_sql

manager_statistics_sql(defn, tdb, table) -> str

The statistics a manager's own loader collects on its table (0.3.8.15): TIME_ID for a TimeManager (collect_time_statistics), the filter id and the filter columns for a FilterManager (load_filter). Pure.

_collect_manager_statistics

_collect_manager_statistics(defn, tdb, table) -> None

Fail-open: a refusal (no STATISTICS right) is a debug line, never a failure of the deployment.

_register

_register(defn, values, kind)

apply_time_manager

apply_time_manager(defn, values, ctx, replace=False)

Create a TimeManager's table of dates and view, EMPTY (or with the bundled dates), and record its calendar rule. Never called on an existing manager with rows (the plan refuses to replace one).

previous_literal

previous_literal(defn) -> Optional[str]

The SQL literal of the first step's previous date of a TimeManager definition: the exported value (info.previous_first), else the calendar rule's date before info.first_date; None when neither is in the bundle. Pure.

create_previous_view

create_previous_view(defn, values) -> bool

Create <view>_PREVIOUS of a deployed TimeManager and record its PREVIOUS setting (0.3.8.15): a process reading the previous-date view is registered right after the manager, before any date exists (the EXPLAIN of its view needs the object). False (with a warning) when the first previous date is unknown: compute_deployment then creates it once the dates exist.

apply_filter_manager

apply_filter_manager(defn, values, ctx, replace=False)

_flag

_flag(settings, name) -> Optional[bool]

upload_kwargs

upload_kwargs(defn, values, ctx, replace=False) -> Dict[str, Any]

The upload_features keyword arguments that register defn on the target (no run). Pure apart from building the manager objects (ctx['manager_factory']).

default_manager_factory

default_manager_factory(kind, db, view)

apply_process

apply_process(defn, values, ctx, replace=False)

Register the process on the target WITHOUT running it (run_now=False), under its target data domain, with PROCESS_DOMAIN_CHECK='error' for the call.

apply_domain

apply_domain(defn, values, ctx, replace=False)

apply_feature_properties

apply_feature_properties(defn, values, ctx, replace=False)

dataset_selection

dataset_selection(defn, values, pid_of) -> Dict[str, Any]

selected_features for build_dataset: each producing process VIEW resolved to the target's PROCESS_ID by pid_of ('DB.VIEW' -> pid). Raises naming a process the target does not have.

apply_dataset

apply_dataset(defn, values, ctx, replace=False)

_glossary_source

_glossary_source(term) -> str

The provenance a glossary term is written with: the source's (MANUAL / IMPORTED), else IMPORTED.

apply_glossary

apply_glossary(defn, values, ctx, replace=False)

part_source

part_source(defn, key) -> Optional[str]

The provenance a documentation part is written with on the target (0.3.8.15): the source's own (provenance of the definition: MANUAL / IMPORTED / PROPAGATED / GENERATED), so a part a person wrote stays protected and a PROPAGATED part keeps following its source; None (no provenance row, as in the source) for a part the source has no provenance for. A definition carrying no provenance at all (written by hand, or before 0.3.8.15) keeps the historical IMPORTED. Pure.

_by_source

_by_source(defn, field, part)

[(source, [(name, text), ...])] of a definition's sections / columns grouped by provenance. Pure.

apply_documentation

apply_documentation(defn, values, ctx, replace=False)