Skip to content

Operate in production

Once a workflow runs on a schedule, four things matter: how the runs are started, what happens when one fails, how you see what ran and what it cost, and that the sessions, credentials and rights stay valid. This page covers each.

Schedule the runs

For one data domain on one calendar, a scheduler calls a single statement per tick (see Managing time with the domain clock):

tdfs4ds.run(data_domain='SALES')

For many independent processes, build a wave plan from the lineage and generate a standalone script. Waves run in order; inside a wave the independent processes run in parallel, each in its own OS process with its own Teradata context:

plan = tdfs4ds.analyze_parallel_plan()                       # None = the whole store
path = tdfs4ds.write_execution_script(plan, max_workers=4, wave_on_failure='skip_descendants')
Argument Meaning
max_workers Most units run at once per wave. None falls back to tdfs4ds.SCHEDULING_MAX_WORKERS, then to one worker per unit
wave_on_failure 'skip_descendants' (default), 'continue', 'stop_after_wave', 'raise': see Orchestrating waves below
force_compute Recompute dates already COMPLETED

The script is written under tdfs4ds.SCHEDULING_SCRIPT_DIR, exits non-zero when anything failed and lists the processes it skipped. Full description: Parallel execution plan.

The contract with an external orchestrator. Call run(..., on_failure='raise'). A process segmented by a FilterManager then raises tdfs4ds.FeatureIngestionError after all its segments were attempted, if any failed, and the orchestrator marks the task failed. With the default 'continue' the run returns normally and the failure is only in the follow-up table.

Failure handling

Added in v0.3.1.210.

A feature-engineering chain is a pipeline: level 3 reads what level 2 produced. So the question is not only "did this process fail?" but "what should happen to everything that depends on it?" This page covers how tdfs4ds reports a failed ingestion, how it records one, and how to stop a failure from quietly contaminating the levels above it.

What changed, and what did not

Before v0.3.1.210, a process segmented by a FilterManager absorbed a failed filter: the error was logged, the loop moved to the next filter, and run() returned normally. An orchestrator chaining waves saw a success. Separately, a defect made the FAILED status impossible to write, so the follow-up table showed only RUNNING and COMPLETED and gave no way to reconstruct what had happened.

Both are fixed. Two things now happen without you opting in:

  • a failed filter is recorded in the follow-up table with a FAILED status carrying the first line of the Teradata error;
  • an ingestion that stages zero rows is recorded as COMPLETED,0 rows rather than COMPLETED.

Default control flow is unchanged. on_failure defaults to 'continue', which behaves exactly as before, and the upstream guard is off by default. Upgrading does not change how your chains run.

Choosing a failure policy

run(), upload_features() and roll_out() accept on_failure:

Policy Behaviour
'continue' (default) Every filter is attempted, each failure is recorded, a summary is logged. No exception — the historical behaviour.
'stop' The loop stops at the first failed filter, records it, and raises.
'raise' Every filter is attempted and recorded — so the trace is complete — then a single exception is raised at the end.
import tdfs4ds

# Make a partial ingestion failure visible to the caller.
tdfs4ds.run(process_id, on_failure='raise')

raise_on_failure=True is accepted as a shorthand for on_failure='raise'. If you pass both and they disagree, the explicit on_failure wins and a warning is logged.

The exception is a FeatureIngestionError and carries the detail as data, so an orchestrator never has to parse a message:

try:
    tdfs4ds.run(process_id, on_failure='raise')
except tdfs4ds.FeatureIngestionError as e:
    print(e.process_id, e.n_failed, "of", e.n_total, "filters failed")
    for f in e.failures:
        print(" filter", f["filter_id"], "->", f["error"])

A process without a FilterManager always raises

on_failure governs what happens to the run when some of its filters failed — a question that only exists when the work is segmented. An unsegmented ingestion has no next filter to move to, so it propagates its error regardless of the policy.

Stopping a failure from contaminating the levels above

