Skip to main content

telemetry

Datadog telemetry for Bitfount.

Structured log events are sent to the Datadog Logs API via telemetry_logger (bitfount.telemetry.logs).

The full public surface is re-exported here for convenience.

Module​

Submodules​

Functions​

clear_global_telemetry_context​

def clear_global_telemetry_context() ‑> None:

Empty the process-wide telemetry context.

clear_telemetry_context​

def clear_telemetry_context() ‑> None:

Drop everything set_telemetry_context put in the current context.

The counterpart to setting without a scope: a process that reuses a context across runs - and a test - needs a way back to empty. Values held by an open telemetry_context_scope are restored by that scope as usual.

current_telemetry_context​

def current_telemetry_context() ‑> dict[str, str | int | float | bool]:

Return the context to attach to an event, overlay over global.

Returns A new dict; mutating it does not affect either layer. Empty if nothing has been set, or if reading either layer failed.

emit_gpu_usage_event​

def emit_gpu_usage_event(    sampler: GpuUsageSampler,    *,    step_name: str,    model_ref: str | None = None,    model_class: str | None = None,    task_hash: str | None = None,    run_id: str | None = None,    exc: BaseException | None = None,) ‑> None:

Send a sampler's summary as one GpuUsageEvent.

Nothing is sent for a disabled sampler. Never raises.

Arguments

  • sampler: The sampler to report; stopped first if still running.
  • step_name: The step that was sampled.
  • model_ref: Which model ran.
  • model_class: Class name of the loaded model.
  • task_hash: The step's partition.
  • run_id: The flow run.
  • exc: The exception that ended the step, or None if it succeeded.

flush_datadog_telemetry​

def flush_datadog_telemetry() ‑> None:

Flush the Datadog telemetry buffer.

This should be called to ensure all buffered logs are sent to Datadog.

record_dag_step_time​

def record_dag_step_time(    start: float,    *,    step_name: str,    task_hash: str | None = None,    files_processed: int | None = None,    patients_processed: int | None = None,    exc: BaseException | None = None,) ‑> None:

Emit the execution time of one DAG step, and how it ended.

Arguments

  • start: time.perf_counter() captured before the step began.
  • step_name: The step's name.
  • task_hash: Task hash of the run the step belongs to, when known.
  • files_processed: Files this invocation read, when the step reported it through report_step_progress. None when it reported nothing — a step that cannot answer leaves the field empty rather than having a number guessed for it.
  • patients_processed: Patients this invocation handled, same contract.
  • exc: The exception that ended the step, or None if it returned. Defaults to None so that a caller which does not track the outcome keeps working; callers that can tell should pass it.

report_step_progress​

def report_step_progress(    *,    files_processed: int | None = None,    patients_processed: int | None = None,    entries_created: int | None = None,    items_skipped: int | None = None,    cache_entries_used: int | None = None,) ‑> None:

Record how much work the running step did.

A no-op when no recorder is bound, so a step function stays callable outside a DAG run and in its own unit tests. Only the arguments given are written, so a step can report its counts from different places.

Arguments

  • files_processed: Files this step actually read this run.
  • patients_processed: Distinct patients this step handled this run.
  • entries_created: Rows this step persisted this run.
  • items_skipped: Items this step was handed and left out.
  • cache_entries_used: Items this step answered from stored rows.

set_global_telemetry_context​

def set_global_telemetry_context(**fields: Any) ‑> None:

Merge fields into the process-wide telemetry context.

Call this as soon as a value is known - in particular immediately before setup_datadog_telemetry, so that events emitted from the moment the handler exists already carry it.

Arguments

  • **fields: Context entries. A None value is ignored rather than recorded, so a caller can pass an optional value unconditionally.

set_telemetry_context​

def set_telemetry_context(**fields: Any) ‑> None:

Add fields to the telemetry context without a scope to leave.

For a value that describes the whole of the work the current context is doing, set where that work begins - a DAG run naming its dataset. Use telemetry_context_scope instead wherever the value has an end as well as a beginning; this one stays until the context it was set in goes away, or until the next run overwrites it.

Arguments

  • **fields: Context entries. None values are ignored.

setup_datadog_telemetry​

def setup_datadog_telemetry(    dd_client_token: str | None = None,    dd_site: str | None = None,    service: str = 'pod',    hostname: str | None = None,    tags: list[str] | None = None,    log_level: str = 'INFO',) ‑> None:

Setup Datadog telemetry logging if credentials are available.

If credentials are not provided, the telemetry logger will exist but have no handlers, meaning all telemetry logs will be silently dropped.

This function is idempotent - calling it multiple times is safe.

Arguments

  • dd_client_token: The Datadog client token.
  • dd_site: The Datadog site to use (e.g., 'datadoghq.com', 'datadoghq.eu').
  • service: The service to use for the logs.
  • hostname: The hostname to use for the logs. Defaults to system hostname.
  • tags: The tags to use for the logs.
  • log_level: The log level for the Datadog handler (e.g., 'INFO', 'DEBUG').

Returns None

shutdown_datadog_telemetry​

def shutdown_datadog_telemetry() ‑> None:

Shutdown Datadog telemetry logging and flush any pending logs.

This should be called during application shutdown to ensure all buffered logs are sent to Datadog.

telemetry_context_scope​

def telemetry_context_scope(**fields: Any) ‑> Iterator[None]:

Add fields to the telemetry context for the duration of the block.

Nested scopes merge, innermost winning, and the overlay is restored on exit whether the block returned or raised.

Arguments

  • **fields: Context entries. None values are ignored.

track_dag_execution_time​

def track_dag_execution_time(func: F) ‑> F:

Decorator emitting a DAG entry point's execution time.

Emits a DAGExecutionTimeEvent naming the function and, for a method, its class. Supports sync and async callables.

Arguments

  • func: The function to wrap.

Returns The wrapped function.

Classes​

AlgorithmProgressEvent​

class AlgorithmProgressEvent(**data: Any):

Emitted at algorithm lifecycle boundaries (run/epoch start and end).

Fired automatically by AlgorithmProgressHook for every algorithm via the BaseAlgorithmHook infrastructure — individual algorithm classes do not need any changes.

step is one of "run_start", "run_end", "epoch_start", or "epoch_end".

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static algorithm_name : str
  • static current_epoch : int | None
  • static datetime : str
  • static max_epochs : int | None
  • static model_config
  • static step : str
  • static step_info : str | None
  • static task_context : str

BCVADerivationEvent​

class BCVADerivationEvent(**data: Any):

Emitted once per background ehr_criteria_query run that built a record.

Counts what each patient's observations held and what deriving the canonical logMAR BCVA reading made of the acuity ones, across every patient in the run. Sent even when no acuity arrived, since that is the case the counts exist to explain. Counts, terminology codes and masked text shapes only: never a reading, its text, or a patient.

The four counts of the CCD rule's decision (ccd_estimate, ccd_low_vision_only, ccd_near_skipped, ccd_binocular_skipped) count it per entry, before the value is read, so they include entries that state no reading.

Attributes

  • chart: Chart readings converted to logMAR.
  • low_vision_coded: Low-vision categories from a coded answer.
  • low_vision_text: Low-vision categories from text.
  • finding: Low-vision categories from a finding code.
  • unreadable_scale_unstated: Numbers whose scale neither the code nor the unit states, stored as text.
  • unreadable_unparsed_text: Text that is no acuity, stored as text.
  • unreadable_unmapped_coded: Coded answers that map to no reading, stored as text.
  • unreadable_out_of_range: Readings outside their scale's range, stored as text.
  • finding_negated: Findings recorded as absent.
  • finding_conflict: Findings whose value contradicts their code.
  • eye_from_code: Readings placed by the eye their code names.
  • eye_conflict: Readings whose stated eye disagrees with their code's. The stated eye wins and the reading is kept.
  • eye_from_text: Readings placed by the eye their own text states (OD 20/40), because the observation states none.
  • text_eye_conflict: Readings dropped because their own text states an eye the observation does not resolve to.
  • patients_observations_unanswered: Patients whose observation fetch did not answer, so no acuity could arrive (for example, an EHR that rejects the observation search).
  • patients_observations_empty: Patients the EHR answered for with no observations at all.
  • patients_without_acuity: Patients with observations, none of them under an acuity code this step reads.
  • patients_with_acuity: Patients with at least one observation under an acuity code.
  • observations: Observation entries served, across every patient.
  • estimate_readings: Readings taken from an estimate of best-corrected
  • acuity: corrected or pinhole distance acuity, or a CCD reading the CCD rule read as an estimate (ccd_estimate).
  • derived_best_corrected: Converted derived BCVA entries kept, one per eye per day, that came from a best-corrected reading.
  • derived_estimate: Converted derived BCVA entries kept that came from an estimate, because that eye had no best-corrected reading that day.
  • derived_low_vision_only: Converted derived BCVA entries kept that came from a low-vision category under an uncorrected or generic acuity code, for the same reason.
  • derived_unconverted: Derived BCVA entries kept that carry the source text rather than a logMAR number, from whichever kind of code. Each fails every numeric bound.
  • patients_bcva_best_corrected: Patients with at least one converted derived BCVA from a best-corrected reading.
  • patients_bcva_estimated: Patients with at least one converted derived BCVA from an estimate.
  • ccd_estimate: Readings parsed from a CCD document that no code classified, read as an estimate of best-corrected acuity: their label says neither near nor binocular, nor uncorrected without corrected or pinhole.
  • ccd_low_vision_only: CCD readings no code classified whose label says uncorrected and not corrected or pinhole, so only a low-vision category derives.
  • ccd_near_skipped: CCD readings no code classified whose label says near. Each derives nothing.
  • ccd_binocular_skipped: CCD readings no code classified that are labelled binocular or placed in both eyes. Each derives nothing.
  • ccd_non_reading_skipped: CCD entries no code classified whose text would not convert and carries no acuity token (no fraction, plausible number, low-vision category or letter count): a method, a correction or an assessment the parser took for acuity by its display. Each derives nothing.
  • ccd_extra_text_field: ;-separated fields after a CCD reading that are neither empty, NI, nor a correction, near or binocular label. No rule reads them.
  • non_reading_skipped: Readings outside the CCD rule whose text records that no reading was taken (Not tested, Other, None; see states_no_reading). Each derives nothing, so the eye's previous reading decides.
  • non_acuity_codes: The most frequent "<system>|<code>" of observations no acuity reading came from, to their count. Capped at BCVA_NON_ACUITY_CODES_LIMIT. Terminology identifiers only, never a value, a display or a patient: it shows which code a site files acuity under when none of the read ones arrive.
  • estimate_codes: The "<system>|<code>" estimated readings were taken from, to their count, capped like non_acuity_codes.
  • unparsed_text_shapes: The most frequent masked shapes (acuity_text_shape) of the readings counted as unreadable_unparsed_text, and, keyed behind non_reading:, of the readings counted as non_reading_skipped, to their count, capped like non_acuity_codes. Digits are 9 and every word that is not acuity vocabulary is a, so a shape shows a site's format and never the text.
  • ccd_extra_field_shapes: The most frequent masked shapes of the fields counted as ccd_extra_text_field, and, keyed behind non_reading:, of the text of the entries counted as ccd_non_reading_skipped, to their count, masked and capped like unparsed_text_shapes.
  • task_hash: The step's partition.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static ccd_binocular_skipped : int
  • static ccd_estimate : int
  • static ccd_extra_field_shapes : dict[str, int]
  • static ccd_extra_text_field : int
  • static ccd_low_vision_only : int
  • static ccd_near_skipped : int
  • static ccd_non_reading_skipped : int
  • static chart : int
  • static derived_best_corrected : int
  • static derived_estimate : int
  • static derived_low_vision_only : int
  • static derived_unconverted : int
  • static estimate_codes : dict[str, int]
  • static estimate_readings : int
  • static eye_conflict : int
  • static eye_from_code : int
  • static eye_from_text : int
  • static finding : int
  • static finding_conflict : int
  • static finding_negated : int
  • static low_vision_coded : int
  • static low_vision_text : int
  • static model_config
  • static non_acuity_codes : dict[str, int]
  • static non_reading_skipped : int
  • static observations : int
  • static patients_bcva_best_corrected : int
  • static patients_bcva_estimated : int
  • static patients_observations_empty : int
  • static patients_observations_unanswered : int
  • static patients_with_acuity : int
  • static patients_without_acuity : int
  • static task_hash : str | None
  • static text_eye_conflict : int
  • static unparsed_text_shapes : dict[str, int]
  • static unreadable_out_of_range : int
  • static unreadable_scale_unstated : int
  • static unreadable_unmapped_coded : int
  • static unreadable_unparsed_text : int

BackgroundDAGRunCrashedEvent​

class BackgroundDAGRunCrashedEvent(**data: Any):

Emitted when a background DAG run's process died without reporting itself.

A native crash (an access violation, an abort) ends the run's process with no Python code running, so the run emits nothing. The pod reports it instead, from the exit code the runner saw or, for a run found dead at start-up, from the run's breadcrumb alone. The breadcrumb says where the run had got to and the fault file, when there is one, says which code was running. No path, file name or patient identifier is carried.

