Skip to content

tdfs4ds.deploy

tdfs4ds.deploy

tdfs4ds.deploy - declarative deployment of feature-store DEFINITIONS across environments (0.3.8.15).

Definitions are deployed, state is not. :func:export_definitions writes the definitions of a part of a store (processes, datasets, views, manager structure, domain clocks and settings, documentation, glossary, feature properties, physical characteristics) as deterministic YAML files to version in git, with databases as variables and processes named by their view. On each environment, :func:plan_deployment compares them with the target (read-only) and decides per object under a conflict policy, :func:apply_deployment carries the plan out without running anything, and :func:compute_deployment (optional) initialises the empty managers and computes. The bundle's deploy.py runs the three steps from a CI job.

PyYAML is imported only by these functions: import tdfs4ds does not load it.

__all__ module-attribute

__all__ = ['export_definitions', 'plan_deployment', 'load_plan', 'DeploymentPlan', 'apply_deployment', 'DeploymentResult', 'compute_deployment', 'write_deployment_bundle', 'DeploymentError', 'TargetChangedError', 'UnresolvedConflictsError']

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

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

DeploymentError

Bases: RuntimeError

A deployment cannot proceed.

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.

export_definitions

export_definitions(path, *, seeds=None, data_domains=None, include_downstream: bool = False, outside_objects: str = 'keep', with_manager_contents: bool = False, source=None, variables: Optional[Dict[str, str]] = None, plan: Optional[Dict] = None, report: bool = True, target_environment: bool = False) -> Dict[str, Any]

Write the definitions of a part of a feature store under path (read-only on the store).

Parameters

path : str Folder of the bundle (created). Existing files of the bundle are rewritten, except conflict_policy.yaml, which holds the reviewer's decisions and is kept when present (delete it to get the default policy back); nothing else in the folder is touched. seeds : list[str] | None Processes (id or view), datasets or features to export, with everything upstream of them (plan_migration's closure). None with data_domains=None = the whole store. data_domains : list[str] | None Export these data domains whole. include_downstream : bool Also export the views (and attached views) that read the exported processes and datasets. outside_objects : 'keep' | 'move' Objects of databases outside the store: 'keep' (default) lists them in requires (checked on the target, never created); 'move' exports their definition to be created. with_manager_contents : bool Also bundle the dates of the TimeManagers and the rows of the FilterManagers. Loaded by a deployment only into a manager that is absent or empty. Use it to back up a data domain. source : str | dict | None The store to export: None = the active store; else another store readable on the same system (attached read-only for the export). variables : dict | None Rename variables: {default name or source database: new name}, e.g. {'FS_DB': 'STORE_DB'}. plan : dict | None A plan_migration result to export instead of planning here. report : bool Write report.html (the migration report of the export plan). target_environment : bool Also write environments/target.yaml holding the plan's target databases and data domains (the mapping typed in the app's Migration panel, or plan's database_map / target_data_domain). Nothing is written when the plan names no target database.

Returns

dict {path, files: [relative paths], objects: n, by_kind: {kind: n}, variables, errors}.

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

load_plan

load_plan(path) -> DeploymentPlan

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

compute_deployment

compute_deployment(plan_or_result, environment, *, changed: bool = False, initialise: bool = True, until=None) -> Dict[str, Any]

Initialise the empty managers the bundle can fill, then compute the deployed processes.

Per data domain of the bundle: a domain with a clock is rolled out from its first date (roll_out(data_domain=..., time_id_start=1, force_compute='changed' if changed else False, on_failure='raise', check_upstream=True)); a domain without one runs its processes (run([...], ...)). Processes whose manager is still empty are skipped and listed.

Parameters

plan_or_result : DeploymentPlan | str The applied plan (or its saved path). A :class:DeploymentResult is accepted when it carries plan_path. environment : str | dict changed : bool Only what changed (force_compute='changed'). initialise : bool Fill the empty managers first (bundled contents or calendar rule). until : None | 'bundle' | date Last date a calendar rule generates: None (default) = now; 'bundle' = the source's last date when it was exported (the same dates as the source); a date.

Returns

dict {ok, initialised: [...], computed: [...], skipped: [...], errors: [...], summary}.

write_deployment_bundle

write_deployment_bundle(path, plan_migration_plan=None, **export_kwargs) -> str

Export into a temporary folder and zip it to path (a .zip file, or a folder: then <folder>/tdfs4ds_deployment_bundle.zip). plan_migration_plan: a plan_migration result to export (else one is planned from export_kwargs). Returns the zip path. Entries are sorted and carry a fixed date, so the same export gives the same archive content.

Submodules