Skip to content

fs-modernize-verify

Prove that a cleaned-up workflow computes what the original computed: a static API check (tdfs4ds.check_api_usage), pattern tests on synthetic data, a run on stub sources and a comparison with the original results.


name: "Feature Store: Verify a clean-up" description: "Prove that a cleaned-up tdfs4ds workflow keeps its business logic and uses only the real tdfs4ds API: a static check of every call and keyword against the installed version (tdfs4ds.check_api_usage), a pattern test on synthetic data in its own data domain, an end-to-end run on stub sources when the real data is out of reach, and a row-by-row comparison with the original results at a reference date. Invoke at the end of fs-modernize, or before presenting a clean-up. SKIP for the health of a running store (use fs-sanity-check)." argument-hint: " [reference date]" allowed-tools: "Read, Edit, Write, Bash, Glob, Grep"


Generate the checks that prove a cleaned-up workflow computes what the original computed, with the cheapest evidence first.

User context: $ARGUMENTS

Step Skill Why
Before fs-modernize The audit table says what each change may affect.
After fs-sanity-check Can run() and roll_out() refresh every process?
Details fs-workflow-assessment What each finding means.
Cleanup fs-inspect Removal plans for the test objects.

Four levels, in order of cost. Stop at the first that fails and fix before going on.

1. API check (static, no database)

check_api_usage reads .py files and notebook code cells and checks every tdfs4ds call (tdfs4ds.x(...), tdfs4ds.a.b(...), aliases, from tdfs4ds.x import y) against the installed tdfs4ds: the name must exist, and each keyword must be a parameter (functions taking **kwargs are not checked). Nothing is executed.

import tdfs4ds

rows = tdfs4ds.check_api_usage("notebooks_clean")
print(len(rows), "problem(s)")
for r in rows:
    print(f"{r['file']} cell {r['cell']} line {r['line']}: {r['name']} {r['problem']}")

Also search the cleaned code for what the API check cannot see: - SQL strings that write to an FS_* table (INSERT, UPDATE, DELETE, MERGE): there must be none; - a cleaned notebook importing a project module that itself imports tdfs4ds; - defaults that silently do nothing: remove_dataset(...) and cleanup_temp_tables() are dry runs by default, plan_removal(...) only plans.

Watch the defaults that do nothing: remove_dataset(...) and cleanup_temp_tables() are dry runs unless dry_run=False, and plan_removal returns a plan, not a removal.

2. Pattern test (live, synthetic data)

Each pattern the clean-up relies on gets a small test on synthetic rows, in its own data domain, with its own TimeManager, FilterManager and object prefix, so it can never touch the project's store. Clean up through a removal plan, never by hand.

Pattern Data that proves it Assertion
Point-in-time window two dates, a row changing between them each date's value equals the window computed by hand
close_absent_entities=True an entity present at date 1, absent at date 2 no value valid at date 2 for it
A process reading another's dataset two processes, the second on the first's dataset its value at date 2 uses the first's value at date 2
The same view registered twice change one select item, register again same PROCESS_ID, a new process version
Composite entity two key columns, one value differing on each one value per pair
Segmentation entity buckets vs one unsegmented run equal values; one COMPLETED row per segment and date
roll_out over the clock three dates one COMPLETED row per process and date, in dependency order
A second data domain on the same clock scores per date, one entity not scored at a later date its value ended at that date
History equals snapshots the same features read both ways at noon of each date the history equals build_dataset(as_of=...), one row per entity
Leads and lags a feature that changes at every date the lead equals the next date's value, the lag the previous one
Clock alignment every process at every date follow_up_report: no process misses a business date
Removal the plan's script with --apply nothing left (the script ends with verify_removal)

A test skeleton (pytest, skipped without a connection):

import pytest
import tdfs4ds

DOMAIN = "TEST_MODERNIZE"

@pytest.fixture(scope="module")
def store():
    try:
        tdfs4ds.open_session(database="MY_TEST_STORE")
    except Exception as exc:
        pytest.skip(f"no connection: {exc}")
    tdfs4ds.create_data_domain(DOMAIN)
    yield
    plan = tdfs4ds.plan_removal(tdfs4ds.domain_processes(DOMAIN), purge_values=True, drop_views=True)
    tdfs4ds.write_removal_script(plan, out_path="cleanup_test_modernize.py")   # run it with --apply

def test_roll_out_over_the_clock(store):
    tdfs4ds.roll_out(data_domain=DOMAIN, time_id_start=1, force_compute=True, on_failure="raise")
    report = tdfs4ds.follow_up_report(process_id=tdfs4ds.domain_processes(DOMAIN)[0]).to_pandas()
    assert (report["STATUS"] == "COMPLETED").sum() >= 3

Run it with PYTHONUNBUFFERED=1 and log to a file: a long live test is easier to follow from its log.

3. End-to-end on stub sources

When the real sources are out of reach (another environment, no rights):

  1. copy the cleaned notebooks to a scratch folder;
  2. remap the source names in one configuration cell to stub tables;
  3. load one or two rows per stub, on two business dates;
  4. relax only the checks that need real volumes (empty-data guards), and list each one you relax;
  5. run the notebooks headless (jupyter nbconvert --execute), then tdfs4ds.sanity_check();
  6. with the store registered, take the lineage and documentation figures: tdfs4ds.rebuild_lineage_graph(), then tdfs4ds.write_documentation_coverage(path).

Never run a notebook that drops or cleans objects, and never on a shared store.

Notes from such runs: - Give each stub table one row when the notebooks probe types or emptiness (SELECT TOP 1 TYPE(col) on an empty table returns no row). Build stubs by iterating: create the view, read the error (3810 unknown column, a type mismatch), add the column. - A trial system gives correctness, not timings; ingestion dominates the run time, so keep the dates and entities to what the check needs. - A refused logon (8017): check the credentials the run actually reads before retrying; an account can lock. - After the test, check what plan_removal left. Since 0.3.7.18, with drop_views=True it also drops a TimeManager only the removed processes read (plan['kept_time_managers'] says why one was kept); FilterManager views and tables, and the test's source tables, are still yours to drop. - One heavy run at a time on a shared test database: runs write to the same catalog tables and disturb each other's timings.

4. Comparison with the original

On two separate stores (original and cleaned), at the same reference date: build the same dataset in both, then compare row by row on the entity key.

import teradataml as tdml

orig = tdml.DataFrame(tdml.in_schema("ORIGINAL_STORE", "ds_reference")).to_pandas(all_rows=True)
new = tdml.DataFrame(tdml.in_schema("CLEAN_STORE", "ds_reference")).to_pandas(all_rows=True)
keys = ["CUSTOMER_ID"]
merged = orig.merge(new, on=keys, how="outer", suffixes=("_orig", "_new"), indicator=True)
print(merged["_merge"].value_counts())          # entities present on one side only

Compare floats with a tolerance; explain every difference (a restated source row, a logic change the owner accepted, a bug). An EXCEPT or a merge is only as complete as the data that exercises the change: say which dates and segments were compared.

5. Code quoted in documents

For a README, a deck or a report about the clean-up: extract every line that looks like code (for a .pptx, the text of each shape), normalise the whitespace, and check that each one appears in a notebook, a module or a test. Fix the lines that don't, or mark them as shortened (...). Paraphrased code that looks real is the most common error in such documents.

6. What to report

  • What ran and passed, with the tdfs4ds and Vantage versions.
  • What was not verified, and why (no data, no rights, out of scope).
  • Every difference found, with its explanation and the owner's decision when it is a logic change.