Attributes

  • flow_run_id: The Prefect flow run that crashed.
  • run_id: The run's identifier.
  • task_hash: The (pod, datasource) task hash of the run.
  • project_id: The project the run belongs to.
  • datasource_name: The datasource the run processes.
  • trigger: Why the run was started.
  • exit_code: The process's exit code, as the runner reported it; None when the crash was found at start-up.
  • exit_code_hex: The exit code as 0xXXXXXXXX; None for a signal and when there is no exit code.
  • exit_kind: One of access_violation, illegal_instruction, stack_overflow, fail_fast, heap_corruption, segmentation_fault, bus_error, floating_point_exception, aborted, terminated, signal_<n> or other. The first nine are native crashes (the POSIX ones are the fatal signals SIGSEGV, SIGBUS, SIGFPE, SIGILL and SIGABRT, and heap_corruption is 0xC0000374). terminated, signal_<n> for any other signal and other say the process was stopped or exited, not that it faulted. Query native_crash, not this field, to count native crashes.
  • native_crash: Whether the process died of a native fault. true is
  • certain: exit_kind is one of the native kinds, or the fault file has a Fatal Python error line (an abort, say). A Windows fatal exception line alone does not count when there is an exit code, because faulthandler also writes it for a first-chance exception that is then handled, in a run that is later killed. false for a kill (TerminateProcess, an app quit or update, SIGTERM) and for a start-up sweep with no fault text. None (unknown) for a sweep finding, with no exit code, fault text that has no Fatal Python error line. Query @native_crash:true for certain native crashes.
  • detected_by: "runner_exit" when the pod's hook saw the runner report the exit, "startup_sweep" when the breadcrumb of a dead process was found at start-up.
  • pid: The process the run was in.
  • process_age_seconds: How old the process was at the last breadcrumb
  • write: the breadcrumb's written_at less the process's creation time.
  • breadcrumb_age_seconds: How long before the crash was detected the last breadcrumb write was: the detection time less written_at.
  • step: The DAG step the main line of execution was in.
  • phase: What the main line of execution was doing; "unreadable" when the breadcrumb could not be parsed, and None when there was no breadcrumb or its phase is not a known one. No breadcrumb means the process died before the run body, or after the run body closed its breadcrumbs and before the runner heard of the end.
  • model_ref: The model being run.
  • file_seq: The 0-based index into the step's plan of uncached files. The desktop log's Processing file lines map it to a file on the site's machine.
  • files_total: How many files the step planned to process.
  • reader_phase: What the read-ahead line of execution was doing.
  • reader_file_seq: The read-ahead line's index into the step's plan.
  • wave_index: The index of the wave being run.
  • fault_kind: A code for the last fatal-exception line of the fault file, from a fixed set such as access_violation, segmentation_fault, windows_exception or other.
  • fault_frames: The faulting thread's top frames as module/function:line, with paths that resolve to installed code only.
  • gpu_utilisation_pct: The GPU's compute utilisation at the run's last sample before the fault, from the breadcrumb the sampler writes. Device-wide (NVML), not this process's.
  • gpu_memory_used_bytes: Device memory in use across all processes at that sample. Compare with gpu_memory_total_bytes to tell a fault at the card's limit from one that never approached it.
  • gpu_memory_total_bytes: The device's total memory at that sample.
  • gpu_sample_count: How many samples the sampler had taken. A low count means the fault came early in the step.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static breadcrumb_age_seconds : float | None
  • static datasource_name : str | None
  • static detected_by : str
  • static exit_code : int | None
  • static exit_code_hex : str | None
  • static exit_kind : str | None
  • static fault_frames : list[str] | None
  • static fault_kind : str | None
  • static file_seq : int | None
  • static files_total : int | None
  • static flow_run_id : str | None
  • static gpu_memory_total_bytes : int | None
  • static gpu_memory_used_bytes : int | None
  • static gpu_sample_count : int | None
  • static gpu_utilisation_pct : float | None
  • static model_config
  • static model_ref : str | None
  • static native_crash : bool | None
  • static phase : str | None
  • static pid : int | None
  • static process_age_seconds : float | None
  • static project_id : str | None
  • static reader_file_seq : int | None
  • static reader_phase : str | None
  • static run_id : str | None
  • static step : str | None
  • static summary_omitted_fields : ClassVar[frozenset[str]]
  • static task_hash : str | None
  • static trigger : str | None
  • static wave_index : int | None

Methods​


summary​

def summary(self) ‑> str:

Say how the run crashed and where it had got to.

Returns One line for the log's message.

BackgroundDAGRunEvent​

class BackgroundDAGRunEvent(**data: Any):

Emitted at each observable moment of a background DAG deployment run.

A background run is submitted by the pod and executed minutes later by a subprocess the Prefect runner launches, so "how long did the DAG take?" is no longer the whole question — a run can be late because the runner was busy, because the run waited for its lineage lock or a machine slot ("started" measures that wait), or because the DAG itself is long. Three phases separate those, and no other signal does: the Prefect UI shows the states but not the waits between them, and a duration alone cannot say which of the three it was.

Known gap, accepted: a run cancelled while still queued never executes, so it never emits any of these. The start-up sweep is what accounts for those.

Attributes

  • phase: "picked_up" when the subprocess began executing, "started" when the DAG body began, "finished" when the run ended.
  • seconds: Seconds since the run was created, for "picked_up"; seconds spent waiting for the concurrency slot, for "started"; the run's own duration, for "finished".
  • status: How the run ended. Only meaningful on "finished".
  • error_type: The exception class that ended the run, when one did.
  • task_hash: The (pod, datasource) task hash of the run.
  • project_id: The project the run belongs to.
  • datasource_name: The datasource the run processes.
  • trigger: Why the run was started.
  • stop_reason: Why the run ended without carrying its work, on "finished"; None for a run that executed its DAG. A bitfount.runtimes.deployments.StopReason value — that enum is the single definition of the set and of what each member means, so this field deliberately does not re-list them. "sweep_unsettled" covers any run that landed while the scan sweep had not read the current inventory, whatever the ledger holds. The values set on a run that executed its DAG are the _STOPPED family plus RUN_TIME_CAP; everything else ends the run before it carries anything.
  • pid: The run's process id, on "picked_up".

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static datasource_name : str | None
  • static error_type : str | None
  • static model_config
  • static phase : str
  • static pid : int | None
  • static project_id : str | None
  • static seconds : float
  • static stop_reason : str | None
  • static task_hash : str | None
  • static trigger : str | None

Methods​


summary​

def summary(self) ‑> str:

Say which moment of the run this is and what seconds measured.

Returns One line for the log's message.

BackgroundRunEmptyEvent​

class BackgroundRunEmptyEvent(**data: Any):

Emitted when a background DAG run ends without running any step.

Sent when the run's file selection is empty, either before any scope step (reason="no_files_selected") or after one kept none of the files it was given (reason="scope_selected_none"). The run completes rather than fails.

indexing_completed separates the expected case from the one worth an alert: an empty selection before the datasource's first index completes is a cold start, whereas one after it means the inventory matches nothing this task admits.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static dag_name : str | None
  • static datetime : str | None
  • static files_considered : int | None
  • static indexing_completed : bool | None
  • static model_config
  • static project_id : str | None
  • static reason : str | None
  • static run_id : str | None
  • static scope_step : str | None
  • static task_hash : str | None
  • static trigger : str | None

BatchProgressEvent​

class BatchProgressEvent(**data: Any):

Emitted by the orchestrator at the start of each protocol batch.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static batch_number : int
  • static model_config
  • static protocol_name : str

CacheEncryptionKeyEvent​

class CacheEncryptionKeyEvent(**data: Any):

Emitted when a process looks up the key that encrypts its caches at rest.

Carries codes, the key's public id and a duration only, never key material or paths. A host whose key_id changes has a second key.

Attributes

  • action: "failed" when no usable key was found, else "resolved".
  • source: Where the key came from: "env", "env_file", "keychain", or "none".
  • outcome: "available", "unavailable" or "opted_out".
  • reason: Why no usable key was found, as a short code; None otherwise.
  • enforced: Whether this release refuses to run without a key.
  • desktop_app: Whether the desktop app started the process.
  • enabled: BITFOUNT_CACHE_ENCRYPTION_ENABLED as set, or None when it is unset and the release default applies.
  • key_id: The public id of the key that was found, even if it was refused for not matching the caches.
  • duration_seconds: How long the lookup took.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static action : str
  • static desktop_app : bool
  • static duration_seconds : float
  • static enabled : bool | None
  • static enforced : bool
  • static key_id : str | None
  • static model_config
  • static outcome : str
  • static reason : str | None
  • static source : str

CacheEncryptionMigrationEvent​

class CacheEncryptionMigrationEvent(**data: Any):

Emitted when the cache encryption sweep migrates a store, or can't.

Carries codes and counts only, never paths or key material. A store found already encrypted is only counted in CacheEncryptionSweepEvent.

Attributes

  • store_type: What the store is, e.g. "dataset_cache" or "project_db".
  • outcome: "migrated", "skipped_low_disk" or "failed".
  • reason: Why it failed, as a short code; None otherwise.
  • bytes: The store's size before migrating.
  • duration_seconds: How long it took.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static bytes : int
  • static duration_seconds : float
  • static model_config
  • static outcome : str
  • static reason : str | None
  • static store_type : str

CacheEncryptionSweepEvent​

class CacheEncryptionSweepEvent(**data: Any):

Emitted once per cache encryption sweep, whether or not it migrated any.

Carries codes and counts only, never paths or key material.

Attributes

  • enabled: BITFOUNT_CACHE_ENCRYPTION_ENABLED as set, or None when it is unset and the release default applies.
  • opted_out: Whether the site turned encryption off.
  • key_reason: Why nothing was migrated for want of a usable key, as a short code; None otherwise.
  • migrated: Stores migrated.
  • already_encrypted: Stores found already encrypted.
  • skipped_low_disk: Stores skipped for lack of disk space.
  • failed: Stores that couldn't be migrated, to be tried next start.
  • total_bytes: The migrated stores' total size before migrating.
  • duration_seconds: How long the sweep took.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static already_encrypted : int
  • static duration_seconds : float
  • static enabled : bool | None
  • static failed : int
  • static key_reason : str | None
  • static migrated : int
  • static model_config
  • static opted_out : bool
  • static skipped_low_disk : int
  • static total_bytes : int

CriteriaMatchingSummaryEvent​

class CriteriaMatchingSummaryEvent(**data: Any):

Emitted once per criteria_matching run, covering every criterion.

One event rather than one per criterion: a run's whole verdict is then readable in a single record, which is what an investigation into an over-strict config actually needs.

The cost of that shape is that criteria and tree_nodes are nested arrays, which Datadog cannot facet or graph on. The numbers worth alerting on are therefore duplicated as flat fields here — the root verdict counts, and the single worst blocking node.

NO PHI. Every field is a count, a configured value, or a schema name, with one exception. The observed value on a row, the codes a patient carried, the prose failure reason and the subject's identity are all excluded by construction, and no configured code string is emitted.

The exception is near_miss_codes: cohort codes that share a category with a configured one, each named only when at least criteria_near_miss_min_patients distinct patients carry it. Nothing on the event is per patient, so a code shared by that many cannot be traced to any one of them. A code fewer carry is counted, never named.

Attributes

  • rows_evaluated: Rows the run evaluated. Rows, not patients: on the file-system path the frame is scan-grain, so one patient's ten scans are ten rows. 0 with empty_reason set means the run had nothing to assess, which is not a verdict — see that field.
  • empty_reason: Why the run evaluated no rows, or None when it evaluated some. no_files_selected is expected and self-healing (a datasource still indexing). files_unreadable means files were selected and none could be loaded, which is unread data and needs someone to look. Both report criteria_yes: 0, and neither means nobody qualified.
  • criteria_yes: Rows where every criterion resolved to pass, the criteria_tree's own combined verdict among them. unknown does not match, so a row missing an input counts here exactly as a row that failed outright does — the two are told apart by rows_unknown on the criterion, not by this.
  • criteria_no: The rest.
  • criterion_count: Flat (non-tree) criteria evaluated, which is the length of criteria before truncation. A range field counts twice, once per bound. criteria_tree leaves are not included; they are counted by tree_leaf_count.
  • tree_node_count: Nodes in the criteria_tree, combinators included. Not-analysed criteria (manual nodes, and groups of them) are left out of this and of every other tree field: they are never evaluated, so there is nothing to count.
  • tree_leaf_count: Of those, leaves.
  • tree_depth: The tree's depth, counting a lone leaf as 1.
  • tree_shape: The tree's structure as a signature, e.g. and(or(code,code),not(column)). Config-derived, so a difference between two sites running the same trial is a config drift. A drift in the not-analysed criteria only does not show here.
  • tree_shape_truncated: Whether tree_shape was cut short. A tree's breadth is uncapped, so a wide generated one would otherwise render a string large enough to have the whole event truncated.
  • tree_outline: The same tree drawn as an indented outline, each node's counts beside it.

tree_nodes is flat so that every node sits at one attribute depth and a single query reaches all of them; the cost is that reading one run's tree means reassembling it from parent_node_id. This is that reassembly, done once, for a reader rather than a query.

  • tree_outline_truncated: Whether tree_outline was cut short.
  • tree_root_pass: Rows the tree's root resolved to pass.
  • tree_root_fail: Rows it resolved to fail.
  • tree_root_unknown: Rows it could not resolve.
  • worst_blocker_key: The node_key of the node that alone kept the most rows out — the highest rows_sole_blocker in the tree, promoted here so the headline is alertable without unrolling tree_nodes.

Ties break towards the deepest node, so a leaf is named ahead of the AndGroup containing it: both blocked the same rows, but the leaf is the criterion someone would go and loosen. Chosen across every node before tree_nodes is truncated, so a tree over the cap still names its blocker.

