Skip to main content

dataset_grants

The grants the metadata runtimes present to relay their progress events.

The file-metadata and scan-metadata runtimes relay their events through the pod (bitfount.progress_events.relay), and must present a grant to do so. A background DAG run presents the grant for its (task_hash, project_id) lineage, but a preprocessing pass belongs to no project. So the pod issues one grant per configured datasource, keyed on its task hash alone, in a cache table (cache.types.dataset_relay_grants) and registry of their own. The pod control server only honours it for imaging dataset events; it redeems no credentials.

A metadata run is not the pod's child. Recovery and the nightly refresh can start one before the pod is up, and one can outlive the pod. A run reads its nonce once, when it starts, so the pod renews a grant rather than rotating it: a pod restart keeps the nonce, and runs already holding it keep reporting.

Both ends import this module: the pod to keep the grants, and the metadata runtimes to find theirs.

Module​

Functions​

build_dataset_relay_sender​

def build_dataset_relay_sender(    cache: CacheProtocol, pod_name: str, datasource_name: str,) ‑> ProgressEventSender | None:

Build a sender that relays a metadata run's events through its pod.

Never raises: a run that cannot report progress still indexes.

Arguments

  • cache: The pod's open background cache.
  • pod_name: The pod the run indexes for.
  • datasource_name: The datasource the run indexes.

Returns The sender, or None when the datasource has no live grant, in which case reporters given it report nothing.

new_dataset_grant_registry​

def new_dataset_grant_registry() ‑> bitfount.federated.run_grants.GrantRegistry[str]:

Return an empty registry for the pod's dataset grants.

sync_dataset_grants​

def sync_dataset_grants(    cache: CacheProtocol,    pod_name: str,    datasource_names: Iterable[str],    registry: DatasetGrantRegistry,) ‑> None:

Keep a live grant for each of the pod's datasources, and only those.

Each datasource's grant is kept if it has more than half its TTL left, renewed with the same nonce if it has less, and issued afresh if it has expired or never existed. Every kept grant is registered, so a pod that has just started honours the grants it issued before. A grant for a datasource the pod no longer has is revoked.

Blocking (SQLite).

Arguments

  • cache: The pod's open background cache.
  • pod_name: The pod's name.
  • datasource_names: The datasources the pod is configured with.
  • registry: The grants the pod control server honours.