A failed upstream does not make a downstream view fail. The view still compiles and still returns rows — empty or stale ones. The downstream process ingests them, succeeds, and records its own COMPLETED, which the skip logic then treats as final.

check_upstream=True refuses to compute when an upstream process has failed at the current valid time:

tdfs4ds.run(process_id, check_upstream=True)

Nothing is computed and no follow-up row is written. The log names the failing upstream processes and states both ways forward: fix the upstream and re-run, or proceed deliberately with check_upstream=False.

The test is "no upstream failed", not "every upstream completed" — a weekly reference process feeding a daily one legitimately has no row for today. Pass strict_upstream=True to also refuse when an upstream is still RUNNING.

Only the latest row of each segment counts, so an upstream that failed and was then re-run successfully no longer blocks (since v0.3.6.15).

With a refusal Default on_failure on_failure='raise' or 'stop'
run(pid), upload_features() returns (upload_features still registers the process) raises UpstreamRefusedError, a FeatureIngestionError
roll_out() carries on, and logs what was refused at the end raises at that date and stops
run([...]) the process reads REFUSED: ..., its downstream processes SKIPPED: ... 'raise': raises after the list. 'stop': stops the list

You can ask the same question without running anything:

verdict = tdfs4ds.check_upstream_health(process_id)
print(verdict["ok"], verdict["verified"])
print(verdict["explanation"])

This guard needs the lineage graph

It answers by reading the persisted lineage graph, so it is only as good as that graph. It reports ok and verified separately, because "no problem found" and "nothing could be checked" are different answers:

Situation ok verified What you are told
Graph empty as the graph rebuilt in memory says True the guard still answers, from the catalogs; rebuild_lineage_graph(all_data_domains=True) persists the graph
Graph unreadable True False run rebuild_lineage_graph(all_data_domains=True)
Process absent from the graph True False run rebuild_lineage_graph(objects=['<view>'], check=True)
Process known, no upstream True True it reads source objects only — nothing to check
Upstream failed False True the run is refused, with the failing processes named

The unreadable and absent cases do not block — missing information is not evidence of a problem — but they are never silent, because reporting "nothing to check" would read as approval from a check that never ran.

Refresh lineage as part of normal operations

If you rely on check_upstream, treat rebuild_lineage_graph() as routine maintenance, alongside documentation. A process registered after the last refresh is not yet protected.

Orchestrating waves

The script produced by generate_execution_script takes its own wave-level wave_on_failure:

Policy Behaviour
'skip_descendants' (default) Skips only the failed process's downstream closure; unrelated branches still run.
'continue' Runs every wave, reports failures at the end.
'stop_after_wave' Finishes the current wave, then stops.
'raise' Same, ending with a RuntimeError.
plan = tdfs4ds.analyze_parallel_plan()
path = tdfs4ds.write_execution_script(plan, wave_on_failure='skip_descendants')

The generated worker runs each process with on_failure='raise', since a wave policy can only react to failures it is told about.

Two settings, two names

on_failure applies to one process (continue / stop / raise); wave_on_failure applies to a plan of waves (skip_descendants / continue / stop_after_wave / raise). The value sets overlap without agreeing, so they are deliberately not the same parameter name.

The script exits non-zero when anything failed, and prints which processes were skipped and why.

Recovering from a contaminated run

Re-running a fixed process replays only the filters that never completed — the ones that succeeded keep their features and their COMPLETED rows.

But re-running does not repair the levels above it. Those processes recorded a genuine COMPLETED while computing on empty inputs, so they are skipped on the next pass and keep their wrong values. To correct them, either re-run them with force_compute=True, or delete their follow-up rows for that valid time.

Processes that ingested nothing are the exception: they carry COMPLETED,0 rows, which the skip test does not match, so they recompute on their own.

Follow-up statuses

Every run writes one row per segment to FS_FOLLOW_UP; read them with tdfs4ds.process_store.process_followup.follow_up_report(process_id=pid).to_pandas().