None when no node scored, which is the normal state of a healthy config, and also what a tree of OrGroups reports since nothing under one is ever solely responsible (see TreeNodeSummary.rows_sole_blocker).

  • worst_blocker_node_id: That node's node_id.
  • worst_blocker_evidence_id: That node's evidence_id, or None where it set none.
  • worst_blocker_group: That node's resolved group, or None.
  • worst_blocker_rows: That node's rows_sole_blocker. 0 exactly when worst_blocker_key is None.
  • dead_code_list_count: Inclusion criteria where every configured code matched nobody — the config asked for codes this cohort does not carry. Counts flat code-list criteria and criteria_tree code leaves of include polarity alike, each tier of an or on its own. Exclusion criteria are excluded from this count: one that excludes nobody is working, not misconfigured.
  • near_miss_criteria_count: Code-list criteria, flat or criteria_tree code leaves, with at least one near-miss code in the cohort — how many lists have a neighbouring code to look at, not how many codes there are.
  • criteria_truncated: Criteria omitted from criteria to bound the payload; 0 normally.
  • tree_nodes_truncated: Nodes omitted from tree_nodes for the same reason. Nodes are kept root-first, so what drops is the deepest detail rather than the structure above it.
  • criteria: Per-criterion aggregates for the flat criteria — one entry per comparison, so a range field appears twice.
  • tree_nodes: Per-node aggregates, in post-order (children before parents), so a reader meets a group's inputs before the group.

Flat rather than nested on purpose: every node sits at the same attribute depth, so one query reaches all of them across runs. tree_outline carries the shape for reading.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static criteria_no : int
  • static criteria_truncated : int
  • static criteria_yes : int
  • static criterion_count : int
  • static dead_code_list_count : int
  • static empty_reason : str | None
  • static model_config
  • static near_miss_criteria_count : int
  • static rows_evaluated : int
  • static tree_depth : int
  • static tree_leaf_count : int
  • static tree_node_count : int
  • static tree_nodes_truncated : int
  • static tree_outline : str | None
  • static tree_outline_truncated : bool
  • static tree_root_fail : int
  • static tree_root_pass : int
  • static tree_root_unknown : int
  • static tree_shape : str | None
  • static tree_shape_truncated : bool
  • static worst_blocker_evidence_id : str | None
  • static worst_blocker_group : str | None
  • static worst_blocker_key : str | None
  • static worst_blocker_node_id : str | None
  • static worst_blocker_rows : int

Methods​


summary​

def summary(self) ‑> str:

Give the run's verdict, then what most held it back.

Returns One line for the log's message.

CriterionSummary​

class CriterionSummary(**data: Any):

One criterion's aggregate outcome across a criteria_matching run.

Counts only. The observed value a row carried, the codes it matched and the prose reason it failed are all deliberately absent — see CriteriaMatchingSummaryEvent for why.

Attributes

  • output_field: The criterion's logical field name, as the served evidence keys it. Not unique on its own: a range field contributes one entry per bound, both under this name.
  • column_name: The flat column name the filter writes. For a ColumnFilter this embeds the comparison — "Age (yrs) >= 50" — which is what keeps a range's two bounds apart as separate entries.
  • operator: The comparison operator as the filter was built with it. Either a symbol (">=") or the English spelling a task config may use ("greater than or equal"); both appear. A code-list criterion reports "code_match", which is not an ordering comparison and so never produces rows_failed_near_bound. None for a filter with no named comparison at all.
  • operand: The configured right-hand side of a scalar comparison. None for a code-list criterion, whose operand is the whole configured list: configured_code_count reports its length instead, so a few hundred codes are not repeated into every event.
  • grain: patient, organ or scan — where the verdict is decided. Events sent before organ existed say scan for an eye-scoped EHR criterion.
  • provenance: scan, ehr, supplied or unknown — the source axis.
  • family: The semantic family (code_list, scan_metric, ...), or None when the producing filter declared none.
  • rows_pass: Rows the criterion passed. Rows, not patients: on the file-system path the frame is scan-grain, so a patient with ten scans counts ten times. The same holds for every rows_* field here.
  • rows_fail: Rows it failed — evaluated, and the answer was no.
  • rows_unknown: Rows it could not evaluate. For a code-list criterion this means the patient had no code data at all, which is missing input rather than a verdict — read it apart from rows_fail.
  • rows_absent_column: Rows whose target column was absent from the frame entirely, as opposed to present and null.

Only a ColumnFilter sets this. A code-list criterion is a MethodFilter and never does, so 0 there does not mean its column was present — check configured_codes_matching_nobody being None, which is how an absent code column shows up.

  • rows_failed_near_bound: Rows that failed an ordering comparison but came within 10% of passing it: abs(value - operand) <= 0.1 * abs(operand). With an operand of 0, where that fraction has no meaning, only an exact 0 counts.

Counts failures only — a row that could not be evaluated is not near anything. None for a criterion with no ordering comparison, which is different from 0 (an ordering comparison where nothing landed close).

A high count against a low rows_pass is the signature of a threshold set slightly too tight: rows_fail: 332 with rows_failed_near_bound: 301 says almost everyone who failed failed narrowly.

  • configured_code_count: How many codes the criterion's configured list holds. Patterns count as one each, so a single H35.3* covering twelve real codes counts once. Includes the _study_eye counterpart list where the criterion has one, since a code configured in either was genuinely configured. None for a non-code criterion.
  • configured_codes_matching_nobody: How many of those matched no code the cohort carried. Equal to configured_code_count means no patient carried any configured code — with the filters' OR semantics, that is a dead list rather than a demanding one.

Read it with the criterion's direction in mind. On an inclusion criterion it is the too-strict signal. On an exclusion criterion it means nobody was excludable, which is normal and is why dead_code_list_count counts inclusion criteria only.

None means it could not be established, never that nothing was

  • dead: the criterion's code column was absent from the frame (the data was never read), or the cohort scan did not run because enable_criteria_near_miss_counts is off, which leaves an exclusion criterion with no source for it at all.
  • near_miss_code_count: Distinct codes present in the cohort that matched no configured pattern but share an ICD-10 category (the first three characters) with one.

None when the pass did not run, and also on a procedure

  • criterion: those columns mix CPT/HCPCS with ICD-10-PCS, where a three-character prefix groups nothing, so no count is reported rather than an arbitrary one.
  • near_miss_row_count: Rows carrying at least one such code. Rows, not
  • patients: on the file-system path the frame is scan-grain, so a patient with ten scans counts ten times.
  • near_miss_codes: The near-miss codes themselves, each with how many distinct patients carry it — what to add to the list, where near_miss_code_count only says that something is missing.

A code is named only when at least criteria_near_miss_min_patients patients carry it; a rarer one is left out entirely, so the list can be shorter than near_miss_code_count. Capped at the ten most carried, most first. None wherever near_miss_code_count is, and also when the frame has no patient-id column to count patients by.

  • unknown_reasons: How many of rows_unknown gave each reason, keyed by UnknownReasonCode value (not_in_ehr, ehr_unavailable, value_missing, ...). Separates "the EHR never answered" from "it answered without the data", which rows_unknown alone cannot. A row that gave no reason is counted under unspecified. Empty when nothing was unknown.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static column_name : str
  • static configured_code_count : int | None
  • static configured_codes_matching_nobody : int | None
  • static family : str | None
  • static grain : str
  • static model_config
  • static near_miss_code_count : int | None
  • static near_miss_codes : list[bitfount.telemetry.logs.models.NearMissCode] | None
  • static near_miss_row_count : int | None
  • static operand : Any
  • static operator : str | None
  • static output_field : str
  • static provenance : str
  • static rows_absent_column : int
  • static rows_fail : int
  • static rows_failed_near_bound : int | None
  • static rows_pass : int
  • static rows_unknown : int

DAGExecutionTimeEvent​

class DAGExecutionTimeEvent(**data: Any):

Emitted with the wall-clock time of a DAG step or executor entry point.

Exactly one of step_name or function identifies what was timed: steps carry step_name, the executor's own entry points carry function (and class_name when the callable is a method).

status says how the timed work ended - "success", "error" or "cancelled" - because the timing is emitted whether it succeeded or not, and a duration alone cannot tell a step that finished from one that died partway through. error_type names the exception class for the two non-success outcomes, so a dashboard can separate a timeout from a crash without a second query. It defaults to success rather than being required, because an event must never raise when constructed. It serialises as execution_status: Datadog reads a status attribute as the log's severity, which the handler sets from the record's level, and two producers for one attribute means one of them loses.

The volume fields divide by who can answer. A step timing carries files_processed / patients_processed - work done by that one invocation, reported by the step itself. The executor's own entry-point timings carry files_in_scope instead, the run's denominator: summing the per-step counts would double-count, since every file-scoped step sees the same files.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static class_name : str | None
  • static duration_seconds : float
  • static error_type : str | None
  • static files_in_scope : int | None
  • static files_processed : int | None
  • static function : str | None
  • static model_config
  • static patients_processed : int | None
  • static step_name : str | None
  • static task_hash : str | None

Methods​


summary​

def summary(self) ‑> str:

Say what was timed, how long it took and how it ended, then its volume.

Returns One line for the log's message.

DAGSweepSummaryEvent​

class DAGSweepSummaryEvent(**data: Any):

Emitted once when a waved background DAG run finishes its sweep.

Attributes

  • dag_name: The DAG being run.
  • waves_planned: Waves the run planned.
  • waves_banked: Waves that completed.
  • waves_failed: Waves attempted and abandoned.
  • waves_unstarted: Waves left for a later run.
  • stop_reason: Why the loop stopped early (budget, standing aside), or "no_waves" when nothing was planned; None when it ran every planned wave.
  • duration_seconds: How long the sweep took, from its first wave to its last.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static dag_name : str
  • static duration_seconds : float
  • static model_config
  • static stop_reason : str | None
  • static waves_banked : int
  • static waves_failed : int
  • static waves_planned : int
  • static waves_unstarted : int

Methods​


summary​

def summary(self) ‑> str:

Say how many of the planned waves the sweep banked, and why it stopped.

Returns One line for the log's message.

DAGWaveEvent​

class DAGWaveEvent(**data: Any):

Emitted when one attempt at a background DAG wave ends.

outcome is "banked" for a wave that completed, "attempt_failed" for a failed attempt that will be retried, and "abandoned" once the retries are spent (its files stay outstanding for the next run).

Attributes

  • dag_name: The DAG being run.
  • outcome: How the attempt ended: "banked", "attempt_failed", "abandoned", or "stood_down" when the run stopped at the wave because its EHR step could not reach the EHR.
  • wave_index: The wave's position in its sweep, from 1.
  • attempt: This attempt's number, from 1.
  • attempts: How many attempts the wave is allowed.
  • waves_planned: Waves the sweep planned, so wave_index reads as n of N.
  • files: Files in the wave.
  • patient_count: Distinct patients the wave's files belong to.
  • wave_kind: "first_carry", "refresh" or "orphan".
  • duration_seconds: How long the attempt took.
  • prefect_subflow: Whether the wave ran as its own Prefect subflow run; False when creating one failed and the wave ran without it.
  • error_type: The exception class, for a failed attempt.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static attempt : int
  • static attempts : int
  • static dag_name : str
  • static duration_seconds : float
  • static error_type : str | None
  • static files : int
  • static model_config
  • static outcome : str
  • static patient_count : int
  • static prefect_subflow : bool
  • static wave_index : int
  • static wave_kind : str
  • static waves_planned : int

Methods​


summary​

def summary(self) ‑> str:

Say how the wave attempt ended, then what the wave carried.

Returns One line for the log's message.

DatadogLogsHandler​

class DatadogLogsHandler(    api_instance: LogsApi,    source: str,    hostname: str,    service: str,    tags: list[str] | None = None,    capacity: int = 1000,    flush_interval_seconds: float = 0.0,):

A MemoryHandler that sends logs to Datadog.

This handler automatically flushes when the buffer approaches a 5MB limit. These numbers are taken from Datadog's Logs API documentation: https://docs.datadoghq.com/api/latest/logs/

We piggyback off Python's MemoryHandler class since we do not want to implement our own buffer management system, including what happens when there are records left in the buffer when the handler is closed.

Initialize the DatadogMemoryHandler.

Arguments

  • api_instance: The Datadog API instance.
  • source: The source of the logs.
  • hostname: The hostname of the logs.
  • service: The service of the logs.
  • tags: The tags of the logs.
  • capacity: The capacity of the buffer, defaulted to 1000 according to Datadog's documentation.
  • flush_interval_seconds: How often to flush the buffer regardless of how full it is. Defaults to no periodic flush; the production path is setup_datadog_telemetry, which passes the configured interval.

Variables​

  • static BUFFER_PERCENTAGE
  • static MAX_BUFFER_SIZE

Methods​


close​

def close(self) ‑> None:

Stop the periodic flush, then flush and close the handler.

The flusher is signalled but not waited for: logging.shutdown calls this while holding the handler, and a flush already in flight cannot finish until that caller returns. shutdown_datadog_* stops the flusher properly first, so the orderly path loses nothing.

emit​

def emit(self, record: logging.LogRecord) ‑> None:

Emit a record to the buffer.

Note that we immediately build the HTTPLogItem object and add it to a separate buffer, rather than waiting for the flush operation to do so.

Arguments

  • record: The log record.

flush​

def flush(self) ‑> None:

