Skip to content

fs-sanity-check

Run the sanity checks in one call (tdfs4ds.sanity_check), write the HTML or Markdown report, read the verdict and decide what to fix first. No language model; nothing is changed.


name: "Feature Store: Sanity check" description: "Generate code to run the tdfs4ds sanity checks in one call and write the HTML or Markdown report (tdfs4ds.sanity_check), read the verdict, say whether run() and roll_out() can still refresh each process, and decide what to fix first. Code only, no language model, changes nothing. Invoke when the user asks for a sanity check or health check, whether a pipeline or store is healthy, whether a process can still be refreshed, or what to check before a migration. SKIP for what one finding means in detail or for the thresholds of the checks (use fs-workflow-assessment), for catalog/storage consistency and orphans (use fs-inspect) and for the performance of one process (use fs-analyze)." argument-hint: "[report path][data-domain] [processes]" allowed-tools: "Read, Edit, Write, Bash, Glob, Grep"


Generate Python code that runs the tdfs4ds sanity checks and writes the report, then help the user read it.

User context: $ARGUMENTS

Step Skill Why
Before fs-setup Connect first if no Teradata context is open.
Before fs-lineage-graph The order and input checks read the persisted lineage graph.
Details fs-workflow-assessment Every finding with its meaning and fix; findings as data; thresholds.
Fix fs-upload Stay inside the framework: what replaces a loop or a custom step around a process.
Fix fs-rollout Re-run in the right order, rebuild a history.
After fs-migrate A migration report opens with these checks on the source store.

Ask for any missing values before generating code: - Report format: HTML to read or share, Markdown for a wiki. - Scope: cheap unless the user asks about entity keys or empty dataset columns. - Data domains or processes, or the whole store.

Run

import tdfs4ds
tdfs4ds.connect(database='<DATABASE>')

path = tdfs4ds.sanity_check('<REPORT>.html')        # a .md path writes Markdown; returns the path
Argument Meaning
out_path The report file. Default: tdfs4ds.DASHBOARD_REPORT_DIR.
fmt 'html' or 'md', overrides the extension. 'csv' writes the findings alone.
processes Process ids or view names. Default: every process.
data_domains Restrict to these data domains.
scope 'cheap' (default): the checks a migration report runs, closed entities included. 'full' adds the entity and dataset scans, which read the storage tables.
display Print the summary and the findings. Default True.

The checks use no language model and change nothing. A finding names its fix and never runs it. An exported report names the checks it left out.

The order and input checks need the persisted lineage graph. When it is empty they are reported as not verified, never as passing:

tdfs4ds.rebuild_lineage_graph(all_data_domains=True)

Read the report

  1. Executive summary: the overall verdict, the main issues, and one row per process in execution order, with a cell per dimension: ok, the worst severity found, or n/a when the check did not run.
  2. Not verified: what could not be checked, and why. It is not a pass.
  3. Checks not run: under scope='cheap', the entity and dataset scans.

Fix in this order, because later findings can be symptoms of earlier ones:

  1. Lineage errors: a view or a process that no longer has what it reads.
  2. Refresh: not refreshable, then at risk.
  3. Run order and point-in-time inputs: values computed on the wrong inputs.
  4. Segments and SQL changed without a run: re-run the process.
  5. Entity keys, skew and distribution: these change storage, so plan them.

Can run() and roll_out() refresh this process?

run() and roll_out() refresh a process from what is registered: its view, managers and options. What was done around them is not replayed, and no error is raised.

usage = tdfs4ds.process_usage_for('<PROCESS_ID>', closed=True)   # closed=True also reads the storage tables

usage['verdict']        # 'refreshable', 'at risk', 'not refreshable' or 'not checked'
usage['reasons']
usage['findings']       # kind, label, severity, detail, fix
usage['unverifiable']
Verdict Meaning
refreshable No refresh finding, or information only. When storage_checked is false, the verdict comes from the run history only.
at risk At least one warning: a refresh may not reproduce the data.
not refreshable At least one error: a refresh only repeats the last state.
not checked The check did not run.
Finding What happened What to do
external_time_loop One execution wrote several business dates with no TimeManager. A TimeManager and one roll_out.
external_segment_loop One execution completed one date several times with no FilterManager. upload_features(..., filtermanager=fm), then run.
view_rewritten_between_runs The view was rewritten with a new literal for each run. Read the value from a manager.
recursive_query Recursion in the SQL chain. A date or sequence generator is a warning; walking a hierarchy is information. A TimeManager, or valid_time_column when the source holds the history.
closed_without_flag Entities have only closed periods while close_absent_entities is off. close_absent_entities=True if entities really leave; otherwise find what closes them.
validity_gap_without_flag A gap in an entity's history. A run leaves none, so a step outside it ended a period. Remove that step, then rebuild the history with roll_out(..., force_compute=True) from the first date.
writes_outside_run The query log shows writes to a FS_T_* table without the package's query band. Information only: removals and relocations write the same way. Check who wrote.

