You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[`main.py`](main.py) - Script to run an [Apache Beam] template on [Google Cloud Dataflow].
3
+
[](https://console.cloud.google.com/cloudshell/editor)
4
4
5
-
The following examples show how to run the [`Word_Count` template], but you can run any other template.
For the `Word_Count` template, we require to pass an `output` Cloud Storage path prefix, and optionally we can pass an `inputFile` Cloud Storage file pattern for the inputs.
@@ -58,18 +55,18 @@ The following instructions will help you prepare your development environment.
58
55
59
56
1. Install the sample requirements.
60
57
61
-
```bash
58
+
```sh
62
59
pip install -U -r requirements.txt
63
60
```
64
61
65
62
## Running locally
66
63
67
-
To run a Dataflow template from the command line.
64
+
*[`main.py`](main.py)
65
+
*[REST API dataflow/projects.templates.launch](https://cloud.google.com/dataflow/docs/reference/rest/v1b3/projects.templates/launch)
68
66
69
-
> NOTE: To run locally, you'll need to [create a service account key] as a JSON file.
70
-
> Then export an environment variable called `GOOGLE_APPLICATION_CREDENTIALS` pointing it to your service account file.
67
+
To run a Dataflow template from the command line.
71
68
72
-
```bash
69
+
```sh
73
70
python main.py \
74
71
--project <your-gcp-project> \
75
72
--job wordcount-$(date +'%Y%m%d-%H%M%S') \
@@ -80,10 +77,10 @@ python main.py \
80
77
81
78
## Running in Python
82
79
83
-
To run a Dataflow template from Python.
80
+
*[`main.py`](main.py)
81
+
*[REST API dataflow/projects.templates.launch](https://cloud.google.com/dataflow/docs/reference/rest/v1b3/projects.templates/launch)
84
82
85
-
> NOTE: To run locally, you'll need to [create a service account key] as a JSON file.
86
-
> Then export an environment variable called `GOOGLE_APPLICATION_CREDENTIALS` pointing it to your service account file.
83
+
To run a Dataflow template from Python.
87
84
88
85
```py
89
86
import main as run_template
@@ -101,9 +98,12 @@ run_template.run(
101
98
102
99
## Running in Cloud Functions
103
100
101
+
*[`main.py`](main.py)
102
+
*[REST API dataflow/projects.templates.launch](https://cloud.google.com/dataflow/docs/reference/rest/v1b3/projects.templates/launch)
103
+
104
104
To deploy this into a Cloud Function and run a Dataflow template via an HTTP request as a REST API.
[Create a service account key]: https://console.cloud.google.com/apis/credentials/serviceaccountkey
133
-
[Creating and managing service accounts]: https://cloud.google.com/iam/docs/creating-managing-service-accounts
134
-
[GCP Console IAM page]: https://console.cloud.google.com/iam-admin/iam
135
-
[Granting roles to service accounts]: https://cloud.google.com/iam/docs/granting-roles-to-service-accounts
136
-
137
-
[Install Python and virtualenv]: https://cloud.google.com/python/setup
0 commit comments