Skip to main content

task_run

Progress events for a task run.

Classes​

TaskRunEventReporter​

class TaskRunEventReporter(    sender: ProgressEventSender | None,    *,    dataset_id: str,    dataset_owner_id: str,    project_id: str,    task_run_id: str,    batch_event_interval_seconds: float = 30.0,    clock: Callable[[], float] = <built-in function monotonic>,):

Reports the progress of one task run.

Batch events are coalesced per step: a step's batch event is sent at most once per batch_event_interval_seconds, and the latest batch held back is sent before the step's completion event, so consumers always see the final batch.

Arguments

  • sender: Delivers the events. None makes the reporter a no-op.
  • dataset_id: The dataset the task runs on.
  • dataset_owner_id: The username of the dataset's owner, which must be the user the sender authenticates as.
  • project_id: The project the task belongs to.
  • task_run_id: The UUIDv7 identifying this task run, from uuid6.uuid7().
  • batch_event_interval_seconds: The shortest time between two batch events for the same step. One interval applies to every step in the run, and each step's interval is timed separately.
  • clock: Monotonic clock in seconds, for tests.

Ancestors​

Variables​

  • next_sequence_number : int - The sequence number the next event will carry.
  • sender : ProgressEventSender | None - The sender this reporter hands its events to, if any.

    Read-only: a caller composing a second reporter for the same run shares this one rather than holding the sender separately.

Methods​


completed​

def completed(self) ‑> None:

Report that the task run has completed.

deferred​

def deferred(self) ‑> None:

Report that the task run was deferred until the dataset is ready.

error​

def error(self, reason: LiteralString, exc: BaseException | None = None) ‑> None:

Report that the task run failed.

Arguments

  • reason: A fixed description of what failed. Must be a string literal, so no data can reach it.
  • exc: The exception behind the failure. Only its class name is sent.

started​

def started(self, trigger: TaskRunStartTrigger.ValueType) ‑> None:

Report that the task run has started.

Arguments

  • trigger: What started the run.

step_batch_started​

def step_batch_started(self, step_name: str, step_version: str, batch_index: int) ‑> None:

Report that a step has started a batch, subject to coalescing.

Arguments

  • step_name: The step's name in the task template.
  • step_version: The step's version.
  • batch_index: The index of the batch.

step_completed​

def step_completed(    self,    step_name: str,    step_version: str,    entries_created_count: int,    items_skipped_count: int,    cache_entries_used_count: int = 0,) ‑> None:

Report that a step has completed.

Sends the step's latest held-back batch event first, if there is one.

Arguments

  • step_name: The step's name in the task template.
  • step_version: The step's version.
  • entries_created_count: Entries the step created.
  • items_skipped_count: Items the step skipped.
  • cache_entries_used_count: Items answered from the cache.

step_started​

def step_started(    self, step_name: str, step_version: str, batches_count: int, batch_size: int,) ‑> None:

Report that a step has started.

Arguments

  • step_name: The step's name in the task template.
  • step_version: The step's version.
  • batches_count: The number of batches the step will run.
  • batch_size: The number of items in each batch.