【发布时间】:2020-09-22 03:24:41
【问题描述】:
我使用 gcp_dataproc_hook 通过气流在 GCP 数据过程中运行作业。 在每个作业执行之前,使用检查该作业是否可以附加到先前执行的作业的钩子。
当附加作业时,除非我删除前一个(附加的)作业,否则 dataproc 不会执行该作业
由于这个流程,我丢失了很多元数据和日志。
有没有办法禁用附件?
这是创建附件的钩子中的代码:
# There is a small set of states that we will accept as sufficient
# for attaching the new task instance to the old Dataproc job. We
# generally err on the side of _not_ attaching, unless the prior
# job is in a known-good state. For example, we don't attach to an
# ERRORed job because we want Airflow to be able to retry the job.
# The full set of possible states is here:
# https://cloud.google.com/dataproc/docs/reference/rest/v1beta2/projects.regions.jobs#State
recoverable_states = frozenset([
'PENDING',
'SETUP_DONE',
'RUNNING',
'DONE',
])
found_match = False
for job_on_cluster in jobs_on_cluster:
job_on_cluster_id = job_on_cluster['reference']['jobId']
job_on_cluster_task_id = job_on_cluster_id[:-UUID_LENGTH]
if task_id_to_submit == job_on_cluster_task_id:
self.job = job_on_cluster
self.job_id = self.job['reference']['jobId']
found_match = True
# We can stop looking once we find a matching job in a recoverable state.
if self.job['status']['state'] in recoverable_states:
break
if found_match and self.job['status']['state'] in recoverable_states:
message = """
Reattaching to previously-started DataProc job %s (in state %s).
If this is not the desired behavior (ie if you would like to re-run this job),
please delete the previous instance of the job by running:
gcloud --project %s dataproc jobs delete %s --region %s
"""
【问题讨论】:
-
嗨!您是否在 Cloud Composer 中运行 Airflow?
-
嗨@muscat,我没有在本地运行气流并连接到 GCP
-
您在提交作业时是否考虑过使用新的
job_id?
标签: python-3.x google-cloud-platform airflow