airflow.providers.google.cloud.operators.dataproc

This module contains Google Dataproc operators.

Module Contents

Classes

PreemptibilityType

Contains possible Type values of Preemptibility applicable for every secondary worker of Cluster.

ClusterGenerator

Create a new Dataproc Cluster.

DataprocCreateClusterOperator

Create a new cluster on Google Cloud Dataproc.

DataprocScaleClusterOperator

Scale, up or down, a cluster on Google Cloud Dataproc.

DataprocDeleteClusterOperator

Delete a cluster in a project.

DataprocJobBaseOperator

Base class for operators that launch job on DataProc.

DataprocSubmitPigJobOperator

Start a Pig query Job on a Cloud DataProc cluster.

DataprocSubmitHiveJobOperator

Start a Hive query Job on a Cloud DataProc cluster.

DataprocSubmitSparkSqlJobOperator

Start a Spark SQL query Job on a Cloud DataProc cluster.

DataprocSubmitSparkJobOperator

Start a Spark Job on a Cloud DataProc cluster.

DataprocSubmitHadoopJobOperator

Start a Hadoop Job on a Cloud DataProc cluster.

DataprocSubmitPySparkJobOperator

Start a PySpark Job on a Cloud DataProc cluster.

DataprocCreateWorkflowTemplateOperator

Creates new workflow template.

DataprocInstantiateWorkflowTemplateOperator

Instantiate a WorkflowTemplate on Google Cloud Dataproc.

DataprocInstantiateInlineWorkflowTemplateOperator

Instantiate a WorkflowTemplate Inline on Google Cloud Dataproc.

DataprocSubmitJobOperator

Submit a job to a cluster.

DataprocUpdateClusterOperator

Update a cluster in a project.

DataprocCreateBatchOperator

Create a batch workload.

DataprocDeleteBatchOperator

Delete the batch workload resource.

DataprocGetBatchOperator

Get the batch workload resource representation.

DataprocListBatchesOperator

List batch workloads.

DataprocCancelOperationOperator

Cancel the batch workload resource.

class airflow.providers.google.cloud.operators.dataproc.PreemptibilityType[source]

Bases: enum.Enum

Contains possible Type values of Preemptibility applicable for every secondary worker of Cluster.

PREEMPTIBLE = 'PREEMPTIBLE'[source]
SPOT = 'SPOT'[source]
PREEMPTIBILITY_UNSPECIFIED = 'PREEMPTIBILITY_UNSPECIFIED'[source]
class airflow.providers.google.cloud.operators.dataproc.ClusterGenerator(project_id, num_workers=None, zone=None, network_uri=None, subnetwork_uri=None, internal_ip_only=None, tags=None, storage_bucket=None, init_actions_uris=None, init_action_timeout='10m', metadata=None, custom_image=None, custom_image_project_id=None, custom_image_family=None, image_version=None, autoscaling_policy=None, properties=None, optional_components=None, num_masters=1, master_machine_type='n1-standard-4', master_disk_type='pd-standard', master_disk_size=1024, worker_machine_type='n1-standard-4', worker_disk_type='pd-standard', worker_disk_size=1024, num_preemptible_workers=0, preemptibility=PreemptibilityType.PREEMPTIBLE.value, service_account=None, service_account_scopes=None, idle_delete_ttl=None, auto_delete_time=None, auto_delete_ttl=None, customer_managed_key=None, enable_component_gateway=False, **kwargs)[source]

Create a new Dataproc Cluster.

