-
Notifications
You must be signed in to change notification settings - Fork 0
/
trigger_df_job.py
29 lines (23 loc) · 1010 Bytes
/
trigger_df_job.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from googleapiclient.discovery import build
import base64
import google.auth
import os
def hello_pubsub():
service = build('dataflow', 'v1b3')
project = "prj-poc-001"
template_path = "gs://dataflow-templates-us-central1/latest/GCS_Text_to_BigQuery"
template_body = {
"jobName": "bq-load", # Provide a unique name for the job
"parameters": {
"javascriptTextTransformGcsPath": "gs://bkt-dataflow-metadata/udf.js",
"JSONPath": "gs://bkt-dataflow-metadata/bq.json",
"javascriptTextTransformFunctionName": "transform",
"outputTable": "prj-poc-001:cricket_dataset.icc_odi_batsman_ranking",
"inputFilePattern": "gs://bkt-dataflow-metadata/batsmen_rankings.csv",
"bigQueryLoadingTemporaryDirectory": "gs://bkt-dataflow-metadata",
}
}
request = service.projects().templates().launch(projectId=project,gcsPath=template_path, body=template_body)
response = request.execute()
print(response)
hello_pubsub()