Flush the buffer by sending all records to Datadog in a single request.

Override the parent's flush method to flush records instead of calling emit() per record.

shouldFlush​

def shouldFlush(self, record: logging.LogRecord, item_size: int = 0) ‑> bool:

Determine if we should flush the buffer.

Arguments

  • record: The log record.
  • item_size: The size of the item to add to the buffer.

Returns True if we should flush the buffer, False otherwise.

DatasetConnectedEvent​

class DatasetConnectedEvent(**data: Any):

Emitted once per datasource when a pod successfully connects it.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static connection_datetime : str
  • static dataset_name : str
  • static datasource_type : str
  • static model_config

DocumentAcuityEvent​

class DocumentAcuityEvent(**data: Any):

Emitted once per background ehr_criteria_query run that considered documents.

Sent when any count is non-zero: for a run that read patients' documents for visual acuity, that left their CCDs undownloaded because the Observations held both eyes' newest best-corrected readings, that skipped the acuity code searches at a site marked as serving acuity only in documents, or that carried CCD readings forward.

Counts what reading visual acuity from patients' CCD documents did across every patient in the run, how many patients' Observations gave a best-corrected reading for one or both eyes and what that did to the documents read, and what the run carried forward from stored rows when a CCD fetch failed. Counts and masked shapes only: never document text, a display, a document ID or a patient.

Attributes

  • documents_listed: Documents the EHR listed for the patient, across patients.
  • type_filter_used: Listings that filtered by document type.
  • type_filter_refused: Type-filtered listings the server refused.
  • type_filter_empty_fallback: Type-filtered listings that came back empty and were repeated unfiltered.
  • listing_capped: Listings cut off at the reader's document limit.
  • listing_unsupported: Patients whose server serves no document listing, so the search was left undone.
  • candidates_type_code: Candidate documents picked by a document type code.
  • candidates_name: Candidate documents picked by a CCD name in their type or description.
  • candidates_format: Candidate documents picked by a C-CDA format.
  • candidates_xml_only: Candidate documents picked only because a rendition is XML (weak candidates).
  • near_miss: Weak candidates with type text that names no CCD. Each is tried; one that turns out not to be a CDA leaves the search complete.
  • ccd_no_xml_rendition: Documents typed or named as a CCD with no XML or untyped rendition to read (such as a CCD served only as a PDF), which are not read.
  • no_candidate: Patients with no CCD candidate.
  • ccd_not_newer: Patients whose Observations gave a best-corrected reading for both eyes and whose listed CCD candidates were all dated before the older of the two readings, so no CCD was downloaded.
  • ccd_may_be_newer: Patients whose Observations gave a best-corrected reading for both eyes and who had a CCD candidate dated on or after the older of the two readings, or undated, so their CCDs were read.
  • documents_tried_capped: Patients whose search stopped at the reader's limit of documents tried with an eye uncovered and candidates left untried, so the search ended incomplete.
  • ccds_tried_1: Patients for whom one CCD was tried: a candidate document that parsed as a CDA or failed. A weak candidate that was not a CDA is not counted.
  • ccds_tried_2: Patients for whom two CCDs were tried, counted as for ccds_tried_1.
  • ccds_tried_3: Patients for whom three CCDs were tried, counted as for ccds_tried_1.
  • ccds_parsed: Documents parsed as C-CDA.
  • binaries_fetched: Document renditions downloaded.
  • older_ccd_used: Patients whose acuity came from a CCD older than the newest CCD tried.
  • binary_failed: Document renditions that failed to download.
  • status_not_xml: Renditions that were not XML.
  • status_not_cda: Renditions that were XML but not C-CDA.
  • status_parse_error: Renditions that failed to parse.
  • ccd_without_acuity: Parsed CCDs that held no acuity reading.
  • ccd_unextractable: Parsed CCDs with acuity candidates none of which could be read.
  • incomplete: Patients whose CCD search ended incomplete.
  • observations_seen: Observation entries seen in parsed CCDs.
  • candidates_known_code: Acuity candidates found by a known acuity code.
  • candidates_study_code: Acuity candidates found by LOINC 28631-0 "Visual acuity study", with no known acuity code.
  • candidates_display_only: Acuity candidates found only by their display text.
  • value_st: Candidate values given as a string.
  • value_pq: Candidate values given as a physical quantity.
  • value_cd: Candidate values given as a coded concept.
  • value_inline_text: Candidate values given as inline text.
  • value_reference: Candidate values given as a reference into the document.
  • reference_unresolved: Value references that resolved to nothing.
  • eye_display: Candidates whose eye came from their display.
  • eye_target_site: Candidates whose eye came from their target site.
  • eye_text: Candidates whose eye came from their text.
  • eye_none: Candidates whose eye could not be told.
  • effective_time_missing: Candidates with no effective time.
  • effective_time_unparsed: Candidates whose effective time did not parse.
  • negated_skipped: Candidates skipped as negated.
  • nullified_skipped: Candidates skipped as nullified.
  • patients_attempted: Patients whose documents were searched for acuity.
  • patients_unavailable: Patients whose documents could not be searched.
  • patients_incomplete: Patients whose document search ended incomplete.
  • patients_answered: Patients whose document search completed.
  • patients_observations_both_eyes: Patients whose Observations gave a best-corrected reading for both eyes, so their documents were listed and their CCDs read only if one may be newer (ccd_not_newer, ccd_may_be_newer).
  • patients_observations_one_eye: Patients whose Observations gave a best-corrected reading for one eye; their documents were read.
  • patients_acuity_searches_skipped: Patients whose acuity code searches were skipped because the server is marked as serving acuity only in documents.
  • ccd_carried_forward: Records given a stored row's CCD readings after a failed CCD fetch.
  • ccd_carry_forward_none: Records with a failed CCD fetch and no good stored row to carry from: none, another EHR patient's, one whose own CCD search failed, or one holding no CCD reading.
  • shapes: The most frequent masked shapes (display, element path, candidate code or near-miss type) seen, and the media types of the renditions of a CCD with no XML rendition, to their count. Capped at BCVA_NON_ACUITY_CODES_LIMIT.
  • task_hash: The step's partition.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static binaries_fetched : int
  • static binary_failed : int
  • static candidates_display_only : int
  • static candidates_format : int
  • static candidates_known_code : int
  • static candidates_name : int
  • static candidates_study_code : int
  • static candidates_type_code : int
  • static candidates_xml_only : int
  • static ccd_carried_forward : int
  • static ccd_carry_forward_none : int
  • static ccd_may_be_newer : int
  • static ccd_no_xml_rendition : int
  • static ccd_not_newer : int
  • static ccd_unextractable : int
  • static ccd_without_acuity : int
  • static ccds_parsed : int
  • static ccds_tried_1 : int
  • static ccds_tried_2 : int
  • static ccds_tried_3 : int
  • static documents_listed : int
  • static documents_tried_capped : int
  • static effective_time_missing : int
  • static effective_time_unparsed : int
  • static eye_display : int
  • static eye_none : int
  • static eye_target_site : int
  • static eye_text : int
  • static incomplete : int
  • static listing_capped : int
  • static listing_unsupported : int
  • static model_config
  • static near_miss : int
  • static negated_skipped : int
  • static no_candidate : int
  • static nullified_skipped : int
  • static observations_seen : int
  • static older_ccd_used : int
  • static patients_acuity_searches_skipped : int
  • static patients_answered : int
  • static patients_attempted : int
  • static patients_incomplete : int
  • static patients_observations_both_eyes : int
  • static patients_observations_one_eye : int
  • static patients_unavailable : int
  • static reference_unresolved : int
  • static shapes : dict[str, int]
  • static status_not_cda : int
  • static status_not_xml : int
  • static status_parse_error : int
  • static task_hash : str | None
  • static type_filter_empty_fallback : int
  • static type_filter_refused : int
  • static type_filter_used : int
  • static value_cd : int
  • static value_inline_text : int
  • static value_pq : int
  • static value_reference : int
  • static value_st : int

EHRElementReadsEvent​

class EHRElementReadsEvent(**data: Any):

Emitted once per ehr_criteria_query run that met an element it could not use.

Also sent when a fallback read an element, so a site whose eyes are read from BodyStructure references shows it on every run. Shapes and counts only: never a value, a patient or a resource ID. The lists are lists rather than mappings because a shape holds dots and braces, which a Datadog attribute name cannot.

Attributes

  • unread: The most frequent unread elements, most frequent first, at most EHR_ELEMENT_READS_LIMIT of them.
  • unread_total: Unread elements across every shape, listed or not.
  • recovered: Elements read through a fallback, most frequent first.
  • stated_absent: Elements the EHR stated there is no value for, most frequent first, by the reason it gave.
  • stated_absent_total: Stated-absent elements, listed or not.
  • task_hash: The step's partition.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static model_config
  • static stated_absent : list[bitfount.telemetry.logs.models.StatedAbsentElementCount]
  • static stated_absent_total : int
  • static task_hash : str | None
  • static unread_total : int

EHRLookupSummary​

class EHRLookupSummary(**data: Any):

Aggregate EHR lookup outcomes for one ehr_criteria_query run.

Counts only, per patient, except the skipped_* fields, which count rows. No name, date of birth, MRN, patient hash, code or exception message is carried: fetch_failed_by_error holds exception class names, not_found_shapes holds fixed flag names, and backend and provider are configured values.

Attributes

  • backend: The EHR querier type ("fhir r4" or "nextgen").
  • provider: The configured EHR provider (for example "modmed_r4").
  • queried: Patients the EHR was asked about this run.
  • matched: Patients whose lookup built a usable record. Counted before drop_ambiguous_patients, so a patient withheld from the cache as ambiguous at store time is still counted here.
  • unrecordable: Patients the EHR returned but for whom no record could be built, for example because no BitfountPatientID was derivable. Neither matched nor failed.
  • matched_by_strategy: Search that found each matched patient (name_dob, first_given_name or mrn on the filename route, patient_id on the patient-ID route) to count.
  • identity_rejected_by_strategy: Fallback search that found a patient whose identity did not match the scan, to the number of patients rejected that way.
  • fallback_ambiguous_by_strategy: Fallback search that matched more than one patient, to the number of patients it did so for. Such a fallback finds nobody: the patient keeps the name search's not_in_ehr and is not in ambiguous_match.
  • fallback_errored_by_strategy: Fallback search that failed with an error other than an authentication one, to the number of patients it failed for. Such a fallback finds nobody: the patient keeps the name search's not_in_ehr and is not in fetch_failed.
  • name_dob_identity_check: Identity check outcome on the name and date of birth search's hit (match, given_names_differ, first_given_differs, family_differs, sex_differs, dob_differs or unchecked) to the number of patients. Counted for every patient that search found, before their record is fetched; never enforced, so the hit is used whatever the outcome. Fallback hits, which are checked and rejected on a mismatch, are not counted here.
  • not_in_ehr: Patients the EHR answered "no such patient" for.
  • ambiguous_match: Patients whose search matched more than one record.
  • auth_rejected: Patients whose lookup the EHR rejected as unauthenticated.
  • fetch_failed: Patients whose lookup failed for any other reason, including those whose record holds demographics but every supported fetch group failed.
  • not_found_rate: (not_in_ehr + ambiguous_match) / queried, or None when nobody was queried.
  • fetch_failed_by_error: Exception class name to number of fetch_failed patients, capped at 20 names plus "other".
  • not_found_shapes: Name-shape flag to number of not-found patients carrying it. Name searches only.
  • records: Records this run built, negative rows included; the denominator for source_states.
  • source_states: Source to fetch state to number of this run's records in that state. Only sources that did not answer are counted: a record that fetched every source stores no states.
  • forbidden_sources: FHIR resource type to number of HTTP 403 responses during this step invocation.
  • skipped_incomplete_name: Rows whose name lacked a given or family part.
  • skipped_unparseable_dob: Rows whose date of birth could not be parsed.
  • skipped_non_patient_name: Rows whose name read as device text.
  • groups_unsupported: Fetch groups the backend reported as unsupported.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static ambiguous_match : int
  • static auth_rejected : int
  • static backend : str | None
  • static fallback_ambiguous_by_strategy : dict[str, int]
  • static fallback_errored_by_strategy : dict[str, int]
  • static fetch_failed : int
  • static fetch_failed_by_error : dict[str, int]
  • static forbidden_sources : dict[str, int]
  • static groups_unsupported : list[str]
  • static identity_rejected_by_strategy : dict[str, int]
  • static matched : int
  • static matched_by_strategy : dict[str, int]
  • static model_config
  • static name_dob_identity_check : dict[str, int]
  • static not_found_rate : float | None
  • static not_found_shapes : dict[str, int]
  • static not_in_ehr : int
  • static provider : str | None
  • static queried : int
  • static records : int
  • static skipped_incomplete_name : int
  • static skipped_non_patient_name : int
  • static skipped_unparseable_dob : int
  • static source_states : dict[str, dict[str, int]]
  • static unrecordable : int

EHRQueryCompleteEvent​

class EHRQueryCompleteEvent(**data: Any):

Emitted after an EHR patient query batch completes.

Fires once per protocol batch in EHR-enabled algorithms. Provides visibility into the per-batch EHR query phase, which is otherwise the longest silent stretch during task execution.

The patients_* outcome counts are per input row, like the per-patient loop that produces them; patients_queried and records_found count unique patients.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static config_type : str
  • static model_config
  • static patients_auth_failed : int
  • static patients_errored : int
  • static patients_not_found : int
  • static patients_queried : int
  • static records_found : int