Parameters
  • cluster_name – The name of the DataProc cluster to create. (templated)

  • project_id (str) – The ID of the google cloud project in which to create the cluster. (templated)

  • num_workers (int | None) – The # of workers to spin up. If set to zero will spin up cluster in a single node mode

  • storage_bucket (str | None) – The storage bucket to use, setting to None lets dataproc generate a custom one for you

  • init_actions_uris (list[str] | None) – List of GCS uri’s containing dataproc initialization scripts

  • init_action_timeout (str) – Amount of time executable scripts in init_actions_uris has to complete

  • metadata (dict | None) – dict of key-value google compute engine metadata entries to add to all instances

  • image_version (str | None) – the version of software inside the Dataproc cluster

  • custom_image (str | None) – custom Dataproc image for more info see https://cloud.google.com/dataproc/docs/guides/dataproc-images

  • custom_image_project_id (str | None) – project id for the custom Dataproc image, for more info see https://cloud.google.com/dataproc/docs/guides/dataproc-images

  • custom_image_family (str | None) – family for the custom Dataproc image, family name can be provide using –family flag while creating custom image, for more info see https://cloud.google.com/dataproc/docs/guides/dataproc-images

  • autoscaling_policy (str | None) – The autoscaling policy used by the cluster. Only resource names including projectid and location (region) are valid. Example: projects/[projectId]/locations/[dataproc_region]/autoscalingPolicies/[policy_id]

  • properties (dict | None) – dict of properties to set on config files (e.g. spark-defaults.conf), see https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.clusters#SoftwareConfig

  • optional_components (list[str] | None) – List of optional cluster components, for more info see https://cloud.google.com/dataproc/docs/reference/rest/v1/ClusterConfig#Component

  • num_masters (int) – The # of master nodes to spin up

  • master_machine_type (str) – Compute engine machine type to use for the primary node

  • master_disk_type (str) – Type of the boot disk for the primary node (default is pd-standard). Valid values: pd-ssd (Persistent Disk Solid State Drive) or pd-standard (Persistent Disk Hard Disk Drive).

  • master_disk_size (int) – Disk size for the primary node

  • worker_machine_type (str) – Compute engine machine type to use for the worker nodes

  • worker_disk_type (str) – Type of the boot disk for the worker node (default is pd-standard). Valid values: pd-ssd (Persistent Disk Solid State Drive) or pd-standard (Persistent Disk Hard Disk Drive).

  • worker_disk_size (int) – Disk size for the worker nodes

  • num_preemptible_workers (int) – The # of VM instances in the instance group as secondary workers inside the cluster with Preemptibility enabled by default. Note, that it is not possible to mix non-preemptible and preemptible secondary workers in one cluster.

  • preemptibility (str) – The type of Preemptibility applicable for every secondary worker, see https://cloud.google.com/dataproc/docs/reference/rpc/ google.cloud.dataproc.v1#google.cloud.dataproc.v1.InstanceGroupConfig.Preemptibility

  • zone (str | None) – The zone where the cluster will be located. Set to None to auto-zone. (templated)

  • network_uri (str | None) – The network uri to be used for machine communication, cannot be specified with subnetwork_uri

  • subnetwork_uri (str | None) – The subnetwork uri to be used for machine communication, cannot be specified with network_uri

  • internal_ip_only (bool | None) – If true, all instances in the cluster will only have internal IP addresses. This can only be enabled for subnetwork enabled networks

  • tags (list[str] | None) – The GCE tags to add to all instances

  • region – The specified region where the dataproc cluster is created.

  • gcp_conn_id – The connection ID to use connecting to Google Cloud.

  • service_account (str | None) – The service account of the dataproc instances.

  • service_account_scopes (list[str] | None) – The URIs of service account scopes to be included.

  • idle_delete_ttl (int | None) – The longest duration that cluster would keep alive while staying idle. Passing this threshold will cause cluster to be auto-deleted. A duration in seconds.

  • auto_delete_time (datetime.datetime | None) – The time when cluster will be auto-deleted.

  • auto_delete_ttl (int | None) – The life duration of cluster, the cluster will be auto-deleted at the end of this duration. A duration in seconds. (If auto_delete_time is set this parameter will be ignored)

  • customer_managed_key (str | None) – The customer-managed key used for disk encryption projects/[PROJECT_STORING_KEYS]/locations/[LOCATION]/keyRings/[KEY_RING_NAME]/cryptoKeys/[KEY_NAME] # noqa

  • enable_component_gateway (bool | None) – Provides access to the web interfaces of default and selected optional components on the cluster.

make()[source]

Helper method for easier migration.

Returns

Dict representing Dataproc cluster.

class airflow.providers.google.cloud.operators.dataproc.DataprocCreateClusterOperator(*, cluster_name, region, project_id=None, cluster_config=None, virtual_cluster_config=None, labels=None, request_id=None, delete_on_error=True, use_if_exists=True, retry=DEFAULT, timeout=1 * 60 * 60, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), polling_interval_seconds=10, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Create a new cluster on Google Cloud Dataproc.

The operator will wait until the creation is successful or an error occurs in the creation process.

If the cluster already exists and use_if_exists is True, the operator will:

If the cluster already exists and use_if_exists is True then the operator will: - if cluster state is ERROR then delete it if specified and raise error - if cluster state is CREATING wait for it and then check for ERROR state - if cluster state is DELETING wait for it and then create new cluster

Please refer to https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.clusters

for a detailed explanation on the different parameters. Most of the configuration parameters detailed in the link are available as a parameter to this operator.

See also

For more information on how to use this operator, take a look at the guide: Create a Cluster

