fs-setup¶
Generate the connection boilerplate and run tdfs4ds.setup() / connect().
Invoked at the very start of every session.
Source file
The full skill specification (frontmatter + body) lives in
tdfs4ds/skills/fs-setup/SKILL.md.
The version below is included verbatim.
name: "Feature Store: Setup" description: "Generate code to connect to Teradata and initialise the tdfs4ds temporal feature store. Invoke when the user needs connection boilerplate, first-time setup, or wants to configure global feature store variables." argument-hint: "[schema][data-domain]" allowed-tools: "Read, Edit, Write, Bash, Glob, Grep"
Generate Python code to connect to a Teradata Vantage database and initialise the tdfs4ds temporal feature store.
User context: $ARGUMENTS
Related skills (typical next steps)¶
| Next | Skill | When |
|---|---|---|
| → | fs-upload |
Engineer the first feature engineering view and register it. |
| → | fs-inspect |
Verify catalogs were provisioned and the data domain is active. |
| → | fs-document |
Once a process is registered, document it and score its EXPLAIN plan. |
Demos: demos/notebooks/00 - Setup a temporal feature store.ipynb.
Install (Python 3.10 or later): pip install tdfs4ds holds the feature store and the admin app; add the assistant,
LLM documentation and vector index with pip install "tdfs4ds[agent]".
If the configuration asks for the assistant and the packages are missing, launch_app / configure_interactively offer tdfs4ds.install_agent_extra().
Ask for any missing values before generating code:
- Schema / database name — Teradata database hosting the feature store (e.g. 'demo_db').
- Data domain — project namespace isolating features across teams (e.g. 'Customer Transaction Analytics').
Emit the following pattern, substituting real values for every <PLACEHOLDER>:
# .env (never hard-code credentials):
# TDFS4DS_TD_HOST=<host>
# TDFS4DS_TD_USERNAME=<user> TDFS4DS_TD_PASSWORD=<password>
# (token logon instead: TDFS4DS_TD_LOGDATA='token=<jwt>', TDFS4DS_TD_LOGMECH=JWT)
# TDFS4DS_TD_DATABASE=<DATABASE> # optional default database of the session
# TDFS4DS_DATA_DOMAIN=..., TDFS4DS_INSTRUCT_MODEL_*, ... (every other setting, prefixed TDFS4DS_)
import tdfs4ds # loads the TDFS4DS_* settings of .env
tdfs4ds.reconnect_teradata(raise_error=True) # opens the teradataml context from TDFS4DS_TD_*
# Not sure which database holds the store? List the ones this session can see:
# tdfs4ds.find_feature_stores() # DATABASE_NAME, VIEW_DATABASE, COMPLETE, MISSING,
# # READABLE, N_PROCESSES, N_DATA_DOMAINS, ERROR
tdfs4ds.connect(database='<DATABASE>')
import teradataml as tdml
# Short header for an analytics notebook (instead of the three lines above): checks the installed
# version, loads the .env, logs on, connects, selects the data domain, sets the log display.
# Arguments left out change nothing. Switches shared by every notebook (TDFS4DS_AGENTIC_FEATURES,
# TDFS4DS_DISPLAY_LOGS) belong in the .env.
# tdfs4ds.open_session(database='<DATABASE>', data_domain='<DATA_DOMAIN>', min_version='0.3.8.1')
# open_session(..., display_logs=False, agentic_features=False) # applied after the .env, so they win over it; None = as configured
# Optional: keep VIEWS in a separate database from TABLES (governance policy).
# Omit database_view (or leave TDFS4DS_SCHEMA_VIEW unset) to co-locate them — the
# default, identical to before. When set, the view database must be granted
# SELECT (WITH GRANT OPTION) on the table database.
# tdfs4ds.connect(database='<DATABASE>', database_view='<VIEW_DB>')
# Optional overrides — can also be set via TDFS4DS_* in .env or in tdfs4ds.json
# tdfs4ds.FEATURE_STORE_TIME = None # valid time of the values a run writes (and of catalog reads).
# # None = real time. Prefer driving runs with a TimeManager
# # (run(pid, time_manager=tm), roll_out) - see fs-rollout.
# tdfs4ds.set_domain_time_manager(tm) # 0.3.6.0: one clock for the data domain (optional table
# # FS_DATA_DOMAIN_SETTINGS, created by setup/connect) - see fs-rollout
# 0.3.7.31: a calendar rule for the clock (tdfs4ds.Calendar) is recorded in the optional table
# FS_MANAGER_SETTINGS (created by setup/connect too) - see the fs-rollout section on Calendar rules
# tdfs4ds.DISPLAY_LOGS = True
# tdfs4ds.DEBUG_MODE = False
# tdfs4ds.STORE_FEATURE = 'MERGE' # keep 'MERGE': 'UPDATE_INSERT' is broken
# 0.3.8.0 (defaults shown; also TDFS4DS_<NAME> in .env):
# tdfs4ds.PHASE_TAGS = True # every statement carries its phase and the call id (profile, framework_cost)
# tdfs4ds.SKIP_UNCHANGED_REGISTRATION = True # an unchanged re-registration is recognised and skipped
# tdfs4ds.GROUP_BATCH_STATEMENTS = False # opt-in: the MERGEs of a batch in one request
# tdfs4ds.SERVER_SIDE_BATCH = 'off' # opt-in: 'auto' = one CALL per batch; first tdfs4ds.install_server_side_batch(dry_run=False)
# 0.3.8.14:
# tdfs4ds.PROCESS_DOMAIN_CHECK = 'warn' # 'warn'|'error'|'off': a view owned by a process of another data domain (error = ProcessDomainConflictError; upload_features(force_domain_change=True) moves it on purpose; TDFS4DS_PROCESS_DOMAIN_CHECK)
# tdfs4ds.INSTALL_AGENT = 'ask' # 'ask'|'yes'|'no': offer tdfs4ds.install_agent_extra() (pip install tdfs4ds[agent])
# Vector store backend for the consumer agent (optional — default is Chroma)
# tdfs4ds.VECTOR_STORE_BACKEND = 'chroma' # 'chroma' (default) | 'teradata' (keeps index in Vantage)
# tdfs4ds.TERADATA_VECTOR_STORE_PREFIX = 'tdfs4ds' # prefix for 3 named stores in Vantage
# TeradataAI in-database embedding (only used when VECTOR_STORE_BACKEND='teradata')
# When None, reuses the standard get_embeddings() (vLLM/TEI/OpenAI-compatible).
# tdfs4ds.TERADATA_AI_API_TYPE = None # 'aws'|'azure'|'gcp'|'nim'|'hugging_face'|'onnx'
# tdfs4ds.TERADATA_AI_MODEL_NAME = None
# tdfs4ds.TERADATA_AI_REGION = None # aws only
# tdfs4ds.TERADATA_AI_API_BASE = None # nim only
# tdfs4ds.TERADATA_AI_ACCESS_KEY = None # or TDFS4DS_TERADATA_AI_ACCESS_KEY env var
# First-time / administrator only (idempotent): deploy catalog tables and views.
# Add database_view='<VIEW_DB>' to place every view in a separate database from the tables.
tdfs4ds.setup()
# Create the data domain (idempotent — warns if already present).
# Analytics notebooks activate it with select_data_domain instead.
tdfs4ds.create_data_domain('<DATA_DOMAIN>')
Pattern — write the configuration, then prove it¶
Do not hand-write a .env on Teradata AI Studio: the platform publishes most of it, and the
values that must be asked for are the ones easiest to get subtly wrong.
import tdfs4ds
tdfs4ds.detect_ai_studio() # what the platform exposes
tdfs4ds.generate_ai_studio_env('.env', pin=True) # derive, ask, CHECK, then write
It asks only what it cannot derive (how to authenticate, which route LLM calls take, the API key and model), stages the result into the session, runs the full check against it, and refuses to write a file whose checks fail. On a token logon it also attempts the database logon first — the one credential the configuration check deliberately leaves alone, and the one this function writes.
If %gen_token is available, pass its token: it is a Vantage credential, where the session's
OAUTH_ACCESS_TOKEN may not be.
Anywhere else, answer a few questions and let the wizard update the file you already have:
tdfs4ds.configure_interactively('.env'). It edits .env line by line (comments and unrelated
variables survive), lists the models the endpoint serves (boto3 for Bedrock), asks for an API key
only when a keyless attempt is rejected, offers Chroma if the Teradata Vector Store is unavailable,
and writes secrets only after an explicit yes. To snapshot a session that already works instead:
tdfs4ds.export_config(fmt='env', source='module').
Verify before building anything — this needs no feature store, so run it first:
Nine checks, each naming the setting to fix: config load, Vector Store auth (with the token's
remaining lifetime), Vector Store service, LLM transport/TLS, instruct model, JSON constraints and
tool calling, embedding model, MCP server, and an opt-in write-path self-test. tdfs4ds.describe_config()
answers the narrower question "is this variable actually set?" without printing any secret.
cannot import name ... from 'teradataml...' means teradatagenai and teradataml don't match, not that a package is
missing: the check names the versions, any copy in ~/.local shadowing the environment's, and a pair known to work.
Rules¶
- A scheduled script starts with a version check (0.3.7.31): right after the import,
tdfs4ds.require('0.3.7.31')(the version the script was written for). It raisesRuntimeErrorwith thepip install -Ucommand when the installed package is older, instead of failing later on a missing function.setup()/connect()also create the optional tablesFS_DATA_DOMAIN_SETTINGS(domain clock, recorded gaps) and, since 0.3.7.31,FS_MANAGER_SETTINGS(calendar rule of a table of dates); a store without them keeps working, the rule is then inferred from the dates. -
On Teradata AI Studio, start a notebook with one call (0.3.5.17):
It loads the nearest.env(and says which), takes the platform's current token (ortoken=user_tokenafter%gen_token) and puts it wherever the file uses a token (database logon, Vector Store, MCP bearer), opens the teradataml context, connects toTDFS4DS_TD_DATABASEand renews the token in the background.connect=Falsestops after the logon (thentdfs4ds.setup(database=...)for a new store). End the notebook withtdml.remove_context(). When the platform gives no token and the one in the.envhas expired,sign_in=True(the default) runs the device-flow sign-in in a notebook or terminal: a link is shown, you sign in, and the session continues.sign_in=Falsenever asks; afterFailed to connect to JupyterHub API, useopen_session(token=user_token)after%gen_token_using_device_flow. Name the store you work in withdatabase=; if no database is known (nodatabase=, noTDFS4DS_TD_DATABASE, notdfs4ds.SCHEMA) nothing is connected and a warning says so. Other stores to read, read-only:tdfs4ds.open_session(database='<DATABASE>', databases_readonly=['<READONLY_DATABASE>'])(None= theTDFS4DS_SCHEMA_READONLYof the.env,[]= none; seefs-federation). -
Open the session with
tdfs4ds.reconnect_teradata(raise_error=True): it readsTDFS4DS_TD_*(password or token logon), and the package's automatic reconnection reuses the same variables, so a dropped connection comes back as the same user.tdml.create_context(...)by hand also works; open it before any call that reads the database. - Bound every request, whatever opens the connection.
TDFS4DS_TD_REQUEST_TIMEOUT=<seconds>applies to the connections tdfs4ds opens (reconnect_teradata,open_session, the app); a context the notebook opens itself does not read it. There, pass the same limit:tdml.create_context(host=..., username=..., password=..., sql_timeout=<seconds>)(teradataml's name for the driver'srequest_timeout). Without it a request on a connection the network dropped waits forever instead of failing (a longroll_outthen hangs with its follow-up rowRUNNING). Use a value above the longest statement, and neversql_timeout=0(the logon fails). - Use
tdfs4ds.create_data_domain(name)in the setup notebook (creates the domain, idempotent). Usetdfs4ds.select_data_domain(name)in all analytics/feature notebooks (activates an existing domain; raisesValueErrorif not found). Never settdfs4ds.DATA_DOMAINdirectly. - Never hard-code credentials; always use a
.envfile or OS environment variables. - The documentation ships with the package:
tdfs4ds.docs_path()gives the home page's path (docs_path('design-operate/good-practices.html')a page), and the admin app shows it under Help › tdfs4ds guide. tdfs4dsauto-loadsTDFS4DS_*variables from.envandtdfs4ds.jsonat import time. Calltdfs4ds.load_config(path=..., dotenv_path=...)to reload or point at a custom file.tdfs4ds.setup(database=...)is idempotent but is an administrator action — note this in a comment. Never writeif_exists='replace': it drops the feature, process and dataset catalogs of that database before recreating them, so every feature registered there is lost, other users' included. The default'fail'creates only what is missing.- When the user does not know the database, call
tdfs4ds.find_feature_stores()beforeconnect(): one read ofDBC.TablesV(only what the session may see) plus one count per store.COMPLETE=Falsemeansconnect()would return False (MISSINGnames the tables);READABLE=Falsemeans the catalog view refused the count (ERRORhas the whole message).complete_only=Truekeeps the storesconnect()accepts;details=Falseskips the counts. - After upgrading tdfs4ds on an existing store, run
tdfs4ds.upgrade_store()(dry run: the one-off steps the store still owes, such as dataset column rows or statistics options), thenupgrade_store(dry_run=False).connect()logs one line when a step is pending (0.3.7.37). connect()works on a store the user may only read: refreshing the catalog views needs the DROP right, and when it is refused the existing views are kept with a warning (0.3.2.4; before, it raised).- To separate views from tables, pass
database_view='<VIEW_DB>'tosetup()/connect()(or setTDFS4DS_SCHEMA_VIEW). Default (None) co-locates views with tables indatabase— no behaviour change. The view database needsSELECT ... WITH GRANT OPTIONon the table database, and an unqualified process/dataset name then defaults to the view database.