Skip to main content

aip_sdk.publish_workspace_metric_config_defaults

aip_sdk.publish_workspace_metric_config_defaults(defaults: Sequence[WorkspaceMetricConfigDefaultSpec], *, workspace_id: str, client: APIClient | None = None) -> list[WorkspaceMetricConfigDefault]

Publish a new default version for each metric in defaults.

workspace_admin only. Each item inserts the next config_version for its metric; the previous version stays readable and unmodified, and the new one becomes what runs in this workspace resolve. Versions are server-derived, so this call can never overwrite a stored one.

All-or-nothing on the server: if any item fails validation, none of the batch is written. At most 500 items per call, and every item's metric.name must be unique within the batch — a duplicate is rejected rather than silently collapsed, since two versions published in one call would leave the caller unable to say which became the default.

Not idempotent, and the transport already retries for you. Each call inserts a new version, and the version is server-derived, so there is no key that makes a repeat safe: publishing the same payload twice leaves two versions, and the second is what runs resolve. The underlying client itself retries a request up to twice more on a timeout or network error before this call raises — so by the time you see an exception here, the write may have already landed on one of those attempts.

Set base_version on an item (the config_version last read for it via list_workspace_metric_config_defaults()) to guard against exactly that: if the lineage has moved past it — including because this same call already landed once and the transport is now retrying it — the server rejects the item with StaleWorkspaceMetricConfigDefaultBaseVersionError instead of inserting another version. Leaving it unset keeps the old, unguarded behaviour. Either way, read the current default with list_workspace_metric_config_defaults() before publishing again after any exception here, rather than assuming nothing was written.

Parameters

  • defaults Sequence[WorkspaceMetricConfigDefaultSpec]: The defaults to publish, one item per metric. At most 500 items; each metric.name at most once.
  • workspace_id str: The workspace to configure.
  • client APIClient | None: Optional pre-configured API client.

Returns

  • list[WorkspaceMetricConfigDefault]: list[WorkspaceMetricConfigDefault]: the versions written, in the order given — read
  • list[WorkspaceMetricConfigDefault]: config_version to confirm the bump.

Raises

Example:

published = aip.publish_workspace_metric_config_defaults(
[
aip.WorkspaceMetricConfigDefaultSpec(
metric=aip.MetricRef(name="hallucination", implementation_version="1.0.0"),
config_name="hallucination-strict",
params={"threshold": 0.2},
)
],
workspace_id="ws-abc123",
)
print(published[0].config_version) # the bump over whatever was current