aip_sdk.get_or_create_partition
aip_sdk.get_or_create_partition(dataset_id: str, version_id: str, *, name: str, selector: PartitionSelector, client: APIClient | None = None) -> GetOrCreatePartitionResult
Create a partition, or reuse the existing one if this name is already taken.
For a script that may run more than once against the same dataset version — a demo,
a notebook, a retry — this avoids choosing between failing on
DuplicatePartitionError and hand-rolling a list_partitions() lookup on catch.
Parameters
dataset_idstr: Dataset ID.version_idstr: Dataset version ID to attach the partition to.namestr: Partition name, unique within the version. Surrounding whitespace is trimmed.selectorPartitionSelector: The selector naming the evaluation target. Used only when creating; an existing partition of this name is reused only if its own stored selector matches this one — a name collision with a different selector raises rather than silently redirecting the evaluation to a different target.clientAPIClient | None: Optional API client.
Returns
GetOrCreatePartitionResult: AGetOrCreatePartitionResult(partition, created)—createdisTruewhenGetOrCreatePartitionResult: freshly created,Falsewhen an existing, selector-matching partition of thisGetOrCreatePartitionResult: name was found instead.
Raises
InvalidArgumentError: Ifnameis blank or longer than 255 characters, orselectoris inconsistent with its partition type.AuthError: If credentials are missing or invalid.ForbiddenError: If the caller lacks editor rights on the version's workspace.NotFoundError: If the dataset version does not exist or belongs to a workspace the caller is not a member of, or a name collision is reported but no partition with this name is listed on the version (e.g. it was deleted concurrently — retry).DuplicatePartitionError: If a partition of this name already exists with a different selector — the name is taken by something else, not an equivalent partition safe to reuse.UnprocessableEntityError: If the version is not an agent-trace version.ResponseParseError: If the platform's response does not match this SDK version.