EHRQueryOutcomeEvent​

class EHRQueryOutcomeEvent(**data: Any):

Emitted once per background ehr_criteria_query step run.

run_outcome is the step's EHRRunOutcome value: "primed", "degraded_partial", "degraded_total" or "not_configured".

Attributes

  • run_outcome: How well the run primed the EHR cache.
  • ehr_availability: What the preflight probe found, when one ran.
  • ehr_preflight_error: Why the preflight's final attempt failed, as exception types and HTTP statuses only, e.g. "AuthenticationError <- HTTPError (status 404)". None when no probe ran or the EHR answered.
  • ehr_preflight_attempts: Probes the preflight made, when one ran.
  • records_stored: EHR rows this run persisted.
  • skipped_total_failure: Patients served from an older row.
  • skipped_unidentified: Patients with no identity to query by.
  • skipped_fresh: Patients whose stored row was still fresh.
  • task_hash: The step's partition.
  • lookups: Per-patient lookup outcomes, None when the step never reached the lookup loop (EHR not configured, preflight unavailable) or the summary could not be built. Covers only the patients this run asked about, which on a rerun are the ones whose stored row was not fresh: mostly earlier misses.
  • stored_patients: Patients the partition holds a row for after this run, across every run that wrote to it. None when the count could not be read.
  • stored_states: stored_patients split by state: "matched" for a patient the EHR found, otherwise the row's error value (for example "not_in_ehr"). The share of the cohort linked to the EHR is stored_states["matched"] / stored_patients, which lookups cannot give. None when the counts could not be read.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static ehr_availability : str | None
  • static ehr_preflight_attempts : int | None
  • static ehr_preflight_error : str | None
  • static model_config
  • static records_stored : int
  • static run_outcome : str
  • static skipped_fresh : int
  • static skipped_total_failure : int
  • static skipped_unidentified : int
  • static stored_patients : int | None
  • static stored_states : dict[str, int] | None
  • static task_hash : str | None

Methods​


summary​

def summary(self) ‑> str:

Say how the run went and why, then what it stored and matched.

Returns One line for the log's message.

EHRScreeningBatchEvent​

class EHRScreeningBatchEvent(**data: Any):

Emitted after each EHR screening page is queried and eligibility-matched.

Fires once per page, so a screening run sends one per page it queries.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static model_config
  • static page_eligible : int
  • static page_number : int
  • static page_size : int
  • static project_id : str | None
  • static task_id : str
  • static total_eligible : int

EHRSessionInitialisedEvent​

class EHRSessionInitialisedEvent(**data: Any):

Emitted after a NextGen or FHIR R4 EHR session is set up.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static config_type : str
  • static model_config

Methods​


summary​

def summary(self) ‑> str:

Say which EHR the session is with.

Returns One line for the log's message.

EHRTokenRefreshedEvent​

class EHRTokenRefreshedEvent(**data: Any):

Emitted after a FHIR client access token is refreshed.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static config_type : str
  • static model_config

ExecutionStatus​

class ExecutionStatus(*args, **kwds):

How a timed piece of DAG work ended.

CANCELLED is kept apart from ERROR because the pod cancels in-flight work on shutdown and redeploy, and counting those as failures would bury the real ones.

Inherits from str so values serialise directly as JSON strings.

Variables​

  • static CANCELLED
  • static ERROR
  • static SUCCESS

FileMultiSeriesSummaryEvent​

class FileMultiSeriesSummaryEvent(**data: Any):

Aggregated count of files whose matching series were cut to one row.

Replaces one event per reduced file, and is sent at the same points as FileSkipSummaryEvent.

Attributes

  • datasource_type: Class name of the datasource that reduced the files.
  • dataset_name: The datasource's configured name.
  • trigger: What closed the window: "pass_end", "task_end" or "interval".
  • window_seconds: Length of the window the counts cover.
  • files_reduced: Files that produced more than one matching row.
  • rows_dropped: Rows discarded across those files.
  • by_laterality: Files reduced, keyed by configured laterality.
  • by_series_protocol: Files reduced, keyed by configured series protocol.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static by_laterality : dict[str, int]
  • static by_series_protocol : dict[str, int]
  • static dataset_name : str | None
  • static datasource_type : str
  • static files_reduced : int
  • static model_config
  • static rows_dropped : int
  • static trigger : str
  • static window_seconds : float

FileSkipSummaryEvent​

class FileSkipSummaryEvent(**data: Any):

Aggregated count of files a datasource skipped over one window.

Replaces one event per skipped file. Emitted at the end of each file-listing pass, at each task boundary, and periodically during a long pass, so a window covers whatever was skipped since the previous summary.

Attributes

  • datasource_type: Class name of the datasource that skipped the files.
  • dataset_name: The datasource's configured name.
  • trigger: What closed the window: "pass_end", "task_end" or "interval".
  • window_seconds: Length of the window the counts cover.
  • total_skipped: Files skipped in the window.
  • by_reason: Counts keyed by FileSkipReason name.
  • by_source: Counts keyed by skip source: "datasource" for skips persisted to the cache, "task" for task-scoped skips.
  • by_extension: Counts keyed by file extension ("" when none).
  • sample_files: Up to a few redacted file names per reason.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static by_extension : dict[str, int]
  • static by_reason : dict[str, int]
  • static by_source : dict[str, int]
  • static dataset_name : str | None
  • static datasource_type : str
  • static model_config
  • static sample_files : dict[str, list[str]]
  • static total_skipped : int
  • static trigger : str
  • static window_seconds : float

Methods​


summary​

def summary(self) ‑> str:

Say how many files were skipped over the window, and mostly why.

No file name is included, not even the redacted samples.

Returns One line for the log's message.

FilteringCompleteEvent​

class FilteringCompleteEvent(**data: Any):

Emitted after RecordFilterAlgorithm.setup_run() finishes selecting files.

Fires once per task, before the first batch begins. Provides visibility into how many files were considered and how many passed the filter criteria.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static files_selected : int
  • static model_config
  • static total_files : int

GpuUsageEvent​

class GpuUsageEvent(**data: Any):

Emitted once per model_inference invocation that ran inference.

Summarises the GPU over the step's working window, from the model load to the end of the chunk loop: whether one is present, whether torch put work on it, and the mean and maximum of its compute and memory utilisation. One event per invocation rather than per sample, so the volume does not grow with how long inference takes.

Utilisation and device memory come from NVML and describe the whole device, not this process. The torch_* fields say what torch itself did. A fully-cached invocation does no GPU work and emits nothing.

Attributes

  • step_name: The step that was sampled.
  • model_ref: Which model ran.
  • model_class: Class name of the loaded model, which separates a torch model from one on another runtime (e.g. ONNX) when NVML shows load but torch did not use the GPU.
  • task_hash: The step's partition.
  • run_id: The flow run.
  • duration_seconds: Length of the sampled window.
  • status: How the step ended.
  • error_type: Exception class name when the step did not succeed.
  • gpu_present: Whether a GPU was found. None when it could not be determined, e.g. no NVIDIA driver library.
  • gpu_count: GPUs NVML reports.
  • gpu_name: Name of the sampled device.
  • gpu_memory_total_bytes: Total memory of the sampled device.
  • nvml_driver_version: NVIDIA driver version.
  • gpu_probe_error: Exception class name when probing for a GPU failed.
  • torch_cuda_build: CUDA version torch was built with; None for a CPU-only build.
  • torch_cuda_available: torch.cuda.is_available().
  • torch_device: Device the SDK selects for torch models: cuda, mps or cpu.
  • torch_used_gpu: Whether torch allocated GPU memory during the window.
  • torch_gpu_memory_peak_bytes: Peak GPU memory torch allocated during the window; on MPS, the driver's allocation at the window's end.
  • gpu_utilisation_mean_pct: Mean device compute utilisation.
  • gpu_utilisation_max_pct: Maximum device compute utilisation.
  • gpu_memory_used_mean_bytes: Mean device memory in use.
  • gpu_memory_used_max_bytes: Maximum device memory in use.
  • sample_count: Samples the utilisation figures are built from.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static duration_seconds : float | None
  • static error_type : str | None
  • static gpu_count : int | None
  • static gpu_memory_total_bytes : int | None
  • static gpu_memory_used_max_bytes : int | None
  • static gpu_memory_used_mean_bytes : float | None
  • static gpu_name : str | None
  • static gpu_present : bool | None
  • static gpu_probe_error : str | None
  • static gpu_utilisation_max_pct : float | None
  • static gpu_utilisation_mean_pct : float | None
  • static model_class : str | None
  • static model_config
  • static model_ref : str | None
  • static nvml_driver_version : str | None
  • static run_id : str | None
  • static sample_count : int
  • static step_name : str
  • static task_hash : str | None
  • static torch_cuda_available : bool | None
  • static torch_cuda_build : str | None
  • static torch_device : str | None
  • static torch_gpu_memory_peak_bytes : int | None
  • static torch_used_gpu : bool | None

GpuUsageSampler​

class GpuUsageSampler(interval_seconds: float = 1.0):

Samples GPU utilisation over a window of work.

Use as a context manager, or call start and stop directly when the window does not match a block; both are idempotent. Never raises: every probe and sample failure is logged at debug level and leaves the affected fields empty.

A no-op when settings.enable_gpu_telemetry is False.

Arguments

  • interval_seconds: Time between samples.

Variables​

  • duration_seconds : float | None - Length of the sampled window, once stopped.
  • enabled : bool - Whether this sampler is collecting, as decided at start.

Methods​


start​

def start(self) ‑> None:

Probe for a GPU and begin sampling.

stop​

def stop(self) ‑> None:

Stop sampling and read torch's own figures for the window.

summary​

def summary(self) ‑> GpuUsageSummary:

Summarise what was observed so far.

Returns The summary; all fields empty when the sampler is disabled.

GpuUsageSummary​

class GpuUsageSummary(    gpu_present: bool | None = None,    gpu_count: int | None = None,    gpu_name: str | None = None,    gpu_memory_total_bytes: int | None = None,    nvml_driver_version: str | None = None,    gpu_probe_error: str | None = None,    torch_cuda_build: str | None = None,    torch_cuda_available: bool | None = None,    torch_device: str | None = None,    torch_used_gpu: bool | None = None,    torch_gpu_memory_peak_bytes: int | None = None,    gpu_utilisation_mean_pct: float | None = None,    gpu_utilisation_max_pct: float | None = None,    gpu_memory_used_mean_bytes: float | None = None,    gpu_memory_used_max_bytes: int | None = None,    sample_count: int = 0,):

What a GpuUsageSampler observed over its window.

Field meanings match the same-named fields on GpuUsageEvent. A field the sampler could not determine is None.

Variables​

  • gpu_count : int | None
  • gpu_memory_total_bytes : int | None
  • gpu_memory_used_max_bytes : int | None
  • gpu_memory_used_mean_bytes : float | None
  • gpu_name : str | None
  • gpu_present : bool | None
  • gpu_probe_error : str | None
  • gpu_utilisation_max_pct : float | None
  • gpu_utilisation_mean_pct : float | None
  • nvml_driver_version : str | None
  • sample_count : int
  • torch_cuda_available : bool | None
  • torch_cuda_build : str | None
  • torch_device : str | None
  • torch_gpu_memory_peak_bytes : int | None
  • torch_used_gpu : bool | None

GroupingSummaryEvent​

class GroupingSummaryEvent(**data: Any):

Aggregate Datadog event for grouping-aware batching behaviour.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static batch_size : int | None
  • static cached_files : int | None
  • static group_count : int | None
  • static include_non_new_group_files : bool | None
  • static maybe_final : bool | None
  • static model_config
  • static oversized_cohort_size : int | None
  • static selected_files : int | None
  • static step : str

HostCacheKeyEvent​

class HostCacheKeyEvent(**data: Any):

Emitted when a process asks for the host's cache key.

Carries the outcome and a short reason code only, never key material.

Attributes

  • outcome: "available" or "unavailable".
  • reason: Why the key was unavailable, as a short code; None otherwise.
  • fetch_seconds: Time the request for the key took, if one was made.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static fetch_seconds : float | None
  • static model_config
  • static outcome : str
  • static reason : str | None

IndexingProgressEvent​

class IndexingProgressEvent(**data: Any):

Emitted by a metadata runtime each time it persists a chunk.

Totals are cumulative for the run, so consecutive events give both the rate and the running position of a pass that may take hours.

timers holds what the phases the run's datasource names (BaseSource.indexing_timer_names) did during the run, keyed by timer name with dots as underscores (dicom.header_read as dicom_header_read). It is unset when the datasource names none. The timers are process-wide, so runs sharing a process mix.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static bytes_read : int
  • static dataset_identifier : str | None
  • static elapsed_seconds : float
  • static files_keyed : int
  • static files_per_second : float
  • static files_reused : int
  • static files_seen : int
  • static files_unchanged : int
  • static io_concurrency : int | None
  • static model_config
  • static process_read_bytes : int | None
  • static rows_written : int
  • static run_type : str
  • static task_hash : str
  • static timers : dict[str, bitfount.telemetry.logs.models.TimerTotals] | None

Methods​


summary​

def summary(self) ‑> str:

Give the pass's running position and its rate.

Returns One line for the log's message.

IndexingSummaryEvent​

class IndexingSummaryEvent(**data: Any):

Emitted once when a metadata runtime finishes, successfully or not.