Parameters
  • project_id (str | None) – The ID of the Google cloud project in which to create the cluster. (templated)

  • cluster_name (str) – Name of the cluster to create

  • labels (dict | None) – Labels that will be assigned to created cluster. Please, notice that adding labels to ClusterConfig object in cluster_config parameter will not lead to adding labels to the cluster. Labels for the clusters could be only set by passing values to parameter of DataprocCreateCluster operator.

  • cluster_config (dict | google.cloud.dataproc_v1.Cluster | None) – Required. The cluster config to create. If a dict is provided, it must be of the same form as the protobuf message ClusterConfig

  • virtual_cluster_config (dict | None) – Optional. The virtual cluster config, used when creating a Dataproc cluster that does not directly control the underlying compute resources, for example, when creating a Dataproc-on-GKE cluster <https://cloud.google.com/dataproc/docs/concepts/jobs/dataproc-gke#create-a-dataproc-on-gke-cluster>

  • region (str) – The specified region where the dataproc cluster is created.

  • delete_on_error (bool) – If true the cluster will be deleted if created with ERROR state. Default value is true.

  • use_if_exists (bool) – If true use existing cluster

  • request_id (str | None) – Optional. A unique id used to identify the request. If the server receives two DeleteClusterRequest requests with the same id, then the second request will be ignored and the first google.longrunning.Operation created and stored in the backend is returned.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • 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).

  • deferrable (bool) – Run operator in the deferrable mode.

  • polling_interval_seconds (int) – Time (seconds) to wait between calls to check the run status.

template_fields: Sequence[str] = ('project_id', 'region', 'cluster_config', 'virtual_cluster_config', 'cluster_name', 'labels',...[source]
template_fields_renderers[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

execute_complete(context, event)[source]

Callback for when the trigger fires - returns immediately.

Relies on trigger to throw an exception, otherwise it assumes execution was successful.

class airflow.providers.google.cloud.operators.dataproc.DataprocScaleClusterOperator(*, cluster_name, project_id=None, region='global', num_workers=2, num_preemptible_workers=0, graceful_decommission_timeout=None, gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Scale, up or down, a cluster on Google Cloud Dataproc.

The operator will wait until the cluster is re-scaled.

Example usage:

t1 = DataprocClusterScaleOperator(
    task_id="dataproc_scale",
    project_id="my-project",
    cluster_name="cluster-1",
    num_workers=10,
    num_preemptible_workers=10,
    graceful_decommission_timeout="1h",
)

See also

For more detail on about scaling clusters have a look at the reference: https://cloud.google.com/dataproc/docs/concepts/configuring-clusters/scaling-clusters

Parameters
  • cluster_name (str) – The name of the cluster to scale. (templated)

  • project_id (str | None) – The ID of the google cloud project in which the cluster runs. (templated)

  • region (str) – The region for the dataproc cluster. (templated)

  • num_workers (int) – The new number of workers

  • num_preemptible_workers (int) – The new number of preemptible workers

  • graceful_decommission_timeout (str | None) – Timeout for graceful YARN decommissioning. Maximum value is 1d

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • 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).

template_fields: Sequence[str] = ('cluster_name', 'project_id', 'region', 'impersonation_chain')[source]
execute(context)[source]

Scale, up or down, a cluster on Google Cloud Dataproc.

class airflow.providers.google.cloud.operators.dataproc.DataprocDeleteClusterOperator(*, region, cluster_name, project_id=None, cluster_uuid=None, request_id=None, retry=DEFAULT, timeout=1 * 60 * 60, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), polling_interval_seconds=10, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Delete a cluster in a project.

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

  • cluster_name (str) – Required. The cluster name (templated).

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

  • cluster_uuid (str | None) – Optional. Specifying the cluster_uuid means the RPC should fail if cluster with specified UUID does not exist.

  • request_id (str | None) – Optional. A unique id used to identify the request. If the server receives two DeleteClusterRequest requests with the same id, then the second request will be ignored and the first google.longrunning.Operation created and stored in the backend is returned.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • 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).

  • deferrable (bool) – Run operator in the deferrable mode.

  • polling_interval_seconds (int) – Time (seconds) to wait between calls to check the cluster status.

template_fields: Sequence[str] = ('project_id', 'region', 'cluster_name', 'impersonation_chain')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

execute_complete(context, event=None)[source]

Callback for when the trigger fires - returns immediately.

Relies on trigger to throw an exception, otherwise it assumes execution was successful.

class airflow.providers.google.cloud.operators.dataproc.DataprocJobBaseOperator(*, region, job_name='{{task.task_id}}_{{ds_nodash}}', cluster_name='cluster-1', project_id=None, dataproc_properties=None, dataproc_jars=None, gcp_conn_id='google_cloud_default', labels=None, job_error_states=None, impersonation_chain=None, asynchronous=False, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), polling_interval_seconds=10, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Base class for operators that launch job on DataProc.

Parameters
  • region (str) – The specified region where the dataproc cluster is created.

  • job_name (str) – The job name used in the DataProc cluster. This name by default is the task_id appended with the execution data, but can be templated. The name will always be appended with a random number to avoid name clashes.

  • cluster_name (str) – The name of the DataProc cluster.

  • project_id (str | None) – The ID of the Google Cloud project the cluster belongs to, if not specified the project will be inferred from the provided GCP connection.

  • dataproc_properties (dict | None) – Map for the Hive properties. Ideal to put in default arguments (templated)

  • dataproc_jars (list[str] | None) – HCFS URIs of jar files to add to the CLASSPATH of the Hive server and Hadoop MapReduce (MR) tasks. Can contain Hive SerDes and UDFs. (templated)

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • labels (dict | None) – The labels to associate with this job. Label keys must contain 1 to 63 characters, and must conform to RFC 1035. Label values may be empty, but, if present, must contain 1 to 63 characters, and must conform to RFC 1035. No more than 32 labels can be associated with a job.

  • job_error_states (set[str] | None) – Job states that should be considered error states. Any states in this set will result in an error being raised and failure of the task. Eg, if the CANCELLED state should also be considered a task failure, pass in {'ERROR', 'CANCELLED'}. Possible values are currently only 'ERROR' and 'CANCELLED', but could change in the future. Defaults to {'ERROR'}.

  • 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).

  • asynchronous (bool) – Flag to return after submitting the job to the Dataproc API. This is useful for submitting long running jobs and waiting on them asynchronously using the DataprocJobSensor

  • deferrable (bool) – Run operator in the deferrable mode

  • polling_interval_seconds (int) – time in seconds between polling for job completion. The value is considered only when running in deferrable mode. Must be greater than 0.

