tdfs4ds.finding_acceptance¶
tdfs4ds.finding_acceptance
¶
Accepted findings: FS_FINDING_ACCEPTANCE (0.3.7.34).
Some findings of the workflow assessment / sanity check are correct but expected (base tables behind an access layer of views, an empty first month because the source starts later). An administrator accepts one with a justification; the report then leaves it out of the error and warning counts and the verdict and lists it under Accepted, with who accepted it, when, why and until when. Nothing disappears silently.
Identity. :func:finding_identity is the ONE definition of "the same finding": the check
(kind), the object, the business dates it concerns and a hash of its detail with the volatile
parts removed (numbers, dates). An acceptance covers exactly that identity: another object, other
dates or a changed detail is a new finding, and so is the same finding after the acceptance
expired. :func:match_acceptances is pure.
Storage. An optional valid-time table in the store (the team sees the same acceptances),
created at setup() / connect() or by the first acceptance; a failed CREATE is remembered
and warned once. Every INSERT names its columns. Everything reading it is fail-open: no table, or
an unreadable one, means nothing is accepted and the assessment is what it always was.
_FIELDS
module-attribute
¶
_FIELDS = ('key', 'check', 'area', 'object', 'dates', 'detail_hash', 'detail', 'justification', 'accepted_by', 'editor', 'accepted_at', 'expires_at')
logger_safe
¶
Wrapper around the global logger that only emits logs when
tdfs4ds.DISPLAY_LOGS is True. level is a string like "info", "error", etc.
sql_literal
¶
Escape value for use inside a single-quoted SQL string literal.
For the DBC probes and catalog predicates that compare a name as data
(WHERE DatabaseName = '…'). The caller supplies the surrounding quotes.
finding_dates
¶
The sorted business dates a finding concerns: its dates field plus every ISO date its
detail names (a finding that carries its date only in the text is re-opened by another date
too).
normalise_detail
¶
The detail without what changes from run to run: dates, numbers, case, spacing.
finding_identity
¶
{"check", "object", "dates", "detail_hash", "key"} of a finding dict (as built by the
assessment): the identity an acceptance is matched on.
severity_note
¶
Why an accepted finding's acceptance may no longer be needed, or None (0.3.8.1). Pure.
The severity at acceptance is recorded since 0.3.8.1 (in the AREA column, after a |, no new
column); an earlier acceptance has none. Recorded and different: "accepted when it was X". Not
recorded and the finding is now info: info findings are in no count, so accepting one
changes nothing. Equal severities: no note.
match_acceptances
¶
(open, accepted, expired) for findings and the acceptances read from the store.
- accepted: the finding, with an
acceptancedict (justification, accepted_by, accepted_at, expires_at,expires_soon): an acceptance still in force whose identity equals the finding's. - open: every other finding. One that an acceptance of the same check and object no longer
covers carries
reopened:'expired'(the acceptance ended) or'changed'(other dates or another detail than what was accepted). - expired: the acceptances past their expiry date (listed, never dropped).
Pure. No acceptance gives (findings, [], []) with the findings untouched.
_view_missing
¶
Whether the public view is absent. existing (connect's DBC read of the table database) answers when views live in the table database; otherwise one DBC read. A failed read counts as absent: the REPLACE VIEW that follows is harmless when the view exists (0.3.7.34 field report: a store whose first connect failed on the view never got it, since the table existed).
_create_view
¶
Create the public view of an existing table; a refusal is a warning (a read-only user).
acceptance_creation
¶
Create the table and its view when missing. Never raises; returns whether it is usable.
available
¶
Whether the table exists in the primary store (checked once per store).
_expiry_literal
¶
TIMESTAMP '...' for a date / timestamp / ISO text (no zone = UTC); NULL for none.
accept_sql
¶
The statement recording one acceptance: a valid-time MERGE on the key, every column named.
read_acceptances
¶
Every acceptance of the store (expired ones included), [] when there is no table or it
cannot be read. Fail-open: the assessment is then what it always was.
_identity_from_args
¶
accept_finding
¶
accept_finding(check: Optional[str] = None, object: Optional[str] = None, *, justification: str, until=None, business_dates=None, finding: Optional[dict] = None, editor: Optional[str] = None, dry_run: bool = False) -> dict
Accept a finding of the workflow assessment, with a justification.
Parameters¶
check, object : str
The finding's kind (e.g. 'completed_on_empty_upstream') and object. Given alone, the
acceptance covers that check and object whatever the detail says; business_dates narrows it
to the dates named (a finding with other dates is a new one).
finding : dict, optional
A finding of assess_workflow()['findings']: its check, object, dates AND detail define what is
accepted (the finding re-opens when any of them changes). The easy way.
justification : str
Required and non-empty: why this finding is expected.
until : date, datetime or str, optional
Expiry; the finding re-opens after it. No zone = UTC.
editor : str, optional
Who is accepting, as declared (the database user is recorded too).
dry_run : bool
Return the statement, write nothing.
Returns {"key", "check", "object", "dates", "sql", "written"}. Raises ValueError for an empty
justification and RuntimeError when the table cannot be created. For administrators: the admin
app restricts the action to its admin profile, and the database rights on the table apply.
list_accepted_findings
¶
The acceptances of the store as a DataFrame (newest first): key, check, area, object, dates,
justification, accepted_by, editor, accepted_at, expires_at, state (active / expires soon /
expired). Expired ones only with include_expired=True. Empty when there is no table.
revoke_finding
¶
revoke_finding(key=None, object: Optional[str] = None, business_dates=None, *, dry_run: bool = False) -> dict
Revoke an acceptance: by its key (from :func:list_accepted_findings), by a finding dict, or by
(check, object, business_dates), key then holding the check. The finding is open again at
the next assessment; the history stays in the table (NONSEQUENCED VALIDTIME).
acceptances_for_migration
¶
acceptances_for_migration(plan_objects: Iterable[str], acceptances: Optional[list] = None) -> List[dict]
The acceptances of the (source) store that concern one of plan_objects (names, with or without database / quotes): for the migration plan to list, never to copy. The match is on the object's bare name appearing among the words of the acceptance's object text.