Skip to content

tdfs4ds.deploy.fidelity

tdfs4ds.deploy.fidelity

Workflow fidelity of a deployment (0.3.8.15): is the workflow deployed on a target the SAME as the source's, in everything a deployment is meant to carry?

Two layers, the same split as the rest of tdfs4ds.deploy:

  • :func:workflow_snapshot (I/O, read-only): every row of the store's catalog tables, the text of every view and table of the databases in scope, the storage statistics, and on request the feature values and the managers' contents. Raw values, nothing normalised.
  • :func:normalise_snapshot / :func:compare_snapshots (pure): database names become the variables of the environment ({{FS_DB}}...), process ids become their process view, dataset ids their dataset, feature ids their (data domain, entity, feature) triplet, per-feature value views their feature; columns that are state of an installation (valid times, authors, hashes of SQL naming a database, run times) are dropped. Then each item is compared row set to row set.

Each item of :data:ITEMS says whether a deployment is meant to reproduce it (compared) or not (by_design: "definitions are deployed, state is not"), so a difference on a by-design item is reported apart from a difference that is a defect.

ITEMS module-attribute

ITEMS: Dict[str, Tuple[str, str, str]] = {'process_catalog': ('Process catalog rows (view, entity, features, type, metadata, process version)', 'compared', ''), 'data_distribution': ('Primary index / partitioning (FS_DATA_DISTRIBUTION)', 'compared', ''), 'filter_manager_link': ('Process -> FilterManager (FS_FILTER_MANAGER)', 'compared', ''), 'time_manager_link': ('Process -> TimeManager (FS_TIME_MANAGER)', 'compared', ''), 'process_options': ('Process options (FS_PROCESS_OPTIONS: close_absent_entities)', 'compared', ''), 'process_settings': ('Process settings (FS_PROCESS_SETTINGS)', 'compared', ''), 'process_sql': ('Stored SQL versions (FS_PROCESS_SQL, text and version number)', 'compared', ''), 'feature_catalog': ('Feature catalog (name, type, table, entity, domain)', 'compared', ''), 'feature_placement': ('Storage tags (FS_FEATURE_PLACEMENT)', 'compared', ''), 'domain_settings': ('Data-domain clock and settings (FS_DATA_DOMAIN_SETTINGS)', 'compared', ''), 'manager_settings': ('Manager settings: calendar rule, previous view (FS_MANAGER_SETTINGS)', 'compared', ''), 'manager_registry': ('Manager registry (FS_MANAGER_REGISTRY)', 'compared', ''), 'dataset_catalog': ('Dataset catalog rows', 'compared', ''), 'dataset_entity': ('Dataset entity split (_ENTITY)', 'compared', ''), 'dataset_features': ('Dataset feature split (_FEATURES)', 'compared', ''), 'dataset_build': ('Dataset build (_BUILD: strategy, join, time mode, TimeManager)', 'compared', ''), 'dataset_window': ('Historical dataset window (_WINDOW)', 'compared', ''), 'dataset_offsets': ('Dataset lags / leads (_OFFSETS)', 'compared', ''), 'dataset_columns': ('Dataset columns (_COLUMNS: order, aliases, versions)', 'compared', ''), 'bd_objects': ('Business dictionary: objects', 'compared', ''), 'bd_sections': ('Business dictionary: sections (incl. reserved ATTACHED / EXPOSES / DEEP_LAYOUT)', 'compared', ''), 'bd_columns': ('Business dictionary: columns', 'compared', ''), 'process_doc_logic': ('Process documentation: business logic / entity description', 'compared', ''), 'process_doc_features': ('Process documentation: feature descriptions', 'compared', ''), 'doc_provenance': ('Documentation provenance (source of each part)', 'compared', ''), 'glossary': ('Glossary terms', 'compared', ''), 'feature_properties': ('Feature properties', 'compared', ''), 'feature_allowed_values': ('Feature properties: allowed values', 'compared', ''), 'lineage': ('Lineage edges (FS_LINEAGE_GRAPH)', 'compared', ''), 'views': ('View text of every non-catalog view (process, upstream, downstream, attached, datasets, managers, clones)', 'compared', ''), 'tables': ('Table DDL of every non-catalog table (storage tables, manager tables, copied sources)', 'compared', ''), 'statistics': ('Storage statistics definitions (DBC.StatsV column sets) of FS_T_* and other tables', 'compared', ''), 'manager_statistics': ("Statistics of the managers' tables", 'after_compute', 'collected when the manager is loaded (load_filter / calendar), not by the deployment'), 'manager_contents': ('Manager contents: TimeManager dates, FilterManager rows', 'after_compute', "bundled only with with_manager_contents=True; else generated by compute (calendar rule) or the environment's"), 'feature_values': ('Feature values with their valid periods (FS_T_*)', 'after_compute', 'computed by compute_deployment'), 'dataset_rows': ('Rows returned by each dataset view', 'after_compute', ''), 'follow_up': ('Run history (FS_FOLLOW_UP)', 'by_design', 'state: each environment runs its own'), 'execution_resources': ('Execution resources, call phases', 'by_design', 'state'), 'documentation_log': ('Documentation log', 'by_design', 'state'), 'removal_log': ('Removal log', 'by_design', 'state'), 'explain_doc': ('EXPLAIN analysis of processes (FS_PROCESS_DOCUMENTATION_EXPLAIN)', 'by_design', "regenerated by the environment's own documentation run (plan of its own data)"), 'finding_acceptance': ('Accepted sanity findings (FS_FINDING_ACCEPTANCE)', 'by_design', "decisions on one environment's findings"), 'entity_refresh': ('Entity refresh rows (FS_R_*)', 'by_design', 'state'), 'vector_index': ('Vector index', 'by_design', 'rebuilt on each environment')}