Never propose a loop or a custom step around run / roll_out, or a write to FS_T_*. See Stay inside the framework in fs-upload.

Limits: a loop whose runs fall in separate executions looks like a schedule. A loop calling roll_out one step at a time looks like a roll_out: only what its step did to storage shows, so ask for closed=True, or scope='cheap' or 'full', which include that read.

Will one roll_out cover the data domain?

Check order also asks, per data domain checked, whether roll_out(data_domain=...) moves every TimeManager its processes read (the rule roll_out applies, shared with tdfs4ds.write_time_manager_report()):

Finding Severity What to do
rollout_refused error A process reads a manager on other dates than the clock: the domain's roll-out stops before its first date. align_domain_time_managers(domain, calendars=True, dry_run=True).
rollout_no_single_calendar warning No clock, processes on several tables of dates. set_domain_time_manager(...), then align.
manager_shared_across_domains warning One manager read by processes of several data domains: rolling one out moves it for all. Give each domain its own soft clones (align), or roll them out together.
domains_share_calendar info Two clocks on one table of dates: in step only when every domain is rolled out to the same date.

Only the managers read by the processes checked are considered (leftovers no process reads are not reported).

Is the domain clock up to date? (0.3.7.31)

The cheap check clock compares each domain clock with its calendar rule (the stored one, else inferred from the dates):

Finding Severity What to do
clock_behind warning Business dates are due by now (rule and due delay) and not in the clock's table, or a process is behind the clock. tdfs4ds.domain_clock_status('<DATA_DOMAIN>') lists them; tdfs4ds.refresh_domain('<DATA_DOMAIN>', until='now') adds and rolls them out (a large backlog needs catch_up=, see fs-rollout).
calendar_gap info Dates a catch_up='latest' refresh skipped on purpose (setting CALENDAR_GAPS). Nothing to fix unless they must be computed: roll them out from the first gap.

The clock check also inspects the calendar of every TimeManager, and the cheap check windows the SQL of the processes:

Finding Severity What to do
calendar_rule_inferable info No rule is stored but the dates follow one. tm.set_calendar(<the rule in the finding>) enables extend, refresh_domain(until='now'), enable_previous and change_calendar.
calendar_irregular info No rule stored, none can be inferred. Attach one with tm.set_calendar(tdfs4ds.Calendar....) or keep add_time_steps.
calendar_off_rule_dates warning Dates that do not fit the stored rule: a half-finished change_calendar (call it again with the same calendar), or dates added by hand.
hand_written_window info A window written by hand from the TimeManager value (ADD_MONTHS, INTERVAL). It does not follow a change of frequency: read <clock>_PREVIOUS (clock.enable_previous(), see fs-rollout).
window_mismatch_calendar warning The hand-written window spans a different step than the calendar: windows overlap or leave gaps. Same fix.
fixed_window_bound info A literal lower bound: the window grows with the clock. Keep it if a cumulative read is meant, else the previous view.

Before changing the frequency of a clock, run tdfs4ds.sanity_check('windows.html') # the cheap scope includes the windows check.

After a replay

After rebuilding a history (roll_out(data_domain=..., time_id_start=1, force_compute=True) or roll_out([...], ...)), run the cheap checks on the processes just replayed:

tdfs4ds.sanity_check('<REPORT>.html', processes=['<PROCESS_ID>', '<PROCESS_VIEW>'], scope='cheap')

Look at, in this order:

Look at Check or finding Good result
One COMPLETED follow-up row per process and date tdfs4ds.completed_dates(pids); the segments check no missing date, no FAILED segment
Empty dates COMPLETED,0 rows in completed_dates (column EMPTY) none, or each one explained
Dates in order order check (date_order_findings) no process computed before its upstream, none ahead of it
No validity gap validity_gap_without_flag in usage; it reads storage, so use scope='full' or process_usage_for(pid, closed=True) none: a run leaves no gap
Absent entities closed_entities, when close_absent_entities=True no entity closed without the flag; the closed ones are the expected ones
The domain roll-out rollout_refused, manager_shared_across_domains absent

Fix the first finding of each process before the next replay: a replay rewrites every date from the first one.

Before a migration

plan_migration(seeds, source, sanity='cheap') runs the same checks on the source store and shows them first in the report. They never block migrate_objects: a process that is not refreshable carries its problem to production, so fix it in the source first.

In the app

Operations → Workflow assessment runs the checks and downloads the report. The process card in Feature catalog shows the refresh verdict. The (?) button shows the matching script.

Full guide

Documentation: Design & operate → Assess workflow health.