registration_retry
Retry hub registration for datasets the hub refused on the pod's credentials.
A 401 at registration means the hub did not accept the token the pod sent, not that anything is wrong with the dataset. Giving up on the dataset for the life of the pod, as any other registration failure does, would leave the pod running with nothing to serve until it was restarted, even once the token had been refreshed. So a dataset refused that way is held here, and registration is retried on the pod's periodic ticker with a bounded exponential backoff. Each attempt goes through the pod's hub session, so it uses whatever token that session holds by then.
Module
Functions
is_hub_auth_failure
def is_hub_auth_failure(exc: BaseException) ‑> bool:Return whether a registration failed because the hub refused the credentials.
Arguments
exc: The exception registration raised.
Returns
True if the first permanent error in the exception's chain is a
HubAuthError (a 401).
Classes
DatasetRegistrationRetry
class DatasetRegistrationRetry( *, register: Callable[[DatasourceContainer], None], is_still_pending: Callable[[str], bool], on_registered: Callable[[dict[str, DatasourceContainer]], Awaitable[None]], initial_delay_seconds: float = 60.0, max_delay_seconds: float = 1800.0, clock: Callable[[], float] = <built-in function monotonic>,):Datasets waiting to be registered again, and when to next try.
Create an empty retry.
Arguments
register: Registers one dataset on the hub, raisingPodRegistrationErrorif it cannot. Run off the event loop.is_still_pending: Whether the pod still holds the named dataset as configured but unregistered. A config reload may have registered or removed it since it was added here.on_registered: Given the datasets a retry registered, makes the pod serve them.initial_delay_seconds: The wait before the first retry.max_delay_seconds: The cap on the wait between retries.clock: Monotonic time source, for tests.
Variables
pending_names : set[str]- The datasets still waiting to be registered.
Methods
add
def add(self, name: str, container: DatasourceContainer) ‑> None:Hold a dataset the hub refused, to retry after the current delay.
Arguments
name: The dataset's name.container: The dataset, as it would have been served.
discard
def discard(self, name: str) ‑> None:Stop retrying a dataset, if it is held.
For a dataset a config reload has since tried to register itself and failed for a reason other than the credentials: the held container is out of date, and retrying it could serve it over the current config.
Arguments
name: The dataset's name.
tick
async def tick(self) ‑> None:Retry every held dataset, if a retry is due.
A dataset that registers is handed to on_registered. One refused
again, or that cannot reach the hub, stays held and the wait before the
next attempt doubles, up to the cap. One the hub refuses for any other
permanent reason (e.g. a 403) is let go, as it would have been at start.