CATALOG_TABLES module-attribute

CATALOG_TABLES: Dict[str, str] = {'process_catalog': 'FS_PROCESS_CATALOG', 'data_distribution': 'FS_DATA_DISTRIBUTION', 'filter_manager_link': 'FS_FILTER_MANAGER', 'time_manager_link': 'FS_TIME_MANAGER', 'process_options': 'FS_PROCESS_OPTIONS', 'process_settings': 'FS_PROCESS_SETTINGS', 'process_sql': 'FS_PROCESS_SQL', 'feature_catalog': 'FS_FEATURE_CATALOG', 'feature_placement': 'FS_FEATURE_PLACEMENT', 'domain_settings': 'FS_DATA_DOMAIN_SETTINGS', 'manager_settings': 'FS_MANAGER_SETTINGS', 'manager_registry': 'FS_MANAGER_REGISTRY', 'dataset_catalog': 'FS_FS_DATASET_CATALOG', 'dataset_entity': 'FS_FS_DATASET_ENTITY', 'dataset_features': 'FS_FS_DATASET_FEATURES', 'dataset_build': 'FS_FS_DATASET_BUILD', 'dataset_window': 'FS_FS_DATASET_WINDOW', 'dataset_offsets': 'FS_FS_DATASET_OFFSETS', 'dataset_columns': 'FS_FS_DATASET_COLUMNS', 'bd_objects': 'FS_BUSINESS_DICTIONARY_OBJECTS', 'bd_sections': 'FS_BUSINESS_DICTIONARY_SECTIONS', 'bd_columns': 'FS_BUSINESS_DICTIONARY_COLUMNS', 'process_doc_logic': 'FS_PROCESS_DOCUMENTATION_BUSINESS_LOGIC', 'process_doc_features': 'FS_PROCESS_DOCUMENTATION_FEATURES', 'doc_provenance': 'FS_DOCUMENTATION_PROVENANCE', 'glossary': 'FS_GLOSSARY', 'feature_properties': 'FS_FEATURE_PROPERTIES', 'feature_allowed_values': 'FS_FEATURE_ALLOWED_VALUES', 'lineage': 'FS_LINEAGE_GRAPH', 'follow_up': 'FS_FOLLOW_UP', 'explain_doc': 'FS_PROCESS_DOCUMENTATION_EXPLAIN', 'finding_acceptance': 'FS_FINDING_ACCEPTANCE'}

DROP_COLUMNS module-attribute

DROP_COLUMNS = {'VALIDSTART', 'VALIDEND', 'VALIDPERIOD', 'DB_USER', 'EDITOR_NAME', 'AUTHOR', 'CREATED_BY', 'ACCEPTED_BY', 'ACCEPTED_AT', 'EVENT_ID', 'STEP_HASH', 'CHAIN_HASH', 'HARVESTED_AT', 'RUN_ID', 'START_DATETIME', 'END_DATETIME'}

