Skip to content

tdfs4ds.time_manager_report

tdfs4ds.time_manager_report

TimeManager inventory and report (0.3.7.22).

TimeManagers multiply as a project grows: a clock per data domain, a soft clone per process, copies made by hand, managers left behind by removed processes. This module answers, per data domain and per manager: what is there, what each manager is (role), which dates it holds, where its cursor is, who follows it (processes, datasets) and what is wrong with it, with the call that fixes each finding. It changes nothing.

Three layers, like serve/efs_map and workflow_assessment:

  • :func:collect_time_manager_inputs - the only I/O (fail-open: a failed read is recorded in errors and the matching facts read as unknown, never as "nothing");
  • :func:build_time_manager_model - pure;
  • :func:render_time_manager_html / :func:render_time_manager_markdown / :func:time_manager_findings_csv - text.

It builds on the process-level model of the Report's "Time drivers" section (serve.time_drivers.time_driver_model), which it does not redefine.

================= =========================================================================== role meaning ================= =========================================================================== clock the data domain's clock (set_domain_time_manager) clone of clock a soft clone of a clock: the clock's dates, its own cursor soft clone shares its table of dates with another manager that is not a clock hard copy its own table holding the same dates as another manager's (a copy) own calendar none of the above ================= ===========================================================================

logger module-attribute

logger = getLogger(__name__)

ROLES module-attribute

ROLES = ('clock', 'clone of clock', 'soft clone', 'hard copy', 'own calendar')

ROLE_TEXT module-attribute

ROLE_TEXT = {'clock': "the data domain's clock", 'clone of clock': 'a soft clone of the clock: its dates, its own cursor', 'soft clone': 'shares its table of dates with another manager', 'hard copy': "a copy of another manager's dates, in its own table", 'own calendar': 'its own table of dates'}

SEVERITIES module-attribute

SEVERITIES = ('error', 'warning', 'info')

NO_DOMAIN module-attribute

NO_DOMAIN = '(no data domain)'

KIND_TEXT module-attribute

KIND_TEXT = {'table_missing': 'Table of dates missing', 'view_missing': 'View missing', 'literal': 'Holds a literal date', 'unused': 'Followed by nothing', 'hard_copy': 'Copy of another calendar', 'clone_out_of_step': "Clone not at the clock's date", 'reader_status': 'Process does not read what it declares', 'off_clock': 'Processes not on the domain clock', 'shared_view': 'Clock read through a shared view', 'no_clock': 'Several managers, no domain clock', 'unverified': 'Not verified', 'registry_orphan': 'Registered, but its view and table are gone', 'rollout_refused': 'roll_out of the domain refuses', 'rollout_no_single_calendar': 'No single roll-out covers the domain', 'manager_shared_across_domains': 'Manager read by several data domains', 'domains_share_calendar': 'Domains on one calendar'}

ROLLOUT_TEXT module-attribute

ROLLOUT_TEXT = {'ok': 'covers every manager', 'refused': 'refuses: a manager on other dates', 'no_single_calendar': 'no single roll-out', 'real_time': 'no TimeManager (real time)', 'unverified': 'not verified (lineage)'}

_node

_node(db, name) -> str

_split

_split(node: str)

collect_time_manager_inputs

collect_time_manager_inputs(data_domains: Optional[Iterable[str]] = None, max_managers: int = 200) -> Dict[str, Any]

Read everything the model needs. The only function of this module that touches the database. data_domains: keep these domains (None = all).

_followup

_followup(proc)

Follow-up rows of the processes (for the last business date each completed).

rollout_coverage

rollout_coverage(rows, clocks: Dict[str, Dict[str, str]], tables: Dict[str, Optional[str]])

Will roll_out(data_domain=...) / run(data_domain=...) move every TimeManager the processes of each data domain read, and is a manager read across data domains? Pure (0.3.7.22).

rows: the process model's rows (process_id, view, domain, reads, status); clocks: {domain: {'view', 'table'}} (node ids); tables: {manager view: table}. Returns (coverage, findings): one coverage dict per data domain (moved: the managers a roll-out of the domain moves, not_moved: those it cannot, verdict: ok / refused / no_single_calendar / real_time / unverified) and findings in the report's shape.

The rule is the one roll_out applies: with a clock it moves the clock and the soft clones of it that the processes read, and refuses before step 1 a process reading a manager on another table of dates; without a clock it needs the processes on one table of dates (_attached_time_manager). A manager (view) read by processes of several domains moves for all of them whichever domain is rolled out.

_is_open

_is_open(ended) -> bool

build_time_manager_model

build_time_manager_model(inputs: Dict[str, Any]) -> Dict[str, Any]

The inventory: {'kpis', 'domains', 'managers', 'findings', 'growth', 'errors', ...}. Pure.

time_manager_inventory

time_manager_inventory(data_domains: Optional[Iterable[str]] = None) -> Dict[str, Any]

The TimeManager inventory of the store (or of data_domains) as a dict: per data domain (clock, managers by role, processes with and without a manager), per manager (role, table of dates, first and last date, cursor, processes and datasets following it) and the findings, each with the call that fixes it. Reads only.

_e

_e(v) -> str

_growth_svg

_growth_svg(growth) -> str

_rollout_cell

_rollout_cell(d) -> str

render_time_manager_html

render_time_manager_html(model: Dict[str, Any]) -> str

HTML body (the consistency section's CSS classes).

render_time_manager_markdown

render_time_manager_markdown(model: Dict[str, Any]) -> str

time_manager_findings_csv

time_manager_findings_csv(model: Dict[str, Any]) -> str

write_time_manager_report

write_time_manager_report(path: Optional[str] = None, fmt: Optional[str] = None, *, data_domains: Optional[Iterable[str]] = None, model=None) -> str

Write the TimeManager report and return its path. fmt: 'html' (default), 'md' or 'csv' (the findings), else taken from path's extension. Reads only.