Coverage for /usr/local/lib/python3.12/site-packages/prefect/client/collections.py: 57%
13 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 13:38 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 13:38 +0000
1from typing import Any, Dict, Optional 1a
3from typing_extensions import Protocol 1a
5from prefect.client.cloud import get_cloud_client 1a
6from prefect.client.orchestration import ServerType, get_client 1a
9class CollectionsMetadataClient(Protocol): 1a
10 async def read_worker_metadata(self) -> Dict[str, Any]: ... 10 ↛ exitline 10 didn't return from function 'read_worker_metadata' because 1a
12 async def __aenter__(self) -> "CollectionsMetadataClient": ... 12 ↛ exitline 12 didn't return from function '__aenter__' because 1a
14 async def __aexit__(self, *exc_info: Any) -> Any: ... 14 ↛ exitline 14 didn't return from function '__aexit__' because 1a
17def get_collections_metadata_client( 1a
18 httpx_settings: Optional[Dict[str, Any]] = None,
19) -> "CollectionsMetadataClient":
20 """
21 Creates a client that can be used to fetch metadata for
22 Prefect collections.
24 Will return a `CloudClient` if profile is set to connect
25 to Prefect Cloud, otherwise will return an `OrchestrationClient`.
26 """
27 orchestration_client = get_client(httpx_settings=httpx_settings)
28 if orchestration_client.server_type == ServerType.CLOUD:
29 return get_cloud_client(httpx_settings=httpx_settings, infer_cloud_url=True)
30 else:
31 return orchestration_client