Skip to main content

prefect_gcp.utilities

Functions

slugify_name

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 job
Returns:
  • The slugified job name or None if the slugified name is empty

Classes

Job

Utility class to call GCP jobs API and interact with the returned objects. Methods:

create

create(client: Resource, namespace: str, body: dict)
Make a create request to the GCP jobs API.

delete

delete(client: Resource, namespace: str, job_name: str)
Make a delete request to the GCP jobs API.

get

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

has_execution_in_progress(self) -> bool
See if job has a run in progress.

is_ready

is_ready(self) -> bool
Whether a job is finished registering and ready to be executed

run

run(client: Resource, namespace: str, job_name: str)
Make a run request to the GCP jobs API.

Execution

Utility class to call GCP executions API and interact with the returned objects. Methods:

condition_after_completion

condition_after_completion(self)
Returns Execution condition if Execution has completed.

get

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

is_running(self) -> bool
Returns True if Execution is not completed.

succeeded

succeeded(self)
Whether or not the Execution completed is a successful state.