status mirrors the run's bookkeeping status ("success", "skipped", "partial" or "error"). It serialises as run_status, because Datadog reads a status attribute as the log's severity. The per-phase seconds are what separate a pass that is bound by hashing from one bound by header parsing or by cache writes. cancel_reason is set when a cancelled run's cause is known, e.g. "lease_renewal_failed" when Prefect cancelled it for losing its deployment concurrency lease. lease_loss_cause then says what took the lease, read from the run's server-side state history: "zombie_reaper", "state_changed:<STATE>" for another server-side state change, "lease_revoked_while_running" when the run was still RUNNING, or "unknown" when the history could not be read. On the same lease-loss path, last_heartbeat_sent_at and last_heartbeat_received_at give the run's last Prefect heartbeat as the run stamped it and as the server received it (ISO 8601), so a gap that got the run reaped shows on which side it opened. Both are None on any other path, or when the server holds no heartbeat for the run. stop_reason names why a run stopped short of its work: "inventory_not_current" for a scan whose input inventory was not current, "inventory_unchanged" for an index pass that found nothing changed, "metadata_busy" for a run that gave up waiting for its metadata lock, or "fenced_out" for a run whose metadata lock a newer holder took over. lock_wait_seconds is how long the run waited for its metadata:<task_hash> lock. The files_pruned, files_newly_missed and files_awaiting_prune counts say what the post-walk prune did: a file a walk misses is recorded, and its row pruned only by a walk that misses it again a grace period later. link_targets_unreachable counts link targets that did not answer, whose rows were kept; link_targets_vanished those that answered with every file gone, such as a folder emptied on the share. timers is the run's total of the same field on IndexingProgressEvent.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static bytes_read : int
  • static cancel_reason : str | None
  • static dataset_identifier : str | None
  • static elapsed_seconds : float
  • static files_awaiting_prune : int
  • static files_keyed : int
  • static files_newly_missed : int
  • static files_per_second : float
  • static files_pruned : int
  • static files_reused : int
  • static files_seen : int
  • static files_unchanged : int
  • static flush_seconds : float
  • static io_concurrency : int | None
  • static key_seconds : float
  • static last_heartbeat_received_at : str | None
  • static last_heartbeat_sent_at : str | None
  • static lease_loss_cause : str | None
  • static link_targets_unreachable : int
  • static link_targets_vanished : int
  • static lock_wait_seconds : float | None
  • static model_config
  • static parse_seconds : float
  • static process_read_bytes : int | None
  • static root_probe_seconds : float
  • static root_probes : int
  • static rows_written : int
  • static run_type : str
  • static status : str
  • static stop_reason : str | None
  • static task_hash : str
  • static timers : dict[str, bitfount.telemetry.logs.models.TimerTotals] | None
  • static transient_failures : int

Methods​


summary​

def summary(self) ‑> str:

Say how the pass ended and after how long, then its totals.

Returns One line for the log's message.

MetadataKickoffEvent​

class MetadataKickoffEvent(**data: Any):

Emitted once each time the pod decides which datasources to index.

submission_order is the order the file_metadata_runtime runs are scheduled in. The health lists partition every datasource considered; skipped_archived_only names those left out because every project they are linked to is archived. hub_filters_failed names the Hub calls that failed and were therefore not applied.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static healthy : list[str]
  • static hub_filters_applied : list[str]
  • static hub_filters_failed : list[str]
  • static model_config
  • static pod_name : str
  • static skipped_archived_only : list[str]
  • static submission_order : list[str]
  • static trigger : str
  • static unknown : list[str]

ModelInferenceProgressEvent​

class ModelInferenceProgressEvent(**data: Any):

Emitted while model_inference is still working.

Modelled on IndexingProgressEvent, and for the same reason: a pass that takes hours otherwise says nothing between its first log line and its last, which is indistinguishable from a hang. Consecutive events give both the rate and the running position.

Emitted on a wall clock and a file floor rather than per batch, so the volume is bounded both by how long inference takes and by how many files it covers — the pair that keeps a large datasource from paying a point per file even when one file takes longer to infer than the interval. One trailing event closes out each invocation.

The counts are scoped to this invocation of the step, which under waving is one wave rather than the whole datasource. The wave's own banner in bitfount.flows.dag.executor carries the outer denominator.

Attributes

  • model_ref: Which model is running.
  • batches_done: Batches finished so far, of batches_total.
  • batches_total: Batches this invocation planned.
  • files_in_window: Files covered since the previous report, which at the one-file batches every shipped v9 template configures is how many batches the window held.
  • files_done: Files carried so far, of files_total.
  • files_total: Files this invocation is inferring over, after the cached ones were subtracted.
  • elapsed_seconds: Since the step's loop started.
  • files_per_second: Mean rate so far, for projecting what is left.
  • task_hash: The step's partition.
  • run_id: The flow run.
  • read_seconds: Cumulative time reading and decoding files. Summed over reads, so it can exceed the wall time when reads overlap.
  • read_cpu_seconds: Cumulative CPU time of those reads, which tells a read bound by the disk or network from one bound by decoding.
  • prep_seconds: Cumulative time preparing records for the model.
  • model_seconds: Cumulative time in the model proper: the prediction call less the reads and preparation that happen inside it, floored at zero.
  • overhead_seconds: Cumulative chunk wall time outside the prediction call (model-wrapper setup, dataloader build, conversion of the predictions, loop bookkeeping).
  • bytes_read: Cumulative on-disk size of the files in the chunks run, from the inventory. A file served from the wave cache still counts its source file's size, so this is not the bytes fetched from the share and bytes_read / read_seconds overstates throughput when there are hits.
  • decoded_bytes: Cumulative size of the decoded arrays the reads produced.
  • files_read: Cumulative number of file reads behind read_seconds; a file read twice counts twice.
  • window_read_seconds: read_seconds for the window since the previous report.
  • window_read_cpu_seconds: read_cpu_seconds for the window.
  • window_prep_seconds: prep_seconds for the window.
  • window_model_seconds: model_seconds for the window.
  • window_overhead_seconds: overhead_seconds for the window.
  • window_bytes_read: bytes_read for the window.
  • window_decoded_bytes: decoded_bytes for the window.
  • window_files_read: files_read for the window.
  • wave_cache_hits: Cumulative records served from the wave's decoded-record cache. Every consulted lookup is one hit or one miss, and files_read and read_seconds include these hits.
  • wave_cache_misses: Cumulative lookups the cache could not serve, including loads that failed.
  • wave_cache_not_stored: Cumulative misses whose record was then not written to the cache; every miss ends in a store or a not-stored outcome, unless the read itself raises.
  • wave_cache_errors: Cumulative failed loads plus failed stores.
  • wave_cache_bytes_read: Cumulative bytes read from the cache, counting hits only.
  • wave_cache_bytes_written: Cumulative bytes written to the cache.
  • wave_cache_read_seconds: Cumulative time spent on lookups, covering hits, plain misses and failed loads.
  • wave_cache_write_seconds: Cumulative time spent storing records.
  • wave_cache_not_stored_reasons: Cumulative not-stored counts keyed by reason; always cumulative, with no window counterpart.
  • window_wave_cache_hits: wave_cache_hits for the window.
  • window_wave_cache_misses: wave_cache_misses for the window.
  • window_wave_cache_not_stored: wave_cache_not_stored for the window.
  • window_wave_cache_errors: wave_cache_errors for the window.
  • window_wave_cache_bytes_read: wave_cache_bytes_read for the window.
  • window_wave_cache_bytes_written: wave_cache_bytes_written for the window.
  • window_wave_cache_read_seconds: wave_cache_read_seconds for the window.
  • window_wave_cache_write_seconds: wave_cache_write_seconds for the window.
  • read_ahead_files: Cumulative files the step's thread took from the read-ahead. read_ahead_read_seconds and read_ahead_cpu_seconds are the reader thread's own time; the read_ahead_* file counts and read_ahead_wait_seconds are measured on the step's thread, and read_seconds stays the step thread's wait for a file's records. Wave-cache cache_* timings for read-ahead reads are measured on the reader thread.
  • read_ahead_ready_files: Of those, cumulative files already read when taken, so the step did not wait.
  • read_ahead_fallback_files: Cumulative files the step read synchronously because the read-ahead could not serve them.
  • read_ahead_read_seconds: Cumulative wall time of the reader's own reads.
  • read_ahead_cpu_seconds: Cumulative CPU time of the reader's own reads.
  • read_ahead_wait_seconds: Cumulative time the step spent waiting in takes, a subset of read_seconds.
  • read_ahead_peak_bytes: The most decoded bytes the reader held untaken; a running maximum with no window counterpart.
  • predict_cpu_seconds: Cumulative CPU time of the step's thread across the prediction call.
  • window_read_ahead_files: read_ahead_files for the window.
  • window_read_ahead_ready_files: read_ahead_ready_files for the window.
  • window_read_ahead_fallback_files: read_ahead_fallback_files for the window.
  • window_read_ahead_read_seconds: read_ahead_read_seconds for the window.
  • window_read_ahead_cpu_seconds: read_ahead_cpu_seconds for the window.
  • window_read_ahead_wait_seconds: read_ahead_wait_seconds for the window.
  • window_predict_cpu_seconds: predict_cpu_seconds for the window.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static batches_done : int
  • static batches_total : int
  • static bytes_read : int | None
  • static decoded_bytes : int | None
  • static elapsed_seconds : float
  • static files_done : int
  • static files_in_window : int
  • static files_per_second : float
  • static files_read : int | None
  • static files_total : int
  • static model_config
  • static model_ref : str
  • static model_seconds : float | None
  • static overhead_seconds : float | None
  • static predict_cpu_seconds : float | None
  • static prep_seconds : float | None
  • static read_ahead_cpu_seconds : float | None
  • static read_ahead_fallback_files : int | None
  • static read_ahead_files : int | None
  • static read_ahead_peak_bytes : int | None
  • static read_ahead_read_seconds : float | None
  • static read_ahead_ready_files : int | None
  • static read_ahead_wait_seconds : float | None
  • static read_cpu_seconds : float | None
  • static read_seconds : float | None
  • static run_id : str | None
  • static task_hash : str | None
  • static wave_cache_bytes_read : int | None
  • static wave_cache_bytes_written : int | None
  • static wave_cache_errors : int | None
  • static wave_cache_hits : int | None
  • static wave_cache_misses : int | None
  • static wave_cache_not_stored : int | None
  • static wave_cache_not_stored_reasons : dict[str, int] | None
  • static wave_cache_read_seconds : float | None
  • static wave_cache_write_seconds : float | None
  • static window_bytes_read : int | None
  • static window_decoded_bytes : int | None
  • static window_files_read : int | None
  • static window_model_seconds : float | None
  • static window_overhead_seconds : float | None
  • static window_predict_cpu_seconds : float | None
  • static window_prep_seconds : float | None
  • static window_read_ahead_cpu_seconds : float | None
  • static window_read_ahead_fallback_files : int | None
  • static window_read_ahead_files : int | None
  • static window_read_ahead_read_seconds : float | None
  • static window_read_ahead_ready_files : int | None
  • static window_read_ahead_wait_seconds : float | None
  • static window_read_cpu_seconds : float | None
  • static window_read_seconds : float | None
  • static window_wave_cache_bytes_read : int | None
  • static window_wave_cache_bytes_written : int | None
  • static window_wave_cache_errors : int | None
  • static window_wave_cache_hits : int | None
  • static window_wave_cache_misses : int | None
  • static window_wave_cache_not_stored : int | None
  • static window_wave_cache_read_seconds : float | None
  • static window_wave_cache_write_seconds : float | None

Methods​


summary​

def summary(self) ‑> str:

Say how far inference has got, how fast, and how long is left.

Returns One line for the log's message.

ModelInferenceSetupEvent​

class ModelInferenceSetupEvent(**data: Any):

Emitted once per model_inference attempt, after the model has loaded.

Says what the step spent getting ready, which the per-window progress events cannot: selecting and diffing the files, and obtaining the model. Also emitted when every file was already cached, with nothing to infer and no model load. Not emitted when loading the model raises; a retried attempt emits its own.

Attributes

  • model_ref: Which model the step runs.
  • model_version: The model version the step runs, if pinned.
  • task_hash: The step's partition.
  • run_id: The flow run.
  • files_selected: Files the datasource selected for this invocation.
  • files_reused: Of those, files whose cached predictions are still valid.
  • files_to_infer: Files left to infer.
  • selection_seconds: Time to list the selection, read the stored hashes and work out which files are reusable.
  • model_load_seconds: Time to load the model; None when none was loaded.
  • weights_source: "memo" when the weights were already in memory, "shared" when read from the shared encrypted store, "download" when fetched; None when not known.
  • weights_bytes: Size of the downloaded weights; None for a memo hit or when not known.
  • weights_download_seconds: Time the whole fetch from the Hub took: downloading the model code, loading the model class and downloading the weights. None for a memo hit or when not known.
  • weights_shared_bytes: Size of the weights read from the shared store; None unless weights_source is "shared".
  • weights_store: What the shared store did for this load ("hit", "stored", "not_stored", "bypassed" or "error"); None when not known.
  • weights_store_reason: Why the weights were not stored or the store was bypassed, as a short code; None otherwise.
  • process_uptime_seconds: How long the process had been running, so a first invocation can be told from one in a warm process.
  • wave_cache_active: Whether the wave's decoded-record cache is in use; None when not known.
  • read_ahead_depth: How many files the step reads ahead; 0 when read-ahead is off, None when not known.
  • read_ahead_max_bytes: The most decoded bytes the read-ahead holds untaken; None when not known.
  • read_ahead_off_reason: Why read-ahead is off: "setting", "multiprocessing" or "datasource"; "none" when it is on and None when not known.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static files_reused : int
  • static files_selected : int
  • static files_to_infer : int
  • static model_config
  • static model_load_seconds : float | None
  • static model_ref : str
  • static model_version : int | None
  • static process_uptime_seconds : float | None
  • static read_ahead_depth : int | None
  • static read_ahead_max_bytes : int | None
  • static read_ahead_off_reason : str | None
  • static run_id : str | None
  • static selection_seconds : float
  • static task_hash : str | None
  • static wave_cache_active : bool | None
  • static weights_bytes : int | None
  • static weights_download_seconds : float | None
  • static weights_shared_bytes : int | None
  • static weights_source : str | None
  • static weights_store : str | None
  • static weights_store_reason : str | None