STATUS Meaning Next step
COMPLETED Succeeded and wrote rows. The skip test treats it as final for that valid time none
COMPLETED,0 rows Succeeded but staged nothing. It does not match the skip test, so it recomputes by itself check the source if unexpected
FAILED,<error> Failed, with the first line of the Teradata error fix the cause, then run(pid): only the segments that never completed run
RUNNING Executing now, or interrupted before an outcome was written (a killed kernel, a lost session) if stale, re-run before relying on the values

The stuck_running, interrupted_run and segment_failed findings of the sanity check report the last two.

Interrupted runs and lost connections

A network cut can leave the client waiting inside the driver with no error, while the database session sits idle: the database answered the last request and nobody is listening. The follow-up row stays RUNNING.

  • A kernel stop, Ctrl-C or kill is recorded: the batch writes FAILED,interrupted: KeyboardInterrupt (or the class of the interruption), with a 15 second limit so a dead connection cannot hold the interruption back, then the interruption goes on.
  • A hang is not an exception. Make it one: tdml.create_context(..., sql_timeout=<seconds>), or set TDFS4DS_TD_REQUEST_TIMEOUT=<seconds> for tdfs4ds' own connections. Use a value above the longest statement (the longest COMPLETED run is in the follow-up table). A request that exceeds it is aborted by the database (Error 3110) and the session stays usable; tdfs4ds does not retry it as a lost connection.
  • After a cut, stop the client and roll out again. roll_out(..., force_compute=True) from the first date of the range replays safely; an interrupted date is recomputed anyway, since only COMPLETED is skipped. Then check the cursor, and list the rows left open:
tdfs4ds.close_interrupted_runs(dry_run=True)    # superseded RUNNING rows, with the SQL
tdfs4ds.close_interrupted_runs(dry_run=False)   # closes them: FAILED,interrupted: no outcome recorded
tdfs4ds.close_interrupted_runs(include_stale=True, dry_run=True)  # also rows no session carries

Why a batch is not one transaction. Each statement is atomic. A batch is several statements (stage, merge into each FS_T_* table, close the follow-up row), so a cut can stop it between two of them. The guarantee is idempotent replay: a run writes its values from its valid time onward, so running the same date again rewrites the same periods. tdfs4ds does not wrap a batch in one transaction: the locks on several FS_T_* tables would serialise parallel runs, and the transient journal would grow with the batch.

Monitor runs and resources

Resources used by each execution (DBQL)

Every query of a process execution runs with a session query band:

TDFS4DS_RUN_ID=…;TDFS4DS_PROCESS_ID=…;TDFS4DS_EXEC_SEQ=…;TDFS4DS_EXECUTION_ID=…;TDFS4DS_VALIDTIME=…;TDFS4DS_VERSION=…;

These pairs are added to whatever band your session already has, and that band is restored after the execution. In DBQL (DBC.QryLogV.QueryBand) they link each query to its follow-up row:

usage = tdfs4ds.followup_resource_usage(process_id=None, run_id=None, days=30)
# one row per execution: every follow-up column, then the resource usage of its queries

