airflow.providers.google.cloud.triggers.dataproc

This module contains Google Dataproc triggers.

Module Contents

Classes

DataprocSubmitTrigger

Trigger that periodically polls information from Dataproc API to verify job status.

DataprocClusterTrigger

Trigger that periodically polls information from Dataproc API to verify status.

DataprocBatchTrigger

DataprocCreateBatchTrigger run on the trigger worker to perform create Build operation

DataprocDeleteClusterTrigger

Asynchronously checks the status of a cluster.

class airflow.providers.google.cloud.triggers.dataproc.DataprocSubmitTrigger(job_id, region, project_id=None, gcp_conn_id='google_cloud_default', impersonation_chain=None, delegate_to=None, polling_interval_seconds=30)[source]

Bases: airflow.triggers.base.BaseTrigger

Trigger that periodically polls information from Dataproc API to verify job status. Implementation leverages asynchronous transport.

serialize()[source]

Returns the information needed to reconstruct this Trigger.

Returns

Tuple of (class path, keyword arguments needed to re-instantiate).

async run()[source]

Runs the trigger in an asynchronous context.

The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.

If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).

In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.

class airflow.providers.google.cloud.triggers.dataproc.DataprocClusterTrigger(cluster_name, region, project_id=None, gcp_conn_id='google_cloud_default', impersonation_chain=None, polling_interval_seconds=10)[source]

Bases: airflow.triggers.base.BaseTrigger

Trigger that periodically polls information from Dataproc API to verify status. Implementation leverages asynchronous transport.

serialize()[source]

Returns the information needed to reconstruct this Trigger.

Returns

Tuple of (class path, keyword arguments needed to re-instantiate).

Return type

tuple[str, dict[str, Any]]

async run()[source]

Runs the trigger in an asynchronous context.

The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.

If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).

In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.

class airflow.providers.google.cloud.triggers.dataproc.DataprocBatchTrigger(batch_id, region, project_id, gcp_conn_id='google_cloud_default', impersonation_chain=None, polling_interval_seconds=5.0)[source]

Bases: airflow.triggers.base.BaseTrigger

DataprocCreateBatchTrigger run on the trigger worker to perform create Build operation

Parameters
  • batch_id (str) – The ID of the build.

  • project_id (str | None) – Google Cloud Project where the job is running

  • region (str) – The Cloud Dataproc region in which to handle the request.

  • gcp_conn_id (str) – Optional, the connection ID used to connect to Google Cloud Platform.

  • impersonation_chain (str | Sequence[str] | None) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

  • polling_interval_seconds (float) – polling period in seconds to check for the status

serialize()[source]

Serializes DataprocBatchTrigger arguments and classpath.

async run()[source]

Runs the trigger in an asynchronous context.

The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.

If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).

In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.

class airflow.providers.google.cloud.triggers.dataproc.DataprocDeleteClusterTrigger(cluster_name, end_time, project_id=None, region=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, polling_interval=5.0, **kwargs)[source]

Bases: airflow.triggers.base.BaseTrigger

Asynchronously checks the status of a cluster.

Parameters
  • cluster_name (str) – The name of the cluster

  • end_time (float) – Time in second left to check the cluster status

  • project_id (str | None) – The ID of the Google Cloud project the cluster belongs to

  • region (str | None) – The Cloud Dataproc region in which to handle the request

  • metadata (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method

  • gcp_conn_id (str) – The connection ID to use when fetching connection info.

  • impersonation_chain (str | Sequence[str] | None) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account.

  • polling_interval (float) – Time in seconds to sleep between checks of cluster status

serialize()[source]

Serializes DataprocDeleteClusterTrigger arguments and classpath.

async run()[source]

Wait until cluster is deleted completely

Was this entry helpful?