Ensure the catalog and namespace for ``gs:// `` exist. Mints a token from ``service_account``, ensures the BigLake catalog for the bucket exists, resolves the warehouse prefix, and creates ``namespace`` if it is missing. Idempotent: a no-op once the catalog and namespace exist. R
(service_account: dict, bucket: str, namespace: str)
| 187 | |
| 188 | |
| 189 | def bootstrap_namespace(service_account: dict, bucket: str, namespace: str) -> str: |
| 190 | """Ensure the catalog and namespace for ``gs://<bucket>`` exist. |
| 191 | |
| 192 | Mints a token from ``service_account``, ensures the BigLake catalog for the |
| 193 | bucket exists, resolves the warehouse prefix, and creates ``namespace`` if it |
| 194 | is missing. Idempotent: a no-op once the catalog and namespace exist. Returns |
| 195 | the resolved catalog prefix. |
| 196 | """ |
| 197 | project = service_account["project_id"] |
| 198 | token = mint_gcp_access_token(service_account) |
| 199 | ensure_catalog(token, project, bucket) |
| 200 | prefix = resolve_warehouse_prefix(token, project, bucket) |
| 201 | create_namespace(token, project, prefix, namespace) |
| 202 | print(f"BigLake namespace ready: {namespace} (gs://{bucket})") |
| 203 | return prefix |
no test coverage detected