print(tdfs4ds.followup_resource_usage_sql())   # the SQL, to reuse in your own tools
tdfs4ds.create_followup_resource_view()        # FS_V_FOLLOW_UP_RESOURCES, if the view DB may read DBQL
Column Meaning (summed over the execution's queries)
N_QUERIES, N_ERRORS queries run, and how many failed
AMP_CPU_SEC total AMP CPU
MAX_AMP_CPU_SEC CPU of the busiest AMP, heaviest query
IMPACT_CPU_SEC busiest AMP × active AMPs: what the system effectively spent
CPU_SKEW_PCT 1 − AMP_CPU / IMPACT_CPU; 0 = evenly spread, high = one AMP did the work
PARSER_CPU_SEC parse and optimise CPU
TOTAL_IO, PHYSICAL_IO logical and physical I/O
IO_SKEW_PCT the same skew rule on I/O (MaxAmpIO)
MAX_SPOOL_BYTES peak spool of any one query
FIRST_QUERY_START, LAST_RESPONSE DBQL times (system clock)
DBQL_STATUS LOGGED, PARTIAL, PENDING or NOT LOGGED — see below

DBQL is not immediate. Logged queries sit in a cache and reach the DBQL tables at the flush interval (DBQLFlushRate, 10 minutes by default). So every follow-up row is returned, with DBQL_STATUS saying whether its measures can be trusted yet:

  • LOGGED: complete.
  • PARTIAL: some rows found, but the execution is still running or ended less than flush_minutes ago, so the totals may still grow.
  • PENDING: nothing written yet. Ask again after the flush; a DBA can force it with FLUSH QUERY LOGGING WITH ALL;.
  • NOT LOGGED: old enough and still absent. Logging was off for the user, or the logging rule excluded these queries.

Pass flush_minutes= to match your system's flush rate, and only_logged=True to keep only the executions that have measures.

Three things are needed: - SELECT on DBC.QryLogV; - DBQL logging for the user that runs the processes, e.g. BEGIN QUERY LOGGING WITH SQL ON <user>;; - some patience: DBQL writes from a cache, so the latest executions appear after the flush interval (10 minutes by default).

check_configuration() checks all three. The view additionally needs its database to hold SELECT … WITH GRANT OPTION on DBC.QryLogV.

How rows are paired. A follow-up row has no execution id, and one cannot be added: older clients sharing the store would then fail to insert follow-up rows (Error 3812). A row is therefore identified by its RUN_ID, PROCESS_ID and its rank by START_DATETIME, and TDFS4DS_EXEC_SEQ carries that rank.

Two edge cases can pair a row with the wrong execution, both within the same run: - an execution whose follow-up insert failed shifts the later ones; - two executions of the same process starting in the same second may swap.

The statistics refresh after the last filter of a run is not tagged.

Set tdfs4ds.QUERY_BAND = False (or TDFS4DS_QUERY_BAND=false) to turn the tagging off.

Keeping the figures beyond DBQL's retention (since 0.3.3.19)

DBQL keeps a few days at most on most systems. The figures of each execution are copied into two tables of the feature store, created by setup() / connect() when missing (optional: without them only what DBQL still holds is shown):

  • FS_EXECUTION_RESOURCES (view FS_V_EXECUTION_RESOURCES): one row per execution, the columns above plus PROCESS_VERSION, the process version in force at the execution's valid time (its business date, else its start);
  • FS_EXECUTION_STATEMENTS (view FS_V_EXECUTION_STATEMENTS): one row per statement of an execution (type, times, CPU, I/O, spool, error). The SQL text is not copied: it is read from DBC.QryLogSQLV while DBQL holds it.
tdfs4ds.harvest_execution_resources()                 # copy what DBQL has finished writing
frame, info = tdfs4ds.read_execution_resources(process_ids=None, days=30, as_of=None)
stats = tdfs4ds.process_run_statistics(frame, by_version=True)
statements, info = tdfs4ds.execution_statements(execution_id)
  • When the copy runs: at the start of each run() (at most every 10 minutes in a Python process, never fatal), when the app's Runs page opens, and from Maintenance → Execution history. It is one INSERT … SELECT per table, run in the database, and it copies only the executions DBQL has finished writing (LOGGED) and not copied yet.
  • Reading: read_execution_resources returns the stored executions plus the live DBQL join for the ones not stored yet, so a run that just ended is listed (PENDING). Its info says when DBQL cannot be read (the follow-up rows are then listed without figures) or logs nothing.
  • Runs, not rows: a FilterManager run writes one follow-up row per segment and roll_out one per business date. process_run_statistics groups them into runs (same RUN_ID, each row starting within 10 minutes of the previous one's end) before computing how often a process runs and what a run costs.
  • TDFS4DS_EXECUTION_RESOURCES=false turns the history off. Primary store only.
  • In the app (since 0.3.3.20), Parameters → Execution log: query band and history switches both on or off for the app process, creates the history tables when needed and says whether this user's runs can be measured (query band settable, DBQL readable, queries logged). Put the variables in the app's .env to keep the setting.

In the admin app

  • Run & monitor → Runs (History tab): each execution with its process version, segment or valid time, status (the whole error for a failure), duration, CPU, skew, I/O and peak spool. Selecting one lists its statements. The second tab gives each process's runs, frequency and consumption per process version, and a chart of each execution over time with the version changes marked. Export to XLSX.
  • Feature catalog: the card of a feature's process gains Runs and consumption for the 30 days up to the catalog time viewed. Its versions table marks the version in force at that time and gives each version's median run and CPU, so the effect of a SQL change is visible. The export carries PROCESS_VERSION_AT, RUNS_30D, RUN_FREQUENCY, MEDIAN_RUN_SEC and MEDIAN_RUN_CPU_SEC.

Credentials, tokens and sessions

Situation What happens What to do
An LLM token (for example a Bedrock bearer token) expires during rebuild_documentation() or an index build The failed call is retried after a prompt for a new token, up to tdfs4ds.CREDENTIAL_RENEWAL_ATTEMPTS times (default 3; 0 = never ask). A blank answer stops the walk and returns the partial summary with stopped_on_credentials=True Paste the new token. Re-run with force_update=False to resume. When nobody can answer (a server, a scheduled job), nothing is prompted and the error propagates
The Teradata session is dropped (idle timeout, restart) execute_query recognises a lost connection, reconnects once from the TDFS4DS_TD_* variables and retries Keep those variables set in the process that runs the schedule
A token logon on AI Studio (about 2 hours of validity) open_session() applies the platform token; a refresher keeps TDFS4DS_TD_LOGDATA current when the logon is a token Start the process with tdfs4ds.open_session(...) instead of building the context by hand

A database logon that the database refuses leaves the existing context untouched, so a failed reconnect does not poison the session.

Logging

The tdfs4ds logger owns one console handler and does not touch the root logger.

Setting Effect
tdfs4ds.DISPLAY_LOGS Gate for verbose logging. False silences the package, errors included
tdfs4ds.LOG_COLOR None = colour by level when the output is a terminal; True / False to force
tdfs4ds.LOG_PROPAGATE True sends the lines to the root logger (your application's logging) instead of the console handler

Rights and GRANTs

plan_migration returns plan['access']: the rights the migrating user and the target databases need, in four groups, with the GRANT statements as text. tdfs4ds never executes a GRANT. A right it cannot read is reported unknown, not missing. After a DBA applied the grants, run as the target user:

tdfs4ds.check_access(plan)       # reads only; each refusal carries the GRANT that lifts it

Database-to-database grants are given at database level, because the migration's own run() reads the views it has just created. The same logic applies to the sanity checks: a refused EXPLAIN or SHOW VIEW is reported as not verified with the GRANT, never as a broken view. For DBQL-based figures the user needs SELECT on DBC.QryLogV and query logging (see above).

Vantage Cloud Lake

  • Manager tables on OFS. TimeManager(..., storage='OFS') and FilterManager(..., storage='OFS') create their backing table on the Object File System; the default is block storage. The choice is per manager.
  • Error 6881 (not eligible for the Analytical Compute Cluster). A tdstone2 model scored through the Apply backend runs on the ACC. The ACC rejects a view that reads a manager through a correlated scalar subquery, and accepts a JOIN to the manager view, on a manager table stored on OFS (confirmed on Vantage Cloud Lake). Writing that filter as a JOIN is a property of the scoring view's SQL, so it is yours. This is the one place where the scalar-subquery advice of the sanity checks does not apply.
  • run() cannot drive a view that inlines an Apply call. Its ingestion statement runs Apply itself and hits 6881. Score first (model.score()), then upload_features. A view that only reads a tdstone2 repository table is an ordinary read.

See Backing-table storage on Vantage Cloud Lake.