Skip to content

tdfs4ds.removal_log

tdfs4ds.removal_log

Removal log: FS_REMOVAL_LOG (0.3.3.27).

One row per removal of a process, a feature, a dataset or stored values, and one per removal refused because other objects depend on the object: who (the database USER), when, what (its id and name, so a removed process can still be named once its catalog rows are gone), whether it was forced, the dependents, the origin (api, script, app) and the outcome (REFUSED, RUNNING, COMPLETED, FAILED,<error>).

Optional, like the other tracking tables: created at setup() / connect() when missing; a failed creation is one warning and is not retried in the process; every write is fail-open (a removal never fails because its log row could not be written). Plain table (not temporal): a removal is an event.

_STATE module-attribute

_STATE: dict = {}

_WARNED module-attribute

_WARNED: set = set()

_ORIGIN module-attribute

_ORIGIN = ContextVar('tdfs4ds_removal_origin', default='api')

KINDS module-attribute

KINDS = ('PROCESS', 'FEATURE', 'DATASET', 'VALUES')

logger_safe

logger_safe(level, message, *args, **kwargs)

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

sql_literal(value)

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.

_table_name

_table_name() -> str

_view_name

_view_name() -> str

_key

_key() -> Optional[str]

reset_state

reset_state() -> None

_warn_once

_warn_once(key: str, message: str, *args) -> None

_execute

_execute(sql: str)

removal_log_ddl

removal_log_ddl() -> str

removal_log_view_sql

removal_log_view_sql() -> str

removal_log_creation

removal_log_creation(existing: Optional[Iterable[str]] = None) -> bool

Create FS_REMOVAL_LOG and its view when missing. Never raises.

existing: the lower-cased object set connect() read from DBC; a table found there costs no CREATE (its view is refreshed).

available

available() -> bool

Whether FS_REMOVAL_LOG exists in the primary store (checked once per store).

removal_origin

removal_origin(origin: str)

Mark the removals of the block as coming from origin (script, app).

_lit

_lit(v) -> str

_deps_text

_deps_text(dependents) -> Optional[str]

log_event

log_event(kind: str, *, object_id=None, object_name=None, data_domain=None, process_id=None, forced: Optional[bool] = None, dependents=None, status: str = 'RUNNING', detail=None) -> str

Insert one row; returns its EVENT_ID (even when nothing could be written).

log_close

log_close(event_id: Optional[str], status: str = 'COMPLETED', detail=None) -> None

logged_removal

logged_removal(kind: str, **kw)

Open a RUNNING row for the block; close it COMPLETED, or FAILED,<error> and re-raise. The block may set ctx["status"] (e.g. a partial outcome).

get_removal_log

get_removal_log(kind: Optional[str] = None, since=None, limit: Optional[int] = None) -> pd.DataFrame

The removal log, newest first: every removal, and every refusal.

kind: 'PROCESS', 'FEATURE', 'DATASET' or 'VALUES'; since: a date or timestamp. Empty frame when the table does not exist.

removed_processes

removed_processes(pids: Iterable[str]) -> dict

{pid: {"name", "at", "user", "forced"}} of the last completed removal of each process found in the log. Empty when the log is unavailable.