Methods​


summary​

def summary(self) ‑> str:

Say how many files are to be inferred and what getting ready cost.

Returns One line for the log's message.

ModelWeightsSweepEvent​

class ModelWeightsSweepEvent(**data: Any):

Emitted after the shared model-weights store has been swept.

Counts only; no path or filename is reported.

Attributes

  • deleted: Entries deleted.
  • failed: Entries that could not be deleted.
  • bytes_reclaimed: Bytes freed by the deletions.
  • legacy_deleted: Of those deleted, entries in the legacy layout.
  • kept_live: Entries kept because they are still in use.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static bytes_reclaimed : int
  • static deleted : int
  • static failed : int
  • static kept_live : int
  • static legacy_deleted : int
  • static model_config

PatientEligibilityEvent​

class PatientEligibilityEvent(**data: Any):

Emitted after eligible patient counts are calculated.

Two producers, whose fields do not overlap fully, so every field either producer cannot supply is optional — a required field would raise ValidationError in the other, inside a try that also guards unrelated work:

  • the orchestrator's on_task_end hook, counting eligible patients over a task's merged output; it has the datasource and no denominator.
  • the patient_eligibility reduce step, which has the denominator, task_hash and run_id, and reads stored verdicts rather than a datasource.

From the reduce step, patients_considered counts the patients rolled up in that run's partition — the pipeline is scan-driven, so that is the patients with at least one stored scan, not every patient in the datasource — and eligible_count is how many of those came out ELIGIBLE. Both describe the rows the run wrote, not what a reader is served: the pointer cutover can be withheld, leaving the previous partition published.

ineligible_count and unknown_count complete the verdict breakdown from the reduce step, and are None from the orchestrator hook, which counts only the eligible. Read them together: the three move independently, and a fall in eligible_count means something different depending on which of the other two rose.

unknown_count is not an EHR-outage signal on its own. An unreachable EHR leaves its criteria unevaluated and those patients roll up to unknown, but so does a patient with no patient-level row at all. The run-scoped EHRRunOutcome that would tell the two apart does not reach the step that emits this; the ehr_coverage tag published beside these counts is the discriminator.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static datasource : str | None
  • static datetime : str
  • static eligible_count : int
  • static ineligible_count : int | None
  • static model_config
  • static patients_considered : int | None
  • static project_id : str
  • static run_id : str | None
  • static task_hash : str | None
  • static unknown_count : int | None

Methods​


summary​

def summary(self) ‑> str:

Give the verdict breakdown, out of the patients considered when known.

Returns One line for the log's message.

PatientEnrichmentSourceEvent​

class PatientEnrichmentSourceEvent(**data: Any):

Emitted once per enrichment source per patient_enrichment step run.