Variables

dataproc_job_id (str) – The actual “jobId” as submitted to the Dataproc API. This is useful for identifying or linking to the job in the Google Cloud Console Dataproc UI, as the actual “jobId” submitted to the Dataproc API is appended with an 8 character random string.

job_type = ''[source]
create_job_template()[source]

Initialize self.job_template with default values.

execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

execute_complete(context, event=None)[source]

Callback for when the trigger fires - returns immediately.

Relies on trigger to throw an exception, otherwise it assumes execution was successful.

on_kill()[source]

Callback called when the operator is killed; cancel any running job.

class airflow.providers.google.cloud.operators.dataproc.DataprocSubmitPigJobOperator(*, query=None, query_uri=None, variables=None, **kwargs)[source]

Bases: DataprocJobBaseOperator

Start a Pig query Job on a Cloud DataProc cluster.

See also

This operator is deprecated, please use DataprocSubmitJobOperator:

The parameters of the operation will be passed to the cluster.

It’s a good practice to define dataproc_* parameters in the default_args of the dag like the cluster name and UDFs.

default_args = {
    "cluster_name": "cluster-1",
    "dataproc_pig_jars": [
        "gs://example/udf/jar/datafu/1.2.0/datafu.jar",
        "gs://example/udf/jar/gpig/1.2/gpig.jar",
    ],
}

You can pass a pig script as string or file reference. Use variables to pass on variables for the pig script to be resolved on the cluster or use the parameters to be resolved in the script as template parameters.

t1 = DataProcPigOperator(
    task_id="dataproc_pig",
    query="a_pig_script.pig",
    variables={"out": "gs://example/output/{{ds}}"},
)

See also

For more detail on about job submission have a look at the reference: https://cloud.google.com/dataproc/reference/rest/v1/projects.regions.jobs

Parameters
  • query (str | None) – The query or reference to the query file (pg or pig extension). (templated)

  • query_uri (str | None) – The HCFS URI of the script that contains the Pig queries.

  • variables (dict | None) – Map of named parameters for the query. (templated)

