Dieser Inhalt ist noch nicht für Mobilgeräte optimiert.
Die Lernumgebung funktioniert am besten, wenn Sie auf einem Computer über einen per E‑Mail gesendeten Link darauf zugreifen.
Overview
In this lab, you will open a Dataflow project, use pipeline filtering, and execute the pipeline locally and on the cloud.
Open Dataflow project
Pipeline filtering
Execute the pipeline locally and on the cloud
Objective
In this lab, you learn how to write a simple Dataflow pipeline and run it both locally and on the cloud.
Setup a Python Dataflow project using Apache Beam
Write a simple pipeline in Python
Execute the query on the local machine
Execute the query on the cloud
Setup
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Google Skills using an incognito window.
Note the lab's access time (for example, 1:15:00), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
Activate Google Cloud Shell
Google Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud.
Google Cloud Shell provides command-line access to your Google Cloud resources.
In Cloud console, on the top right toolbar, click the Open Cloud Shell button.
Click Continue.
It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. For example:
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
You can list the active account name with this command:
[core]
project = qwiklabs-gcp-44776a13dea667a6
Note:
Full documentation of gcloud is available in the
gcloud CLI overview guide
.
Check project permissions
Before you begin your work on Google Cloud, you need to ensure that your project has the correct permissions within Identity and Access Management (IAM).
In the Google Cloud console, on the Navigation menu (), select IAM & Admin > IAM.
Confirm that the default compute Service Account {project-number}-compute@developer.gserviceaccount.com is present and has the editor role assigned. The account prefix is the project number, which you can find on Navigation menu > Cloud Overview > Dashboard.
Note: If the account is not present in IAM or does not have the editor role, follow the steps below to assign the required role.
In the Google Cloud console, on the Navigation menu, click Cloud Overview > Dashboard.
Copy the project number (e.g. 729328892908).
On the Navigation menu, select IAM & Admin > IAM.
At the top of the roles table, below View by Principals, click Grant Access.
In the Console, on the Navigation menu, click Cloud Storage > Buckets.
Click + Create.
Specify the following, and leave the remaining settings as their defaults:
Property
Value (type value or select option as specified)
Name
Location type
Multi-region
Click Create.
If you get the Public access will be prevented prompt, select Enforce public access prevention on this bucket and click Confirm.
Record the name of your bucket. You will need it in subsequent tasks.
In the training-vm SSH terminal enter the following to create an environment variable named "BUCKET" and verify that it exists with the echo command:
BUCKET="{{{project_0.project_id| PROJECT ID }}}"
echo $BUCKET
You can use $BUCKET in terminal commands. And if you need to enter the bucket name <your-bucket> in a text field in the console, you can quickly retrieve the name with echo $BUCKET.
Task 3. Pipeline filtering
The goal of this lab is to become familiar with the structure of a Dataflow project and learn how to execute a Dataflow pipeline.
Return to the training-vm SSH terminal and navigate to the directory /training-data-analyst/courses/data_analysis/lab2/python and view the file grep.py.
View the file with Nano. Do not make any changes to the code:
cd ~/training-data-analyst/courses/data_analysis/lab2/python
nano grep.py
Press CTRL+X to exit Nano.
Can you answer these questions about the file grep.py?
What files are being read?
What is the search term?
Where does the output go?
There are three transforms in the pipeline:
What does the transform do?
What does the second transform do?
Where does its input come from?
What does it do with this input?
What does it write to its output?
Where does the output go?
What does the third transform do?
Task 4. Execute the pipeline locally
In the training-vm SSH terminal, locally execute grep.py:
python3 grep.py
Note: Ignore the warning if any.
The output file will be output.txt. If the output is large enough, it will be sharded into separate parts with names like: output-00000-of-00001.
Locate the correct file by examining the file's time:
ls -al /tmp
Examine the output file(s).
You can replace "-*" below with the appropriate suffix:
cat /tmp/output-*
Does the output seem logical?
Task 5. Execute the pipeline on the cloud
Copy some Java files to the cloud. In the training-vm SSH terminal, enter the following command:
Using Nano, edit the Dataflow pipeline in grepc.py:
nano grepc.py
Replace PROJECT, BUCKET, and REGION with the values listed below. Please retain the outside single quotes.
PROJECT='{{{project_0.project_id| PROJECT ID }}}'
BUCKET='{{{project_0.project_id| PROJECT ID }}}'
REGION='{{{project_0.default_region| REGION }}}'
Save the file and close Nano by pressing the CTRL+X key, then type Y, and press Enter.
Submit the Dataflow job to the cloud:
python3 grepc.py
Because this is such a small job, running on the cloud will take significantly longer than running it locally (on the order of 7-10 minutes).
Return to the browser tab for the console.
On the Navigation menu, click VIEW ALL PRODUCTS. In the Analytics section, click Dataflow and click on your job to monitor progress.
Wait for the Job status to be Succeeded.
Examine the output in the Cloud Storage bucket.
On the Navigation menu, click Cloud Storage > Buckets and click on your bucket.
Click the javahelp directory.
This job generates the file output.txt. If the file is large enough, it will be sharded into multiple parts with names like: output-0000x-of-000y. You can identify the most recent file by name or by the Last modified field.
Click on the file to view it.
Alternatively, you can download the file via the training-vm SSH terminal and view it:
When you have completed your lab, click End Lab. Google Skills removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
1 star = Very dissatisfied
2 stars = Dissatisfied
3 stars = Neutral
4 stars = Satisfied
5 stars = Very satisfied
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2026 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
Labs erstellen ein Google Cloud-Projekt und Ressourcen für einen bestimmten Zeitraum
Labs haben ein Zeitlimit und keine Pausenfunktion. Wenn Sie das Lab beenden, müssen Sie von vorne beginnen.
Klicken Sie links oben auf dem Bildschirm auf Lab starten, um zu beginnen
Privates Surfen verwenden
Kopieren Sie den bereitgestellten Nutzernamen und das Passwort für das Lab
Klicken Sie im privaten Modus auf Konsole öffnen
In der Konsole anmelden
Melden Sie sich mit Ihren Lab-Anmeldedaten an. Wenn Sie andere Anmeldedaten verwenden, kann dies zu Fehlern führen oder es fallen Kosten an.
Akzeptieren Sie die Nutzungsbedingungen und überspringen Sie die Seite zur Wiederherstellung der Ressourcen
Klicken Sie erst auf Lab beenden, wenn Sie das Lab abgeschlossen haben oder es neu starten möchten. Andernfalls werden Ihre bisherige Arbeit und das Projekt gelöscht.
Diese Inhalte sind derzeit nicht verfügbar
Bei Verfügbarkeit des Labs benachrichtigen wir Sie per E-Mail
Sehr gut!
Bei Verfügbarkeit kontaktieren wir Sie per E-Mail
Es ist immer nur ein Lab möglich
Bestätigen Sie, dass Sie alle vorhandenen Labs beenden und dieses Lab starten möchten
Privates Surfen für das Lab verwenden
Am besten führen Sie dieses Lab in einem Inkognito- oder privaten Browserfenster aus. So vermeiden Sie Konflikte zwischen Ihrem privaten Konto und dem Teilnehmerkonto, die zusätzliche Kosten für Ihr privates Konto verursachen könnten.
In this lab, you learn how to write a simple Dataflow pipeline and run it both locally and on the cloud.