2 回答
TA贡献1111条经验 获得超0个赞
有一个名为的运算符DataprocClusterCreateOperator将为您创建 Dataproc 集群。
检查https://airflow.apache.org/_api/airflow/contrib/operators/dataproc_operator/index.html#module-airflow.contrib.operators.dataproc_operatorDataprocClusterCreateOperator的文档
from airflow.contrib.operators import dataproc_operator
create_dataproc_cluster = dataproc_operator.DataprocClusterCreateOperator(
task_id='create_dataproc_cluster',
# Give the cluster a unique name by appending the date scheduled.
# See https://airflow.apache.org/code.html#default-variables
cluster_name='hadoop-cluster',
num_workers=2,
zone='europe-west1-b',
master_machine_type='n1-standard-1',
worker_machine_type='n1-standard-1',
dag=dag)
TA贡献1772条经验 获得超8个赞
是的,我们需要使用 DataprocClusterCreateOperator。首先我们需要导入dataproc_operator,然后我们还需要使用dag参数传递所有参数,否则会出现错误
from airflow.contrib.operators import dataproc_operator
create_dataproc_cluster = dataproc_operator.DataprocClusterCreateOperator(
task_id='create_dataproc_cluster',
project_id='trim-karma-248213',
cluster_name='airflow-cluster',
num_workers=2,
zone='europe-west1-c',
master_machine_type='n1-standard-1',
worker_machine_type='n1-standard-1',
dag=dag)
添加回答
举报