Skip to content

tdfs4ds.serve.page_code

tdfs4ds.serve.page_code

The code behind every page of the admin app, behind its (?) icon (0.3.6.13).

page_code(panel, ...) returns {title, explanation, code}: what the page shows, and a Python script that produces the same thing without the app. The script runs standalone: it opens its own session (the password typed through getpass, never written; a token logon uses open_session), attaches the current store and its read-only stores, does the page's default view, and closes the session in a finally.

A snippet never writes. Where the page can act (rebuild, migrate, remove, attach, create a dataset...) the snippet stops at the plan or the dry run and shows the write as a comment.

Pure: no database access, so it is tested offline. The page selections (a process, a date range) come later; each snippet takes the first process or dataset of the store where it needs one. The Dataset builder keeps its form-aware Show Python (dataset_code.py); this entry is the generic one.

_FIRST_PROCESS module-attribute

_FIRST_PROCESS = ['processes = tdfs4ds.process_catalog(all_data_domains=True).to_pandas()', 'if processes.empty:', "    raise SystemExit('No process is registered in this feature store.')", "process_id = processes['PROCESS_ID'].iloc[0]", "view_name = processes['VIEW_NAME'].iloc[0]"]

_FIRST_DATASET module-attribute

_FIRST_DATASET = ['datasets = tdfs4ds.dataset_catalog().to_pandas()', 'if datasets.empty:', "    raise SystemExit('No dataset is registered in this feature store.')", "dataset = datasets['DATASET_DATABASE'].iloc[0].strip() + '.' + datasets['DATASET_NAME'].iloc[0].strip()"]

lit

lit(value) -> str

readonly_arg

readonly_arg(readonly) -> list

The databases_readonly value: names, or the three-key descriptor for a store whose views live in another database or whose vector prefix is not the default.

standalone_prologue

standalone_prologue(*, store: str, readonly, host: str, username: str, token_logon: bool, encrypt: bool = False, extra_imports=())

The lines that open the session, for a page snippet: (head, tail).

head = imports + logon + connect, ending before the try:; the page body goes inside try: and tail (finally: tdml.remove_context()) closes it. Unknown host, user or database are typed at the prompt (input), never left as a placeholder.

_entries

_entries(store: str, readonly: list, token_logon: bool) -> dict

{panel: (title, explanation, body lines, top-level imports)}, one per PANELS key.

panel_keys

panel_keys() -> list

page_code

page_code(panel: str, *, store: str = '', readonly=None, host: str = '', username: str = '', token_logon: bool = False, encrypt: bool = False) -> dict

{title, explanation, code, filename} for one page. Raises KeyError for an unknown panel.