Skip to content

tdfs4ds.serve.home

tdfs4ds.serve.home

The Home page and the header search of the admin app (0.3.7.5).

home(profile) answers GET /ui/home: three or four cards per profile, each one computed on its own and fail-open -- a card that cannot be read says unavailable: <reason> and never raises. It reuses what the app already holds (the feature catalog model, the workflow model, the configuration checks, the health snapshot, the follow-up facts) and adds no heavy read of its own. A card that reads the store reports the "not connected" reason when there is no session; the configuration cards keep working.

search_objects(q) answers GET /ui/search: features, processes and datasets whose name matches, ranked exact > prefix > word > substring (> detail). It reads an in-memory index built from the feature catalog model when that is cached, else from three catalog reads (one under the feature-catalog lock); the index is cached for INDEX_TTL_S seconds.

Card shape: {id, title, state: 'ok'|'unavailable', reason, summary, items: [{label, detail, kind, key, chip, ask}], actions: [{label, target, disabled, reason}], search, hint}. kind/key make an item an object (opened through openObject in the browser).

logger module-attribute

logger = logging.getLogger(__name__)

PROFILES module-attribute

PROFILES = ('admin', 'engineer', 'scientist', 'analyst')

KINDS module-attribute

KINDS = ('feature', 'process', 'dataset', 'view', 'table')

INDEX_TTL_S module-attribute

INDEX_TTL_S = 120.0

CARD_TTL_S module-attribute

CARD_TTL_S = 60.0

STALE_DAYS module-attribute

STALE_DAYS = 7

TOP module-attribute

TOP = 8

_LOCK module-attribute

_LOCK = threading.RLock()

_INDEX module-attribute

_INDEX: dict = {'key': None, 'at': 0.0, 'entries': []}

_FACTS module-attribute

_FACTS: dict = {}

PROFILE_CARDS module-attribute

PROFILE_CARDS = {'analyst': (('suggestions', 'Questions to ask', _card_suggestions, True), ('search', 'Find a feature', _card_search, False), ('recent_documented', 'Recently documented features', _card_recent_documented, True)), 'scientist': (('undocumented', 'Features without documentation', _card_undocumented, True), ('datasets', 'Datasets', _card_datasets, True), ('shortcuts', 'Build and measure', _card_shortcuts, False), ('search', 'Find a feature', _card_search, False)), 'engineer': (('runs', 'Runs needing attention', _card_runs, True), ('health_check', 'Health check', _card_health_check, False), ('store_map', 'Store map', _card_store_map, True)), 'admin': (('config', 'Configuration', _card_config, False), ('database', 'Database', _card_database, False), ('maintenance', 'Maintenance', _card_maintenance, False), ('store_map', 'Store map', _card_store_map, True))}

clear

clear() -> None

Forget the search index and the cached facts (a store switch).

when

when(value) -> str

A raw ISO time as the status bar shows it: '11:25' today, else '8 Nov 11:25'. Anything unparseable is returned as it is.

_card

_card(cid: str, title: str, **kw) -> dict

_unavailable

_unavailable(cid: str, title: str, reason: str, hint: str = '') -> dict

_safe

_safe(cid: str, title: str, fn: Callable[[], dict]) -> dict

Run one card; an exception becomes an 'unavailable' card, never a failure.

_store_guard

_store_guard() -> Optional[str]

The reason the store cannot be read, or None.

_capability

_capability(name: str) -> dict

The app's view of one capability (never raises).

_catalog_model

_catalog_model() -> dict

The feature-catalog model: the cached one, else built once (under the lock).

_blank

_blank(v) -> bool

_card_suggestions

_card_suggestions() -> dict
_card_search() -> dict

_card_recent_documented

_card_recent_documented() -> dict

_card_undocumented

_card_undocumented() -> dict

_card_datasets

_card_datasets() -> dict

_card_shortcuts

_card_shortcuts() -> dict

_followup_facts

_followup_facts() -> dict

Latest status per process, from the follow-up (cached CARD_TTL_S per store).

_card_runs

_card_runs() -> dict

_card_health_check

_card_health_check() -> dict

_card_store_map

_card_store_map() -> dict

_card_config

_card_config() -> dict

_card_database

_card_database() -> dict

_card_maintenance

_card_maintenance() -> dict

_parse_time

_parse_time(v)

A catalog time as a timestamp, or None ('never run', 'unknown', ...).

_health_signals

_health_signals(failed: int, undocumented: int, total_features: int) -> list

What is wrong or fine, from what the app already holds (no read): [{id, label, level, detail, target}], level ok / warn / bad / unknown.

_card_overview

_card_overview() -> dict

The store at a glance, from the cached feature-catalog model (one read at most, shared with the other cards): name, domains, counts, last refresh, recent runs, health signals.

_build

_build(cid, title, fn, reads_db) -> dict

home

home(profile: str = 'admin', as_of: str = '', card: str = '', frame: bool = False) -> dict

The Home cards of one profile. frame=True returns only ids and titles (instant); card=<id> builds that one card (the page fetches the cards in parallel); neither builds them all. as_of is accepted for symmetry: Home shows the current state only.

_entries_from_model

_entries_from_model(model: dict, datasets) -> list

_dataset_entries

_dataset_entries(ds) -> list

_entry

_entry(kind: str, key, label, detail: str, extra: str = '') -> dict

_entries_from_catalogs

_entries_from_catalogs() -> list

Three cheap catalog reads, for when the feature-catalog model is not cached.

_index

_index() -> list

The search entries: from memory while fresh, else the cached model, else catalog reads.

_rank

_rank(entry: dict, q: str, words: list) -> Optional[int]

search_objects

search_objects(q: str, limit: int = 20) -> dict

{"results": [{kind, key, label, detail}]} ranked exact > prefix > word > substring (> detail). An empty query returns nothing and reads nothing.