uniqc.backend_adapter.backend_registry module¶
Backend registry: fetches, normalises, and caches platform backends.
This module is the central orchestrator for the uniqc backend command.
It:
1. Calls each platform’s list_backends() adapter method (or cache).
2. Normalises the raw platform data into BackendInfo objects.
3. Persists the normalised list to the disk cache.
4. Provides query helpers (get_backend_info, find_backend).
- class uniqc.backend_adapter.backend_registry.BackendAuditIssue(backend_id, severity, field, message)[source]¶
Bases:
objectOne backend metadata issue found by the registry audit.
- class uniqc.backend_adapter.backend_registry.FetchResult(backends, fetch_failures=<factory>)[source]¶
Bases:
objectResult of fetching backends from all platforms.
- Variables:
backends (dict[uniqc.backend_adapter.backend_info.Platform, list[uniqc.backend_adapter.backend_info.BackendInfo]]) – Per-platform backend descriptors.
fetch_failures (dict[uniqc.backend_adapter.backend_info.Platform, str]) – Platforms that had credentials but failed to fetch, mapped to the error message.
- Parameters:
- backends: dict[Platform, list[BackendInfo]]¶
- uniqc.backend_adapter.backend_registry.audit_backend_info(backend)[source]¶
Validate one normalized backend descriptor.
The audit is intentionally provider-neutral. It checks only the fields UnifiedQuantum relies on internally, so adapters can expose provider-specific metadata in
BackendInfo.extrawithout being rejected.- Parameters:
backend (BackendInfo)
- Return type:
- uniqc.backend_adapter.backend_registry.audit_backends(backends, *, fetch_failures=None)[source]¶
Validate normalized backend descriptors returned by the registry.
- Parameters:
backends (list[BackendInfo] | dict[Platform, list[BackendInfo]]) – Backend descriptors (flat list or per-platform dict).
fetch_failures (dict[Platform, str] | None) – Optional mapping of platforms that had credentials but failed to fetch, with the error message. Each entry is emitted as a
BackendAuditIssue(severity="warning")so the caller can see which platforms were not audited.
- Return type:
- uniqc.backend_adapter.backend_registry.fetch_all_backends(force_refresh=False)[source]¶
Fetch backends from all configured platforms.
- Parameters:
force_refresh (bool) – Bypass the cache TTL for all platforms.
- Returns:
Dict mapping Platform to its list of BackendInfo objects. Platforms with no credentials are silently omitted. Platforms with credentials but fetch failures are omitted with a warning.
- Return type:
- uniqc.backend_adapter.backend_registry.fetch_all_backends_with_status(force_refresh=False)[source]¶
Fetch backends from all platforms, returning fetch failures too.
Like
fetch_all_backends()but also returns information about platforms that had credentials but failed to fetch, so callers can surface these as audit issues.- Parameters:
force_refresh (bool)
- Return type:
- uniqc.backend_adapter.backend_registry.fetch_platform_backends(platform, force_refresh=False)[source]¶
Fetch and normalise backends for one platform.
- Parameters:
- Returns:
A tuple of (backends, fetched_newly) where fetched_newly is True if the data was fetched from the network (vs. served from cache).
- Raises:
BackendError – If the platform has credentials configured but the fetch fails (network error, API error, etc.) and no stale cache is available as fallback.
- Return type:
tuple[list[BackendInfo], bool]
- uniqc.backend_adapter.backend_registry.find_backend(identifier)[source]¶
Find a backend by its identifier.
- Supports two forms:
platform:name(e.g.originq:WK_C180)bare
name(searches all platforms)
Matching is case-insensitive and treats
-and_as equivalent sooriginq:wk_c180andoriginq:WK_C180both succeed. For OriginQ a small alias table also maps short names likewk180toWK_C180.- Parameters:
identifier (str) – Backend identifier.
- Returns:
The matching BackendInfo object.
- Raises:
ValueError – If the backend is not found or the identifier format is invalid.
- Return type: