这是我的代码。
当我运行以下代码时,我收到以下错误。我正在尝试使用gcp-variant-transforms api将我的google云存储中的gvcf / vcf文件转换为bigquery。
[2018-06-06 16:46:42,589] {models.py:1428}信息 - 执行于2018-06-06 21:46:34.252526 [2018-06-06 16:46:42,589] {base_task_runner.py:115}信息 - 运行:['bash',' - c',u'airflow运行GcsToBigQuery gcsToBigquery_ID 2018-06-06T21:46:34.252526 - job_id 168 --raw -sd DAGS_FOLDER / GcsToBigQuery.py'] [2018-06-06 16:46:43,204] {base_task_runner.py:98}信息 - 子任务:[2018-06-06 16:46:43,202] { init .py:45} INFO - 使用执行程序SequentialExecutor [2018-06-06 16:46:43,484] {base_task_runner.py:98}信息 - 子任务:[2018-06-06 16:46:43,483] {models.py:189}信息 - 从/填充DagBag应用/气流/ DAG的/ GcsToBigQuery.py [2018-06-06 16:46:43,853] {base_task_runner.py:98} INFO - 子任务:[2018-06-06 16:46:43,852] {gcp_dataflow_hook.py:111}信息 - 开始等待DataFlow进程到完成。 [2018-06-06 16:46:46,931] {base_task_runner.py:98}信息 - 子任务:[2018-06-06 16:46:46,930] {GcsToBigQuery.py:48}错误 - 状态:失败:gcsToBigquery:无法运行: DataFlow失败,返回码为1 [2018-06-06 16:46:46,931] {base_task_runner.py:98}信息 - 子任务:[2018-06-06 16:46:46,930] {python_operator.py:90}信息 - 完成。返回值为:无
请帮我解决这个问题。谢谢!
from datetime import datetime, timedelta
from airflow import DAG
from airflow.contrib.hooks.gcp_dataflow_hook import DataFlowHook
from airflow.operators.python_operator import PythonOperator
import logging
default_args = {
'owner': 'My Name',
'depends_on_past': False,
'start_date': datetime(2018, 6, 6),
'email': ['MY Email'],
'email_on_failure': True,
'email_on_retry': False,
'retries': 2,
'retry_delay': timedelta(minutes=5)
}
dag = DAG('GcsToBigQuery', default_args=default_args,
description='To move GVCF/VCF files from Google Cloud Storage to Big Query',
schedule_interval='@once',
start_date=datetime(2018, 6, 6))
dataflow_py_file = 'gcp_variant_transforms.vcf_to_bq'
PY_OPTIONS = ['-m']
DATAFLOW_OPTIONS_PY = {
"project": "project-Name",
"input_pattern": "gs://test-gvcf/1000-genomes.vcf",
"output_table": "trc-mayo-projectsample:1000genomicsID.1000_genomesSamp",
"staging_location": "gs://test-gvcf/vcftobq/staging",
"temp_location": "gs://test-gvcf/vcftobq/temp",
"job_name": "dataflowstarter25",
#"setup_file": "./setup.py",
"runner": "DataflowRunner"
}
def gcsToBigquery():
try:
dataflowHook = DataFlowHook(gcp_conn_id='google_cloud_platform_id')
dataflowHook.start_python_dataflow(task_id='dataflowStarter2_ID', variables=DATAFLOW_OPTIONS_PY,
dataflow=dataflow_py_file, py_options=PY_OPTIONS)
except Exception as e:
logging.error("Status : FAIL : gcsToBigquery: Not able to run: " + str(e.message))
gcsToBigquery_task = PythonOperator(task_id='gcsToBigquery_ID',
python_callable=gcsToBigquery,
dag=dag)
答案 0 :(得分:1)
通过使用DataflowPythonOperator并在云实例中安装gcp_variant_transforms
API可以避免此问题。
安装所需组件的命令:
sudo pip install git+https://github.com/googlegenomics/gcp-variant-transforms.git