MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / bootstrap_namespace

Function bootstrap_namespace

misc/python/materialize/biglake.py:189–203  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

187
188
189def 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

Callers 1

workflow_createFunction · 0.90

Calls 4

mint_gcp_access_tokenFunction · 0.85
ensure_catalogFunction · 0.85
resolve_warehouse_prefixFunction · 0.85
create_namespaceFunction · 0.85

Tested by

no test coverage detected