template_fields: Sequence[str] = ('query', 'variables', 'job_name', 'cluster_name', 'region', 'dataproc_jars',...[source]
template_ext = ('.pg', '.pig')[source]
ui_color = '#0273d4'[source]
job_type = 'pig_job'[source]
generate_job()[source]

Helper method for easier migration to DataprocSubmitJobOperator.

Returns

Dict representing Dataproc job

execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.dataproc.DataprocSubmitHiveJobOperator(*, query=None, query_uri=None, variables=None, **kwargs)[source]

Bases: DataprocJobBaseOperator

Start a Hive query Job on a Cloud DataProc cluster.

See also

This operator is deprecated, please use DataprocSubmitJobOperator:

Parameters
  • query (str | None) – The query or reference to the query file (q extension).

  • query_uri (str | None) – The HCFS URI of the script that contains the Hive queries.

  • variables (dict | None) – Map of named parameters for the query.

template_fields: Sequence[str] = ('query', 'variables', 'job_name', 'cluster_name', 'region', 'dataproc_jars',...[source]
template_ext = ('.q', '.hql')[source]
ui_color = '#0273d4'[source]
job_type = 'hive_job'[source]
generate_job()[source]

Helper method for easier migration to DataprocSubmitJobOperator.

Returns

Dict representing Dataproc job

execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.dataproc.DataprocSubmitSparkSqlJobOperator(*, query=None, query_uri=None, variables=None, **kwargs)[source]

Bases: DataprocJobBaseOperator

Start a Spark SQL query Job on a Cloud DataProc cluster.

See also

This operator is deprecated, please use DataprocSubmitJobOperator:

Parameters
  • query (str | None) – The query or reference to the query file (q extension). (templated)

  • query_uri (str | None) – The HCFS URI of the script that contains the SQL queries.

  • variables (dict | None) – Map of named parameters for the query. (templated)

template_fields: Sequence[str] = ('query', 'variables', 'job_name', 'cluster_name', 'region', 'dataproc_jars',...[source]
template_ext = ('.q',)[source]
template_fields_renderers[source]
ui_color = '#0273d4'[source]
job_type = 'spark_sql_job'[source]
generate_job()[source]

Helper method for easier migration to DataprocSubmitJobOperator.

Returns

Dict representing Dataproc job

execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.dataproc.DataprocSubmitSparkJobOperator(*, main_jar=None, main_class=None, arguments=None, archives=None, files=None, **kwargs)[source]

Bases: DataprocJobBaseOperator

Start a Spark Job on a Cloud DataProc cluster.

See also

This operator is deprecated, please use DataprocSubmitJobOperator:

Parameters
  • main_jar (str | None) – The HCFS URI of the jar file that contains the main class (use this or the main_class, not both together).

  • main_class (str | None) – Name of the job class. (use this or the main_jar, not both together).

  • arguments (list | None) – Arguments for the job. (templated)

  • archives (list | None) – List of archived files that will be unpacked in the work directory. Should be stored in Cloud Storage.

  • files (list | None) – List of files to be copied to the working directory

template_fields: Sequence[str] = ('arguments', 'job_name', 'cluster_name', 'region', 'dataproc_jars', 'dataproc_properties',...[source]
ui_color = '#0273d4'[source]
job_type = 'spark_job'[source]
generate_job()[source]

Helper method for easier migration to DataprocSubmitJobOperator.

Returns

Dict representing Dataproc job

execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.dataproc.DataprocSubmitHadoopJobOperator(*, main_jar=None, main_class=None, arguments=None, archives=None, files=None, **kwargs)[source]

Bases: DataprocJobBaseOperator

Start a Hadoop Job on a Cloud DataProc cluster.

See also

This operator is deprecated, please use DataprocSubmitJobOperator:

Parameters
  • main_jar (str | None) – The HCFS URI of the jar file containing the main class (use this or the main_class, not both together).

  • main_class (str | None) – Name of the job class. (use this or the main_jar, not both together).

  • arguments (list | None) – Arguments for the job. (templated)

  • archives (list | None) – List of archived files that will be unpacked in the work directory. Should be stored in Cloud Storage.

  • files (list | None) – List of files to be copied to the working directory

template_fields: Sequence[str] = ('arguments', 'job_name', 'cluster_name', 'region', 'dataproc_jars', 'dataproc_properties',...[source]
ui_color = '#0273d4'[source]
job_type = 'hadoop_job'[source]
generate_job()[source]

Helper method for easier migration to DataprocSubmitJobOperator.

Returns

Dict representing Dataproc job

execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.dataproc.DataprocSubmitPySparkJobOperator(*, main, arguments=None, archives=None, pyfiles=None, files=None, **kwargs)[source]

Bases: DataprocJobBaseOperator

Start a PySpark Job on a Cloud DataProc cluster.

See also

This operator is deprecated, please use DataprocSubmitJobOperator:

Parameters
  • main (str) – [Required] The Hadoop Compatible Filesystem (HCFS) URI of the main Python file to use as the driver. Must be a .py file. (templated)

  • arguments (list | None) – Arguments for the job. (templated)

  • archives (list | None) – List of archived files that will be unpacked in the work directory. Should be stored in Cloud Storage.

  • files (list | None) – List of files to be copied to the working directory

  • pyfiles (list | None) – List of Python files to pass to the PySpark framework. Supported file types: .py, .egg, and .zip

template_fields: Sequence[str] = ('main', 'arguments', 'job_name', 'cluster_name', 'region', 'dataproc_jars',...[source]
ui_color = '#0273d4'[source]
job_type = 'pyspark_job'[source]
generate_job()[source]

Helper method for easier migration to DataprocSubmitJobOperator.

Returns

Dict representing Dataproc job

execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.dataproc.DataprocCreateWorkflowTemplateOperator(*, template, region, project_id=None, retry=DEFAULT, timeout=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Creates new workflow template.

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

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

  • template (dict) – The Dataproc workflow template to create. If a dict is provided, it must be of the same form as the protobuf message WorkflowTemplate.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float | None) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

template_fields: Sequence[str] = ('region', 'template')[source]
template_fields_renderers[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.dataproc.DataprocInstantiateWorkflowTemplateOperator(*, template_id, region, project_id=None, version=None, request_id=None, parameters=None, retry=DEFAULT, timeout=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), polling_interval_seconds=10, cancel_on_kill=True, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Instantiate a WorkflowTemplate on Google Cloud Dataproc.

The operator will wait until the WorkflowTemplate is finished executing.

Parameters
  • template_id (str) – The id of the template. (templated)

  • project_id (str | None) – The ID of the google cloud project in which the template runs

  • region (str) – The specified region where the dataproc cluster is created.

  • parameters (dict[str, str] | None) – a map of parameters for Dataproc Template in key-value format: map (key: string, value: string) Example: { “date_from”: “2019-08-01”, “date_to”: “2019-08-02”}. Values may not exceed 100 characters. Please refer to: https://cloud.google.com/dataproc/docs/concepts/workflows/workflow-parameters

  • request_id (str | None) – Optional. A unique id used to identify the request. If the server receives two SubmitJobRequest requests with the same id, then the second request will be ignored and the first Job created and stored in the backend is returned. It is recommended to always set this value to a UUID.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float | None) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • 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).

  • deferrable (bool) – Run operator in the deferrable mode.

  • polling_interval_seconds (int) – Time (seconds) to wait between calls to check the run status.

  • cancel_on_kill (bool) – Flag which indicates whether cancel the workflow, when on_kill is called

template_fields: Sequence[str] = ('template_id', 'impersonation_chain', 'request_id', 'parameters')[source]
template_fields_renderers[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

execute_complete(context, event=None)[source]

Callback for when the trigger fires.

This returns immediately. It relies on trigger to throw an exception, otherwise it assumes execution was successful.

on_kill()[source]

Override this method to clean up subprocesses when a task instance gets killed.

Any use of the threading, subprocess or multiprocessing module within an operator needs to be cleaned up, or it will leave ghost processes behind.

class airflow.providers.google.cloud.operators.dataproc.DataprocInstantiateInlineWorkflowTemplateOperator(*, template, region, project_id=None, request_id=None, retry=DEFAULT, timeout=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), polling_interval_seconds=10, cancel_on_kill=True, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Instantiate a WorkflowTemplate Inline on Google Cloud Dataproc.

The operator will wait until the WorkflowTemplate is finished executing.

See also

For more information on how to use this operator, take a look at the guide: Create a Cluster

For more detail on about instantiate inline have a look at the reference: https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.workflowTemplates/instantiateInline

Parameters
  • template (dict) – The template contents. (templated)

  • project_id (str | None) – The ID of the google cloud project in which the template runs

  • region (str) – The specified region where the dataproc cluster is created.

  • parameters – a map of parameters for Dataproc Template in key-value format: map (key: string, value: string) Example: { “date_from”: “2019-08-01”, “date_to”: “2019-08-02”}. Values may not exceed 100 characters. Please refer to: https://cloud.google.com/dataproc/docs/concepts/workflows/workflow-parameters

  • request_id (str | None) – Optional. A unique id used to identify the request. If the server receives two SubmitJobRequest requests with the same id, then the second request will be ignored and the first Job created and stored in the backend is returned. It is recommended to always set this value to a UUID.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float | None) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • 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).

  • deferrable (bool) – Run operator in the deferrable mode.

  • polling_interval_seconds (int) – Time (seconds) to wait between calls to check the run status.

  • cancel_on_kill (bool) – Flag which indicates whether cancel the workflow, when on_kill is called

template_fields: Sequence[str] = ('template', 'impersonation_chain')[source]
template_fields_renderers[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

execute_complete(context, event=None)[source]

Callback for when the trigger fires.

This returns immediately. It relies on trigger to throw an exception, otherwise it assumes execution was successful.

on_kill()[source]

Override this method to clean up subprocesses when a task instance gets killed.

Any use of the threading, subprocess or multiprocessing module within an operator needs to be cleaned up, or it will leave ghost processes behind.

class airflow.providers.google.cloud.operators.dataproc.DataprocSubmitJobOperator(*, job, region, project_id=None, request_id=None, retry=DEFAULT, timeout=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, asynchronous=False, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), polling_interval_seconds=10, cancel_on_kill=True, wait_timeout=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Submit a job to a cluster.

Parameters
  • project_id (str | None) – Optional. The ID of the Google Cloud project that the job belongs to.

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

  • job (dict) – Required. The job resource. If a dict is provided, it must be of the same form as the protobuf message Job. For the complete list of supported job types and their configurations please take a look here https://cloud.google.com/dataproc/docs/reference/rest/v1/projects.regions.jobs

  • request_id (str | None) – Optional. A unique id used to identify the request. If the server receives two SubmitJobRequest requests with the same id, then the second request will be ignored and the first Job created and stored in the backend is returned. It is recommended to always set this value to a UUID.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float | None) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • gcp_conn_id (str) –

  • 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).

  • asynchronous (bool) – Flag to return after submitting the job to the Dataproc API. This is useful for submitting long running jobs and waiting on them asynchronously using the DataprocJobSensor

  • deferrable (bool) – Run operator in the deferrable mode

  • polling_interval_seconds (int) – time in seconds between polling for job completion. The value is considered only when running in deferrable mode. Must be greater than 0.

  • cancel_on_kill (bool) – Flag which indicates whether cancel the hook’s job or not, when on_kill is called

  • wait_timeout (int | None) – How many seconds wait for job to be ready. Used only if asynchronous is False

template_fields: Sequence[str] = ('project_id', 'region', 'job', 'impersonation_chain', 'request_id')[source]
template_fields_renderers[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

execute_complete(context, event=None)[source]

Callback for when the trigger fires.

This returns immediately. It relies on trigger to throw an exception, otherwise it assumes execution was successful.

on_kill()[source]

Override this method to clean up subprocesses when a task instance gets killed.

Any use of the threading, subprocess or multiprocessing module within an operator needs to be cleaned up, or it will leave ghost processes behind.

class airflow.providers.google.cloud.operators.dataproc.DataprocUpdateClusterOperator(*, cluster_name, cluster, update_mask, graceful_decommission_timeout, region, request_id=None, project_id=None, retry=DEFAULT, timeout=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), polling_interval_seconds=10, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Update a cluster in a project.

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

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

  • cluster_name (str) – Required. The cluster name.

  • cluster (dict | google.cloud.dataproc_v1.Cluster) –

    Required. The changes to the cluster.

    If a dict is provided, it must be of the same form as the protobuf message Cluster

  • update_mask (dict | google.protobuf.field_mask_pb2.FieldMask) – Required. Specifies the path, relative to Cluster, of the field to update. For example, to change the number of workers in a cluster to 5, the update_mask parameter would be specified as config.worker_config.num_instances, and the PATCH request body would specify the new value. If a dict is provided, it must be of the same form as the protobuf message FieldMask

  • graceful_decommission_timeout (dict | google.protobuf.duration_pb2.Duration) – Optional. Timeout for graceful YARN decommissioning. Graceful decommissioning allows removing nodes from the cluster without interrupting jobs in progress. Timeout specifies how long to wait for jobs in progress to finish before forcefully removing nodes (and potentially interrupting jobs). Default timeout is 0 (for forceful decommission), and the maximum allowed timeout is 1 day.

  • request_id (str | None) – Optional. A unique id used to identify the request. If the server receives two UpdateClusterRequest requests with the same id, then the second request will be ignored and the first google.long-running.Operation created and stored in the backend is returned.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float | None) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • 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).

  • deferrable (bool) – Run operator in the deferrable mode.

  • polling_interval_seconds (int) – Time (seconds) to wait between calls to check the run status.

template_fields: Sequence[str] = ('cluster_name', 'cluster', 'region', 'request_id', 'project_id', 'impersonation_chain')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

execute_complete(context, event)[source]

Callback for when the trigger fires - returns immediately.

Relies on trigger to throw an exception, otherwise it assumes execution was successful.

class airflow.providers.google.cloud.operators.dataproc.DataprocCreateBatchOperator(*, region=None, project_id=None, batch, batch_id, request_id=None, retry=DEFAULT, timeout=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, result_retry=DEFAULT, asynchronous=False, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), polling_interval_seconds=5, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Create a batch workload.

Parameters
  • project_id (str | None) – Optional. The ID of the Google Cloud project that the cluster belongs to. (templated)

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

  • batch (dict | google.cloud.dataproc_v1.Batch) – Required. The batch to create. (templated)

  • batch_id (str) – Optional. The ID to use for the batch, which will become the final component of the batch’s resource name. This value must be 4-63 characters. Valid characters are /[a-z][0-9]-/. (templated)

  • request_id (str | None) – Optional. A unique id used to identify the request. If the server receives two CreateBatchRequest requests with the same id, then the second request will be ignored and the first google.longrunning.Operation created and stored in the backend is returned.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • result_retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Result retry object used to retry requests. Is used to decrease delay between executing chained tasks in a DAG by specifying exact amount of seconds for executing.

  • timeout (float | None) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • 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).

  • asynchronous (bool) – Flag to return after creating batch to the Dataproc API. This is useful for creating long-running batch and waiting on them asynchronously using the DataprocBatchSensor

  • deferrable (bool) – Run operator in the deferrable mode.

  • polling_interval_seconds (int) – Time (seconds) to wait between calls to check the run status.

template_fields: Sequence[str] = ('project_id', 'batch', 'batch_id', 'region', 'impersonation_chain')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

execute_complete(context, event=None)[source]

Callback for when the trigger fires.

This returns immediately. It relies on trigger to throw an exception, otherwise it assumes execution was successful.

on_kill()[source]

Override this method to clean up subprocesses when a task instance gets killed.

Any use of the threading, subprocess or multiprocessing module within an operator needs to be cleaned up, or it will leave ghost processes behind.

handle_batch_status(context, state, batch_id)[source]
class airflow.providers.google.cloud.operators.dataproc.DataprocDeleteBatchOperator(*, batch_id, region, project_id=None, retry=DEFAULT, timeout=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Delete the batch workload resource.

Parameters
  • batch_id (str) – Required. The ID to use for the batch, which will become the final component of the batch’s resource name. This value must be 4-63 characters. Valid characters are /[a-z][0-9]-/.

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

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

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float | None) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • 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).

