Skip to content

tdfs4ds.props_show

tdfs4ds.props_show

Feature properties, the SHOW side (0.3.7.23): what the app, the export, the agent and the documentation read of the properties a store declares (valid range, allowed values, meaning of a NULL, sensitivity; see tdfs4ds.feature_props).

Everything here is opt-in and fail-open: declared() returns None unless the store has the properties tables (feature_props.state.PRESENT is truthy, tested BEFORE any read) and at least one declared row, so with nothing declared no statement is issued and every caller keeps its old output byte for byte. The sentences come from the ONE renderer of the core package (render_properties_text); the helpers below only select, compare and lay out.

EXPORT_COLUMNS module-attribute

EXPORT_COLUMNS = ['VALID_RANGE', 'NULL_MEANING', 'SENSITIVE']

_VALID_VALUE_RE module-attribute

_VALID_VALUE_RE = re.compile('\\b(valid|allowed|permitted|acceptable|legal|expected|possible|authori[sz]ed)\\s+(values?|range|ranges|domain|levels?|categor\\w+)\\b|\\b(range|domain)\\s+of\\s+(valid|allowed)\\b|\\bwhat\\s+(values?|range)\\b.*\\b(can|may|allowed|valid)\\b|\\bvaleurs?\\s+(valides?|autoris\\w+|permises?|possibles?|accept\\w+|attendues?)\\b|\\b(plage|intervalle|domaine)\\s+(de\\s+)?(valeurs?|validit\\w+)\\b|\\bplage\\s+valide\\b|\\bvaleurs?\\b.{0,25}\\b(valides?|autoris\\w+|permises?)\\b|\\bvaleurs?\\b.*\\b(peut|peuvent)\\s+prendre\\b|\\bwhat\\s+(values?)\\b.*\\b(take|takes|hold)\\b', re.I)

_SELECTION_RE module-attribute

_SELECTION_RE = re.compile('\\b(select|selecting|target|targeting|filter|filtering|segment|segmenting|exclude|excluding|choose|pick|rank|prioriti[sz]e|score|decide|eligible|eligibility|cibler|ciblage|s[ée]lectionn\\w+|filtrer|segmenter|exclure|choisir|prioris\\w+|[ée]ligib\\w+)\\b', re.I)

_CUSTOMER_RE module-attribute

_CUSTOMER_RE = re.compile('\\b(customers?|clients?|people|persons?|users?|individuals?|members?|patients?|prospects?|personnes?|utilisateurs?|membres?|assur[ée]s?|abonn[ée]s?)\\b', re.I)

_OUTLIER_ASK_RE module-attribute

_OUTLIER_ASK_RE = re.compile('\\b(outliers?|unusual|anomal\\w*|atypiques?|aberrant\\w*|abnormal|out\\s+of\\s+(?:range|bounds)|impossible|invalid|hors\\s+(?:de\\s+la\\s+)?(?:plage|bornes|limites)|invalides?|bounds?|bornes?|limites?|declared\\s+range|plage\\s+d[ée]clar[ée]e)\\b', re.I)

present

present() -> bool

True only when the store is known to hold declared properties. Never reads the database.

read_properties

read_properties(as_of=None, data_domains=None) -> pd.DataFrame

render

render(row, lang: str = 'en') -> str

The fixed sentences of a property row (the core renderer); "" when unavailable.

declared

declared(as_of=None, data_domains=None) -> Optional[pd.DataFrame]

The declared properties, or None (nothing declared, tables absent, any failure). No statement is issued unless present().

_g

_g(row, key)

_txt

_txt(v) -> str

norm

norm(x) -> str

rows_of

rows_of(df: Optional[DataFrame]) -> list

find

find(df: Optional[DataFrame], feature: str, entity: str = '', domain: str = '') -> Optional[dict]

The property row of a feature: exact (domain, entity, name), narrowed by what is given; a bare name that matches rows of several entities / domains is None (never a guess).

has_range

has_range(row) -> bool

_allowed

_allowed(row) -> list

is_sensitive

is_sensitive(row) -> bool

numeric_bounds

numeric_bounds(row) -> tuple

(min, max) as floats (None for a missing or non-numeric bound).

compact

compact(row, fr: bool = False) -> str

The short cell of the feature catalog: range / allowed values, NULL meaning, sensitive.

panel_cell

panel_cell(row) -> dict

What the Feature catalog page shows for one declared row.

export_values

export_values(row) -> dict

The three export cells of a declared row ("" for a property with no rule).

named_features

named_features(question: str, df: Optional[DataFrame]) -> list

Rows of df whose feature name the question writes (whole word, accents and _ tolerant).

valid_values_request

valid_values_request(question: str, df: Optional[DataFrame]) -> Optional[list]

The property rows a "what is a valid value for X?" question is about, or None. Pure.

sensitive_selection

sensitive_selection(question: str, df: Optional[DataFrame]) -> list

Sensitive features a question names while asking to select / target / filter customers.

valid_values_answer

valid_values_answer(rows: list, fr: bool) -> str

sensitive_warning

sensitive_warning(rows: list, fr: bool) -> str

asks_for_outliers

asks_for_outliers(question: str) -> bool

The question asks for outliers / unusual values / the declared bounds (the only time the declared range is used by the agent for values and charts).

range_violation_line

range_violation_line(e: dict, fr: bool, df: Optional[DataFrame] = None) -> str

One fixed line when the stored min / max of a feature (feature_extremes result) fall outside the declared range: those values are data errors, not outliers. "" otherwise, and without any read when nothing is declared. Called only when the question asks for outliers.

declared_range_of

declared_range_of(feature: str, entity: str = '', domain: str = '') -> Optional[tuple]

(min, max) declared for a feature (floats), None when none; no read unless present.

process_properties_context

process_properties_context(process_info: dict, df: Optional[DataFrame] = None) -> str

Prompt block with the declared properties of a process's features; "" when none (and no read unless the store has declared properties).

column_text_with_properties

column_text_with_properties(table_name: str, column_name: str, text: str, df: Optional[DataFrame]) -> str

The text indexed for a documented column: its description, then the declared properties when the column is a feature with a single declaration (a name shared by several declarations is left alone).