docs/integrations/prefect-gcp/api-ref/prefect_gcp-utilities.mdx
prefect_gcp.utilitiessanitize_labels_for_gcp <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L16" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>sanitize_labels_for_gcp(labels: dict[str, str]) -> dict[str, str]
Sanitize Prefect labels for use as GCP resource labels.
GCP labels must have keys that start with a lowercase letter and contain only lowercase letters, digits, underscores, and hyphens, with a max length of 63 characters. Values follow the same character rules but may start with any allowed character, and may also be empty.
Dots and slashes in keys (e.g. prefect.io/flow-run-id) are replaced
with hyphens. Leading non-letter characters are stripped from keys.
Labels whose keys are empty after sanitization are dropped.
merge_labels_for_gcp <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L39" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>merge_labels_for_gcp(prefect_labels: dict[str, str], existing_labels: dict[str, str]) -> dict[str, str]
Sanitize Prefect labels and merge them with existing job body labels.
Existing labels (from the job body template) always take precedence.
The merged result is capped at :data:_GCP_LABEL_MAX_COUNT (64) labels
to stay within the Cloud Run limit. When trimming is needed, the
lowest-priority Prefect labels (last in insertion order — e.g.
deployment-updated, worker-name) are dropped first so that core
identifiers like flow-run-id and flow-run-name are preserved.
slugify_name <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L64" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>slugify_name(name: str, max_length: int = 30) -> Optional[str]
Slugify text for use as a name.
Keeps only alphanumeric characters and dashes, and caps the length of the slug at 30 chars.
The 30 character length allows room to add a uuid for generating a unique name for the job while keeping the total length of a name below 63 characters, which is the limit for Cloud Run job names.
Args:
name: The name of the jobReturns:
Job <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L124" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Utility class to call GCP jobs API and
interact with the returned objects.
Methods:
create <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L196" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>create(client: Resource, namespace: str, body: dict)
Make a create request to the GCP jobs API.
delete <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L203" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>delete(client: Resource, namespace: str, job_name: str)
Make a delete request to the GCP jobs API.
get <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L181" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get(cls, client: Resource, namespace: str, job_name: str)
Make a get request to the GCP jobs API and return a Job instance.
has_execution_in_progress <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L155" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>has_execution_in_progress(self) -> bool
See if job has a run in progress.
is_ready <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L149" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_ready(self) -> bool
Whether a job is finished registering and ready to be executed
run <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L210" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>run(client: Resource, namespace: str, job_name: str)
Make a run request to the GCP jobs API.
Execution <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L217" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Utility class to call GCP executions API and
interact with the returned objects.
Methods:
condition_after_completion <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L234" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>condition_after_completion(self)
Returns Execution condition if Execution has completed.
get <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L249" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get(cls, client: Resource, namespace: str, execution_name: str)
Make a get request to the GCP executions API and return an Execution instance.
is_running <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L230" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>is_running(self) -> bool
Returns True if Execution is not completed.
succeeded <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-gcp/prefect_gcp/utilities.py#L240" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>succeeded(self)
Whether or not the Execution completed is a successful state.