_UUID module-attribute

_UUID = '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}'

_FV_VIEW module-attribute

_FV_VIEW = re.compile('\\bFS_V_[0-9a-fA-F]{8}_[0-9a-fA-F]{4}_[0-9a-fA-F]{4}_[0-9a-fA-F]{4}_[0-9a-fA-F]{12}\\b')

_FEATURE_ID_IN_TEXT module-attribute

_FEATURE_ID_IN_TEXT = re.compile('(FEATURE_ID\\s*(?:=|IN\\s*\\()\\s*)([0-9][0-9 ,]*)', re.I)

Normaliser

Rewrites store-local identities into comparable ones. db_vars: {DB: VAR}.

db_vars instance-attribute

db_vars = {_u(k): v for k, v in db_vars.items() if k}

pid_view instance-attribute

pid_view = {str(k).strip(): v for k, v in pid_view.items()}

dataset_name instance-attribute

dataset_name = {str(k).strip(): v for k, v in dataset_name.items()}

feature_triplet instance-attribute

feature_triplet = {str(k).strip(): v for k, v in feature_triplet.items()}

feature_view instance-attribute

feature_view = {_u(k): v for k, v in feature_view.items()}

domain_map instance-attribute

domain_map = {_u(k): v for k, v in (domain_map or {}).items()}

__init__

__init__(db_vars: Dict[str, str], pid_view: Dict[str, str], dataset_name: Dict[str, str], feature_triplet: Dict[str, str], feature_view: Dict[str, str], domain_map: Optional[Dict[str, str]] = None)

text

text(s) -> str

value

value(column: str, v)

_u

_u(x) -> str

_default_run

_default_run(sql: str)

workflow_snapshot

workflow_snapshot(schema: str, databases: Iterable[str], *, view_schema: Optional[str] = None, with_values: bool = True, with_dataset_rows: bool = True, run: Optional[Callable[[str], Tuple[List[str], List[list]]]] = None) -> Dict[str, Any]

Raw snapshot of a store and of the databases holding its workflow (read-only).

schema / view_schema: the store's databases; databases: every database whose views and tables are part of the workflow (the store's, the managers', the source databases). run(sql) returns (column names, rows) (default: the teradataml context). Fail-open: an unreadable part is recorded under errors and its item is None.

is_catalog_object

is_catalog_object(name: str) -> bool

A framework catalog object (created by setup), not part of a workflow definition: the catalog tables and views, FS_V_* public views. FS_T_* storage tables and FS_V_<uuid> per-feature views ARE compared (physical characteristics).

build_normaliser

build_normaliser(snap: Dict[str, Any], db_vars: Dict[str, str], domain_map: Optional[Dict[str, str]] = None) -> Normaliser

The :class:Normaliser of a raw snapshot (its own process / dataset / feature ids).

_norm_sql

_norm_sql(text: str, nz: Normaliser, cursor_neutral: bool = True) -> str

normalise_rows

normalise_rows(table: Optional[Dict[str, Any]], nz: Normaliser, drop: Iterable[str] = (), keep: Iterable[str] = ()) -> Optional[List[str]]

Sorted JSON lines of a table's rows, normalised, dropped columns removed (keep overrides :data:DROP_COLUMNS, e.g. the valid period of feature values). Pure.

_neutral_marker

_neutral_marker(line: str) -> str

An ATTACHED marker row without what each attach computes for itself (the time it was written and the hashes of the view text, which names the store's database): kind, data domain and sources stay.

normalise_snapshot

normalise_snapshot(snap: Dict[str, Any], db_vars: Dict[str, str], domain_map: Optional[Dict[str, str]] = None) -> Dict[str, Any]

{item: sorted list of normalised entries | None} of a raw snapshot. Pure.

compare_snapshots

compare_snapshots(source: Dict[str, Any], target: Dict[str, Any]) -> List[Dict[str, Any]]

One row per item of :data:ITEMS: {item, label, status, equal, n_source, n_target, only_source, only_target} (the only_* lists hold at most 10 entries). source / target are :func:normalise_snapshot results. Pure.

render_comparison

render_comparison(rows: List[Dict[str, Any]]) -> str

A plain-text table of :func:compare_snapshots (ASCII). Pure.