目前,这些是options,用于调度我知道的数据流作业的执行:
答案 0 :(得分:0)
有多种方法,但是我认为对您来说非常方便的一种方法是使用Apache Airflow的DataflowPythonOperator。
GCP以Cloud Composer的形式为Apache Airflow提供托管服务,可用于安排数据流管道或其他GCP操作。
答案 1 :(得分:0)
我将App Engine Flex用作数据流启动器。该微服务具有可以按需启动数据流作业的端点,而cron也会击中该作业。
这是我的项目结构:
df_tasks/
- __init__.py
- datastore_to_csv.py
- ...other_piplines
__init__.py
dflaunch.yaml
main.py
setup.py <-- used by pipelines
对我来说,诀窍是正确设置管道依赖项。即,将setup.py用于管道依赖项。像此示例一样进行设置最多可以帮助您: https://github.com/apache/beam/tree/master/sdks/python/apache_beam/examples/complete/juliaset
setup.py:
import setuptools
setuptools.setup(
name='dataflow_python_pipeline',
version='1.0.0',
description='DataFlow Python Pipeline',
packages=setuptools.find_packages(),
)
我在df_tasks
中的管道配置如下所示:
pipeline_options = PipelineOptions.from_dictionary({
'project': project,
'runner': 'DataflowRunner',
'staging_location': bucket_path+'/staging',
'temp_location': bucket_path+'/temp',
'setup_file': './setup.py'
})
然后在main.py中:
from df_tasks import datastore_to_csv
project_id = os.environ['GCLOUD_PROJECT']
@app.route('/datastore-to-csv', methods=['POST'])
def df_day_summary():
# Extract Payload
payload = request.get_json()
model = payload['model']
for_date = datetime.datetime.strptime(payload['for_date'], '%Y/%m/%d')
except Exception as e:
print traceback.format_exc()
return traceback.format_exc()
# launch the job
try:
job_id, job_name = datastore_to_csv.run(
project=project_id,
model=model,
for_date=for_date,
)
# return the job id
return jsonify({'jobId': job_id, 'jobName': job_name})
except Exception as e:
print traceback.format_exc()
return traceback.format_exc()