template_fields: Sequence[str] = ('batch_id', 'region', 'project_id', 'impersonation_chain')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.dataproc.DataprocGetBatchOperator(*, batch_id, region, project_id=None, retry=DEFAULT, timeout=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Get the batch workload resource representation.

Parameters
  • batch_id (str) – Required. The ID to use for the batch, which will become the final component of the batch’s resource name. This value must be 4-63 characters. Valid characters are /[a-z][0-9]-/.

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

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

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float | None) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • 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).

template_fields: Sequence[str] = ('batch_id', 'region', 'project_id', 'impersonation_chain')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.dataproc.DataprocListBatchesOperator(*, region, project_id=None, page_size=None, page_token=None, retry=DEFAULT, timeout=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, filter=None, order_by=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

List batch workloads.

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

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

  • page_size (int | None) – Optional. The maximum number of batches to return in each response. The service may return fewer than this value. The default page size is 20; the maximum page size is 1000.

  • page_token (str | None) – Optional. A page token received from a previous ListBatches call. Provide this token to retrieve the subsequent page.

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – Optional, a retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float | None) – Optional, the amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • 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).

  • filter (str | None) – Result filters as specified in ListBatchesRequest

  • order_by (str | None) – How to order results as specified in ListBatchesRequest

template_fields: Sequence[str] = ('region', 'project_id', 'impersonation_chain')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

class airflow.providers.google.cloud.operators.dataproc.DataprocCancelOperationOperator(*, operation_name, region, project_id=None, retry=DEFAULT, timeout=None, metadata=(), gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

Bases: airflow.providers.google.cloud.operators.cloud_base.GoogleCloudBaseOperator

Cancel the batch workload resource.

Parameters
  • operation_name (str) – Required. The name of the operation resource to be cancelled.

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

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

  • retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If None is specified, requests will not be retried.

  • timeout (float | None) – The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

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

  • gcp_conn_id (str) – The connection ID to use connecting to Google Cloud.

  • 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).

template_fields: Sequence[str] = ('operation_name', 'region', 'project_id', 'impersonation_chain')[source]
execute(context)[source]

Derive when creating an operator.

Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?