Says whether a supplied file (for example, a site's BCVA CSV) was read and what it now serves, so a criterion that never sees the file's facts can be told apart from one whose file never arrived. Counts, codes and the configured source name only: never a value, a row, or a patient.

Attributes

  • source_name: The source's configured name. Not source, which is Datadog's reserved attribute for the log's origin (ddsource).
  • outcome: "stored" (read and replaced), "unchanged" (same content as the last ingest, not re-read), "not_found", "outside_dir", "filesystem_error", "unreadable" (columns could not be determined; stored rows kept) or "failed" (an unexpected parse error; stored rows kept).
  • missing_columns: The configured columns the file's header lacks; None unless unreadable for that reason.
  • header_columns: How many columns the file's header has; None unless unreadable with a header that parsed. One column with every configured column missing means the file is not comma-separated.
  • rows_stored: Facts this run wrote for the source; 0 unless stored.
  • rows_with_identity: File rows resolved to a patient; None unless the file was read this run.
  • rows_unresolved_identity: File rows stating an identity that did not resolve, and so skipped; None unless the file was read this run.
  • stored_rows: Facts the source serves after this run.
  • stored_patients: Distinct patients those facts belong to.
  • codes: The most frequent "<system>|<code>" the source serves, to its fact count, capped at ENRICHMENT_CODES_LIMIT.
  • task_hash: The step's partition.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static codes : dict[str, int]
  • static header_columns : int | None
  • static missing_columns : list[str] | None
  • static model_config
  • static outcome : str
  • static rows_stored : int
  • static rows_unresolved_identity : int | None
  • static rows_with_identity : int | None
  • static source_name : str
  • static stored_patients : int | None
  • static stored_rows : int | None
  • static task_hash : str | None

PodErrorEvent​

class PodErrorEvent(**data: Any):

Emitted when the pod fails outside a task.

phase is "init" or "startup" for an exception escaping Pod.__init__ or Pod.start, and "process_spawn" when a background process could not be started after all retries. Frames come from the record's exc_info where the exception is in hand; the message is never sent.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static attempts : int | None
  • static error_type : str
  • static model_config
  • static phase : str
  • static process_name : str | None

Methods​


summary​

def summary(self) ‑> str:

Say where the pod failed and with what.

Returns One line for the log's message.

RecoverySummaryEvent​

class RecoverySummaryEvent(**data: Any):

Emitted once per start-of-process metadata run reconciliation.

Attributes

  • backlog_cancelled: Queued duplicate metadata runs cancelled.
  • runs_resubmitted: Replacement runs submitted for lost ones.
  • refresh_runs_ended: Refresh runs ended after wedging.
  • slots_released: Stranded concurrency slots released.
  • failed_steps: Reconciliation steps that raised, by name.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static backlog_cancelled : int
  • static failed_steps : list[str]
  • static model_config
  • static refresh_runs_ended : int
  • static runs_resubmitted : int
  • static slots_released : int

ScanReduceEvent​

class ScanReduceEvent(**data: Any):

Emitted after the scan_reduce step narrows a run's file selection.

How much a reduction saved is otherwise invisible: covered and the published coverage figure both count the inventory, so a run that skipped most of it looks the same from the outside as one that processed everything.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static datetime : str | None
  • static files_considered : int | None
  • static files_selected : int | None
  • static files_unidentified : int | None
  • static model_config
  • static patients_considered : int | None
  • static patients_dropped : int | None
  • static run_id : str | None
  • static strategy : str | None
  • static task_hash : str | None
  • static unsatisfiable : bool | None

Methods​


summary​

def summary(self) ‑> str:

Say how far the reduction narrowed the selection, and what it dropped.

Returns One line for the log's message.

SchemaGenerationEndEvent​

class SchemaGenerationEndEvent(**data: Any):

Emitted when the Prefect schema worker finishes generating a schema.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static dataset_id : str
  • static datetime : str
  • static model_config

SchemaGenerationErrorEvent​

class SchemaGenerationErrorEvent(**data: Any):

Emitted when a datasource's schema cannot be loaded, generated or uploaded.

From the Prefect schema worker, stage is "generation" for a failure while building the schema, "upload" for a failed full upload, and "partial_upload" for a failed upload after an interruption. From the pod, stage is "load" for a datasource the pod could not load at start-up or on a config reload, and so is not serving.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static dataset_id : str
  • static error_type : str
  • static model_config
  • static stage : str

Methods​


summary​

def summary(self) ‑> str:

Say which schema stage failed, for which dataset and with what.

Returns One line for the log's message.

SchemaGenerationStartEvent​

class SchemaGenerationStartEvent(**data: Any):

Emitted when the Prefect schema worker begins generating a schema.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static dataset_id : str
  • static datetime : str
  • static model_config

SchemaInitiationSource​

class SchemaInitiationSource(*args, **kwds):

Source that triggered schema generation.

Inherits from str so values serialise directly as JSON strings.

Variables​

  • static PREFECT_SCHEMA_WORKER

SchemaUploadSuccessEvent​

class SchemaUploadSuccessEvent(**data: Any):

Emitted after a full schema is successfully uploaded to the Hub.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static dataset_id : str
  • static datetime : str
  • static model_config
  • static number_of_records : int

StepProgress​

class StepProgress(    files_processed: int | None = None,    patients_processed: int | None = None,    entries_created: int | None = None,    items_skipped: int | None = None,    cache_entries_used: int | None = None,):

How much work one DAG step invocation did.

Mutable by design. contextvars.copy_context() copies bindings, not the objects they point at, so a step mutating this on its worker thread is seen by the executor that created it - which is how a count reported inside a step reaches the timing event emitted around it.

Every field means work done by this invocation and nothing else. A step that cannot answer honestly leaves it None; a partition size or a denominator does not belong here. files_in_scope on the executor's own timing events is the field for a denominator.

The first two feed the step's timing event. The last three are what the step's STEP_COMPLETED progress event reports, so they are the figures a consumer sees for the step; a None is sent as zero there.

Attributes

  • files_processed: Files this step actually read this run, excluding ones skipped because a cached result already covered them.
  • patients_processed: Distinct patients this step handled this run.
  • entries_created: Rows this step persisted this run.
  • items_skipped: Items this step was handed and left out, for want of what it needed to process them.
  • cache_entries_used: Items this step answered from rows an earlier run stored, rather than processing again.

Variables​

  • cache_entries_used : int | None
  • entries_created : int | None
  • files_processed : int | None
  • items_skipped : int | None
  • patients_processed : int | None

TaskAcceptedByPodEvent​

class TaskAcceptedByPodEvent(**data: Any):

Emitted by the modeller when a pod accepts a task request.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static app_version : str
  • static datetime : str
  • static model_config
  • static pod_identifier : str
  • static task_id : str

TaskAcceptedEvent​

class TaskAcceptedEvent(**data: Any):

Emitted by the worker when it accepts and begins a task.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static app_version : str
  • static datasource_type : str
  • static datetime : str
  • static model_config
  • static modeller_username : str
  • static pod_name : str
  • static task_id : str

TaskCompleteEvent​

class TaskCompleteEvent(**data: Any):

Emitted by the worker when a task finishes successfully.

Symmetric counterpart to TaskAcceptedEvent — together they bracket the full task execution window in Datadog logs.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static datetime : str
  • static model_config
  • static modeller_username : str
  • static pod_name : str
  • static task_id : str

TaskCompleteTimeoutEvent​

class TaskCompleteTimeoutEvent(**data: Any):

Emitted when the worker times out waiting for TASK_COMPLETE from the modeller.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static datetime : str
  • static model_config
  • static modeller_username : str
  • static pod_name : str
  • static task_id : str

TaskErrorEvent​

class TaskErrorEvent(**data: Any):

Emitted by the worker when a task does not run to completion.

outcome says how it ended: "error" or "abort" for a failure inside the task, "rejected", "no_data", "data_not_available", "cancelled", "timeout" or "child_died" otherwise.

stacktrace_frames carries frame strings only - never the exception message or .args, which can name a patient. The handler fills it from the record's exc_info when the emitting code has the exception itself; it stays None on the paths that only learn a child process failed, because the traceback the child sent back is format_exception output and includes the message. error_type is available on both paths.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static error_type : str
  • static model_config
  • static modeller_username : str
  • static outcome : str
  • static pod_name : str
  • static stacktrace_frames : str | None
  • static task_id : str

Methods​


summary​

def summary(self) ‑> str:

Say which task did not complete, how it ended and with what.

Returns One line for the log's message.

TelemetryEventName​

class TelemetryEventName(*args, **kwds):

Canonical names for all Datadog telemetry events.

Inherits from str so values serialise directly as JSON strings.

Variables​

  • static ABANDONED_THREAD
  • static ALGORITHM_PROGRESS
  • static BACKGROUND_DAG_RUN
  • static BACKGROUND_DAG_RUN_CRASHED
  • static BACKGROUND_RERUN_GATE
  • static BACKGROUND_RUN_DEFERRED
  • static BACKGROUND_RUN_EMPTY
  • static BATCH_PROGRESS
  • static BCVA_DERIVATION
  • static CACHE_ENCRYPTION_KEY
  • static CACHE_ENCRYPTION_MIGRATION
  • static CACHE_ENCRYPTION_SWEEP
  • static COMPUTE_CERTIFICATE
  • static COMPUTE_CHILD
  • static COMPUTE_REGISTRATION
  • static COMPUTE_SUMMARY
  • static COMPUTE_SUPERVISION
  • static CRITERIA_MATCHING_SUMMARY
  • static DAG_EXECUTION_TIME
  • static DAG_RUN_PROGRESS
  • static DAG_STEP
  • static DAG_SWEEP_SUMMARY
  • static DAG_WAVE
  • static DATASET_CONNECTED
  • static DATASOURCE_ROOT_CHANGED
  • static DOCUMENT_ACUITY
  • static EHR_ELEMENT_READS
  • static EHR_PATIENT_LISTING
  • static EHR_PATIENT_LISTING_SERVED
  • static EHR_PATIENT_LISTING_SUBMITTED
  • static EHR_PROVIDER_CAPABILITY
  • static EHR_QUERY_COMPLETE
  • static EHR_QUERY_OUTCOME
  • static EHR_REFRESH_REQUESTED
  • static EHR_SCREENING_BATCH
  • static EHR_SESSION_INITIALISED
  • static EHR_TOKEN_REFRESHED
  • static EVENT_LOOP_LAG
  • static FILE_MULTI_SERIES_SUMMARY
  • static FILE_SKIP_SUMMARY
  • static FILTERING_COMPLETE
  • static GPU_USAGE
  • static GROUPING_SUMMARY
  • static HOST_CACHE_KEY
  • static INDEXING_PROGRESS
  • static INDEXING_SUMMARY
  • static LOCK_LEASE_LOST
  • static MESSAGE_SERVICE_CONNECTIVITY
  • static METADATA_KICKOFF
  • static METADATA_SWEEP_ABANDONED
  • static MODEL_INFERENCE_PROGRESS
  • static MODEL_INFERENCE_SETUP
  • static MODEL_WEIGHTS_SWEEP
  • static PATIENT_API_REQUEST_ERROR
  • static PATIENT_API_SERVER
  • static PATIENT_ELIGIBILITY
  • static PATIENT_ENRICHMENT_SOURCE
  • static PERIODIC_RERUN_TICK
  • static POD_ERROR
  • static POD_READY
  • static POD_RESOURCES
  • static POD_SHUTDOWN
  • static PREFECT_LEASE_STORAGE_IN_MEMORY
  • static PREFECT_MIGRATION
  • static PREFECT_SLOTS_UNJUDGED
  • static PREFECT_SLOTS_UNLEASED
  • static PROGRESS_EVENT_DELIVERY
  • static PROGRESS_REPORTING_DISABLED
  • static RECOVERY_SUMMARY
  • static SCAN_REDUCE
  • static SCAN_SUBMITTED_BY_INDEX
  • static SCAN_SWEEP_GATE_UNREADABLE
  • static SCHEMA_GENERATION_END
  • static SCHEMA_GENERATION_ERROR
  • static SCHEMA_GENERATION_START
  • static SCHEMA_UPLOAD_SUCCESS
  • static TASK_ACCEPTED
  • static TASK_ACCEPTED_BY_POD
  • static TASK_COMPLETE
  • static TASK_COMPLETE_TIMEOUT
  • static TASK_DEFINITION_REFRESH
  • static TASK_ERROR
  • static TELEMETRY_DROPPED
  • static TRIAL_FILTER_SUMMARY
  • static UPDATE_HOLD
  • static WAVE_DECODED_CACHE
  • static WAVE_PLAN_CANDIDATES_EXHAUSTED
  • static WAVE_PLAN_FAILED
  • static WAVE_PLAN_NO_SCAN_COVERAGE
  • static WORKER_STARTUP_PHASE

TreeNodeSummary​

class TreeNodeSummary(**data: Any):

One criteria_tree node's aggregate outcome, leaf or combinator alike.

parent_node_id and depth are carried on every node so the whole tree is rebuildable from the node list alone, without a separate structure payload.

Attributes

  • node_key: The identifier to key a dashboard on, in precedence order: evidence_id when the author set one, else its protocol criterion number when it sets its own item_number, else this node's own group when it is a region root, else its place under its nearest keyed ancestor, else node_id. The criterion number comes before group because group is to be replaced by it. Read node_key_source to know which it resolved to.

A node's place is the ancestor's key followed by each child index on the path down to it, counted from 0: I7a[1][0] is the first child of the second child of I7a. It names the protocol item, and only an edit inside that item can change it. A place that is the same as an author-set key is not used.

An inherited group is never used. A region root's own group is unique tree-wide and author-set (_check_group_inheritance), so it identifies that one node; the descendants sharing the string do not set it and are not identified by it.

The criterion number joins the item_number values on the path from the root, after I or E from criterion_type, for example E4a. Only a node that sets its own item_number, and whose criterion_type resolves, gets one. A number that would key two nodes, or that is the same as another node's evidence_id or own group, is not used.

  • node_key_stable: Whether node_key came from an author-set value — evidence_id, a criterion number, or a region root's own group — rather than falling back to the positional node_id. A tree whose nodes are mostly False here cannot be tracked across a config edit; setting evidence_id or item_number on the nodes that matter fixes it.
  • node_key_source: Where node_key came from: author for an author-set value (as node_key_stable), anchored for the node's place under its nearest keyed ancestor, positional for the node_id fallback.
  • is_region_root: Whether this node set the group it reports, rather than inheriting it. A region root's own verdict is the region's verdict, so filtering on this gives one row per reporting group without unrolling the subtree beneath it.
  • node_id: The node's auto-assigned node_<n> id.

Positional, and assigned in tree order, so inserting a node renumbers every node after it. Present for correlating against a single run's evidence; prefer node_key for anything that spans runs.

  • node_type: The node's discriminator — and, or, at_least, not, multi_scan, or a leaf type (column, code, observation, medication, allergy, device, appointment).
  • parent_node_id: The parent's node_id, or None for the root.
  • depth: Distance from the root, which is 0.
  • child_count: How many children the node has; 0 for a leaf.
  • group: The node's resolved (inherited) group reporting label, or None when neither it nor any ancestor set one.
  • evidence_id: The node's own evidence_id. Not inherited, and unique tree-wide, so it identifies exactly one node.
  • min_count: An AtLeastGroup's min_count; None on every other node.
  • combine: An AndGroup's combine mode; None on every other node.
  • rows_pass: Rows whose evaluation resolved this node to pass. For a combinator that is its own combined verdict, not a tally of its children.
  • rows_fail: Rows it resolved to fail.
  • rows_unknown: Rows it could not resolve.
  • rows_sole_blocker: Rows this node alone kept out of the cohort: rows where it failed while every sibling under the same AndGroup passed.

Three conditions, all required, because the point of the field is that loosening this one node would have admitted those rows:

  1. The row's tree verdict was fail. A row the tree accepted was kept out by nobody, whatever an individual branch did.
  2. The node's parent is an AndGroup, where every child must pass, so a lone failing child decided it. 0 for a node under any other combinator — an OrGroup sibling can carry the branch regardless, and under a NotGroup the failure is what let the row through.
  3. Every node between that parent and the root is also an AndGroup, so the group's failure reached the verdict rather than being absorbed. An AtLeastGroup whose min_count equals its child count is conjunctive in effect but does not count here — conservative, and it keeps the rule checkable by eye.

A nested AndGroup scores alongside the child that sank it: both statements are true, and the group's own count is worth having. worst_blocker_key breaks that tie towards the deeper node, being the criterion someone would actually loosen.

  • polarity: On a code leaf, include, exclude or flag: whether matching it lets a row through, read off how many not nodes sit above it (an odd number excludes). flag under a not with on_match: unknown, where a match neither admits nor excludes the row but sends it for review. None on every other node.
  • configured_code_count: On a code leaf, how many codes its code list holds, patterns counting once each as on CriterionSummary. None on every other node, and on a text-only leaf, which configures no code.
  • configured_codes_matching_nobody: How many of those matched no code the cohort carried, read exactly as on CriterionSummary: equal to configured_code_count on an include leaf is a dead list, and the same on an exclude leaf is normal.

Codes are compared by string alone. A CodeSpec pinned to a code_system is credited by a cohort code of the same string in any system, as the flat lists are.

None when it could not be established: the leaf's code column was absent from the frame, or the cohort scan did not run because enable_criteria_near_miss_counts is off. A tree leaf has no evidence fallback, since a node's outcome records its verdict but not the codes that decided it.

  • near_miss_code_count: On a condition leaf, distinct cohort codes matching none of its codes but sharing an ICD-10 category with one, as on CriterionSummary. None on a procedure leaf, for the same reason as there, and whenever the scan did not run.
  • near_miss_row_count: Rows carrying at least one such code.
  • near_miss_codes: The near-miss codes named, under the same patient threshold, cap and None cases as on CriterionSummary.
  • operator: On a column leaf, the comparison it ran (">=", ...). None on every other node: a code-addressed leaf matches rather than compares, and its configured codes are never sent.
  • operand: On a column leaf, the configured value it compared against. None elsewhere, for the same reason.
  • grain: On a leaf, scan or patient. None on a combinator.
  • provenance: On a leaf, scan or ehr, as on CriterionSummary. None on a combinator.
  • rows_absent_column: On a column leaf, rows whose target column was not on the frame at all — unknown because the data was never produced, not because a patient lacked it. None elsewhere.
  • rows_failed_near_bound: On a column leaf with an ordering comparison, failures within 10% of the operand, as on CriterionSummary. None elsewhere.
  • rows_fail_without_records: On a code, observation or medication leaf — the leaves that record what they examined — fails where no record of the configured kind was found. For an observation leaf: no reading at all.
  • rows_fail_with_records: Fails where records were found but none qualified — for an observation leaf, readings outside its value bound or not the one its selector picked. Together with rows_fail_without_records it sums to rows_fail. Both are None on a leaf that reads no records, and on a combinator.
  • unknown_reasons: How many of rows_unknown gave each reason, keyed by UnknownReasonCode value (not_in_ehr, ehr_unavailable, value_missing, ...). Separates "the EHR never answered" from "it answered without the data", which rows_unknown alone cannot. A row that gave no reason is counted under unspecified. Empty when nothing was unknown, and on a combinator: its unknowns are its children's, which carry the reasons.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static child_count : int
  • static combine : str | None
  • static configured_code_count : int | None
  • static configured_codes_matching_nobody : int | None
  • static depth : int
  • static evidence_id : str | None
  • static grain : str | None
  • static group : str | None
  • static is_region_root : bool
  • static min_count : int | None
  • static model_config
  • static near_miss_code_count : int | None
  • static near_miss_codes : list[bitfount.telemetry.logs.models.NearMissCode] | None
  • static near_miss_row_count : int | None
  • static node_id : str
  • static node_key : str
  • static node_key_source : Literal['author', 'anchored', 'positional']
  • static node_key_stable : bool
  • static node_type : str
  • static operand : Any
  • static operator : str | None
  • static parent_node_id : str | None
  • static polarity : Literal['include', 'exclude', 'flag'] | None
  • static provenance : str | None
  • static rows_absent_column : int | None
  • static rows_fail : int
  • static rows_fail_with_records : int | None
  • static rows_fail_without_records : int | None
  • static rows_failed_near_bound : int | None
  • static rows_pass : int
  • static rows_sole_blocker : int
  • static rows_unknown : int

TrialFilterSummaryEvent​

class TrialFilterSummaryEvent(**data: Any):

Aggregate Datadog event for trial filter outcomes within a batch.

rows_missing counts rows with missing inputs required by the filter. It is not mutually exclusive with rows_matched or rows_failed.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static filter_name : str
  • static matching_column_count : int | None
  • static missing_columns : list[str] | None
  • static model_config
  • static rows_failed : int
  • static rows_matched : int
  • static rows_missing : int
  • static step : str

WaveDecodedCacheEvent​

class WaveDecodedCacheEvent(**data: Any):

Emitted once per wave when its decoded-record cache ends or is unavailable.

Carries no path or filename; location is a coarse label only.

Attributes

  • outcome: "closed" when the cache ran and was removed, "delete_failed" when removing it failed, or "unavailable" when it could not be used.
  • reason: Why the cache was unavailable or its removal failed.
  • records_stored: Records written to the cache over its lifetime.
  • bytes_stored: Bytes written to the cache over its lifetime.
  • hits: Lookups served from the cache.
  • misses: Lookups the cache could not serve.
  • admission_stopped: Why the cache stopped admitting records, if it did.
  • budget_bytes: The disk budget the cache was given.
  • free_bytes_at_open: Free disk space when the cache was opened.
  • lifetime_seconds: How long the cache existed.
  • cleanup_seconds: How long removing the cache took.
  • orphans_deleted: Leftover caches from earlier waves that were deleted.
  • orphan_bytes_reclaimed: Bytes reclaimed by deleting those.
  • orphans_failed: Leftover caches that could not be deleted.
  • location: A coarse label for where the cache lived.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static admission_stopped : str | None
  • static budget_bytes : int | None
  • static bytes_stored : int | None
  • static cleanup_seconds : float | None
  • static free_bytes_at_open : int | None
  • static hits : int | None
  • static lifetime_seconds : float | None
  • static location : str | None
  • static misses : int | None
  • static model_config
  • static orphan_bytes_reclaimed : int | None
  • static orphans_deleted : int | None
  • static orphans_failed : int | None
  • static outcome : str
  • static reason : str | None
  • static records_stored : int | None

WorkerStartupPhaseEvent​

class WorkerStartupPhaseEvent(**data: Any):

Emitted after each phase of worker startup, with how long that phase took.

Together these bracket the window between the worker reporting "Configuring task" and its first exchange with the modeller — protocol deserialisation and model download, protocol pickling, spawning the child interpreter, child setup, and algorithm initialisation. That window is otherwise silent, and a message arriving from the modeller during it is only tolerated for handler_register_grace_period seconds, so the split between these phases is what decides whether a task starts or stalls.

process is "parent" (the pod) or "child" (the spawned worker).

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Variables​

  • static duration_seconds : float
  • static model_config
  • static phase : str
  • static pod_name : str | None
  • static process : str
  • static task_id : str