Skip to content

tdfs4ds.serve.dataset_code

tdfs4ds.serve.dataset_code

The Python that builds a dataset, as the Dataset builder would (0.3.4.0).

dataset_python(...) renders the tdfs4ds.build_dataset / tdfs4ds.build_historical_dataset call that the builder's Create runs for the same form (the arguments come from the same parsing: panels._builder_selection, _builder_kind, _builder_offsets), plus one explanation per argument. Pure: no database access, so it is tested offline. Credentials are never written: the host and user are filled in when known, the password is asked with getpass.

_KINDS module-attribute

_KINDS = {'current': 'A snapshot valid now: each time the view is read, it returns the values in force at that moment.', 'as_of': 'A snapshot frozen at {as_of}: the values valid at that instant, whatever is ingested later. Useful for a training set that must not move.', 'time_manager': 'A snapshot that follows the TimeManager {time_manager}: the view reads the values valid at its business date, and moving the manager (tm.update(...)) moves the dataset. This is how a scoring dataset follows a roll-out.'}

_lit

_lit(value) -> str

_dict_block

_dict_block(d: dict) -> str

A dict literal with one key per line (easier to read and edit than pprint's).

_indent

_indent(text: str, n: int) -> str

_history_text

_history_text(kind: dict) -> str

dataset_python

dataset_python(*, store: str, data_domain: str, entity: str, selected_features: dict, view_name: str, schema_name: str, kind: dict, join_type: str, feature_offsets: dict | None = None, document: bool = False, columns: dict | None = None, host: str = '', username: str = '') -> dict

The code and its explanation.

Returns {"code": str, "explanation": [(argument, text), ...], "html": str}; columns ({feature: [column names]}, from preview_column_names) only feeds the explanation.

_selection_text

_selection_text(sel: dict) -> str

_offsets_text

_offsets_text(offsets: dict, columns: dict) -> str

explanation_html

explanation_html(expl) -> str