Skip to content

tdfs4ds.migration

tdfs4ds.migration

tdfs4ds.migration — cross-store MIGRATION / promotion (lab → production) (v0.3.1.150).

Where :mod:tdfs4ds.read_federation attaches other feature stores read-only, this package imports selected work from a distant (lab) store into the principal (production) store — bringing along the temporal lineage graph, the business dictionary, the Teradata vector index, the non-FS upstream objects the process views depend on, the feature-value data (recompute or copy), and the filter/time managers.

Two governed phases:

  • :func:plan_migration — READ-ONLY: resolve seeds in the source store, expand the upstream process closure (the migration unit), inventory + classify every object, detect name conflicts against the primary, run the replace downstream-safety gate, and return a manifest that requires approval.
  • :func:migrate_objects — the only writer: executes an approved manifest.

:func:render_migration_report renders the manifest as an approval report; :func:generate_migration_script / :func:write_migration_script emit a standalone execution script with a baked-in approval map.

__all__ module-attribute

__all__ = ['dataset_access', 'process_run_access', 'write_access_script', 'check_access', 'plan_migration', 'migrate_objects', 'render_migration_report', 'render_migration_diagram', 'write_migration_report', 'suggest_database_map', 'target_domain_for', 'classify_kind', 'generate_migration_script', 'write_migration_script']

plan_migration

plan_migration(seeds=None, source=None, *, all_domains: bool = True, target_data_domain: Optional[str] = None, data_strategy: str = 'recompute', attach: bool = True, database_map: Optional[Dict[str, Any]] = None, run_user: Optional[str] = None, dataset_readers=None, sanity='cheap', outside_objects: str = 'move', data_domains=None, include_downstream: bool = False) -> Dict[str, Any]

migrate_objects

migrate_objects(plan: Dict[str, Any], approvals: Optional[Dict[str, str]] = None, *, dry_run: bool = False, rebuild_vector_index: bool = True, progress: Optional[Callable[[str], None]] = None) -> Dict[str, Any]

Execute an approved migration manifest against the primary store.

Parameters

plan : dict The manifest from :func:tdfs4ds.plan_migration. approvals : dict[str, str] | None {conflict_key: 'skip'|'replace'} for every conflict. Required whenever the plan has conflicts; a replace that is still blocking (the downstream-safety gate) is rejected. dry_run : bool Validate approvals and return the plan of record without writing. rebuild_vector_index : bool Rebuild the Teradata vector index after BD migration (default True; skipped unless VECTOR_STORE_BACKEND == 'teradata'). progress : callable(str) | None Per-step progress hook (for the SSE panel).

Returns

dict Execution report: pid_map (source→primary), per-object outcomes, skipped/replaced, and any post-migration downstream compile breakages.

render_migration_report

render_migration_report(plan: Dict[str, Any], fmt: str = 'markdown') -> str

Render the migration manifest as an approval-ready report.

Parameters

plan : dict A manifest from :func:tdfs4ds.plan_migration. fmt : 'markdown' | 'html' Output format (default markdown).

render_migration_diagram

render_migration_diagram(plan: Dict[str, Any]) -> str

An inline SVG + scoped CSS fragment (no script) of the plan: the source store on the left, the target on the right, one lane per kind (tables, views, managers, processes, datasets, downstream views) with its count, the target box split by action, and under it one <details> panel per lane listing every object source -> target with its action.

write_migration_report

write_migration_report(plan: Dict[str, Any], out_path: Optional[str] = None, fmt: str = 'html') -> str

Write the approval report as a standalone page (fmt='html': doctype, charset, title "Migration plan", light theme, the diagram first) or Markdown (fmt='markdown') and return its path (default: tdfs4ds.SCHEDULING_SCRIPT_DIR or the working directory).

suggest_database_map

suggest_database_map(plan, primary_schema: Optional[str] = None, primary_view_schema: Optional[str] = None)

Where each source database of plan should go: a list of rows {kind, source_database, target_database, inside_store, reason, n_objects[, data_choice]}, one per (kind, source database), sorted.

Pure when the primary names are given; by default they come from plan['target'] (then tdfs4ds.SCHEMA / view_schema()). A source table goes to the primary table database and a view to the primary view database when its database is one of the source store's; any other database stays where it is (read in place). A table already found at its target with every source column is data_choice='reuse'; a database_map entry of the plan wins. Objects that are not verified are left out (they are not migrated). The rows are ready to edit into a database_map argument of plan_migration.

target_domain_for

target_domain_for(source_domain: Optional[str], mapping) -> Optional[str]

The target data domain of source_domain under target_data_domain mapping. Pure.

None (or '') keeps the source domain; a string sends every domain there; a dict {source_domain: target_domain} is looked up case-insensitively, '*' standing for any other domain, and a domain it does not name keeps its own name.

classify_kind

classify_kind(graph_type: Optional[str], table_kind: Optional[str], is_process: bool = False, is_dataset: bool = False) -> Tuple[str, str]

(object_type, kind_source) of an inventoried object. Pure.

graph_type is what the dependency graph (SHOW VIEW / SHOW TABLE) said: 'view', 'table', 'dataset' or 'unknown' (both SHOW statements failed). table_kind is the DBC.TablesV TableKind, or None when the dictionary was not read or does not list the object. The dictionary wins over the graph; a process view / dataset keeps its kind (the catalogs say so) and only the source of the evidence changes. kind_source is 'dbc', 'show' or 'unverified'; an object neither could type is ('unverified', 'unverified'): it is never recreated, rewritten nor reported as a conflict.

generate_migration_script

generate_migration_script(plan: Dict[str, Any], approvals: Optional[Dict[str, str]] = None, *, data_strategy: Optional[str] = None) -> str

Return a standalone .py (string) that re-plans and executes this migration with the given approvals baked in. Inspect before executing. The text is ASCII only, and the script calls tdfs4ds.require(<this version>) first.

write_migration_script

write_migration_script(plan: Dict[str, Any], out_path: Optional[str] = None, approvals: Optional[Dict[str, str]] = None, **kw) -> str

Write the generated migration script under tdfs4ds.SCHEDULING_SCRIPT_DIR (or out_path); return its path.

dataset_access

dataset_access(dataset: str, readers=None) -> Dict[str, Any]

The GRANTs a user needs to read dataset ('db.name' or a name in the view database), for any dataset, migrated or not: SELECT for the readers, and what the dataset's database must hold to resolve the view (the store's tables, its TimeManager view). Text only; statuses from what the session can read.

process_run_access

process_run_access(process_ids=None, user: Optional[str] = None) -> Dict[str, Any]

The GRANTs a user needs to run processes of the current store (process_ids None = all): the tables and catalog views, the process views, the manager views, and the rights the process views' databases need on what they read (from the persisted lineage). Text only; statuses from what the session can read.

write_access_script

write_access_script(plan: Dict[str, Any], out_path: Optional[str] = None, groups: Optional[Iterable[str]] = None) -> str

Write :func:access_script to out_path (default tdfs4ds_grants_<ts>.sql under tdfs4ds.SCHEDULING_SCRIPT_DIR or the working directory); return the path.

check_access

check_access(plan: Optional[Dict[str, Any]] = None, datasets: Optional[Iterable[str]] = None) -> Dict[str, Any]

Run as the target user, after the GRANTs were applied: EXPLAIN on each view (the plan's process, intermediate and dataset views at their target, or the current store's process views plus datasets). Refusals carry the GRANT that lifts them (:func:tdfs4ds.utils.query_management.grant_hint). Read-only, never raises: {ok, user, checked, refused, broken, unanswered}.

Submodules