시작하기 전에
- 실습에서는 정해진 기간 동안 Google Cloud 프로젝트와 리소스를 만듭니다.
- 실습에는 시간 제한이 있으며 일시중지 기능이 없습니다. 실습을 종료하면 처음부터 다시 시작해야 합니다.
- 화면 왼쪽 상단에서 실습 시작을 클릭하여 시작합니다.
In this lab, you run Dataflow pipelines to serve predictions for batch requests and streaming in real time.
In this lab, you learn how to perform the following tasks:
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.
Cloud Shell is a virtual machine that contains development tools. It offers a persistent 5-GB home directory and runs on Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources. gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab completion.
Click the Activate Cloud Shell button () at the top right of the console.
Click Continue.
It takes a few moments to provision and connect to the environment. When you are connected, you are also authenticated, and the project is set to your PROJECT_ID.
(Output)
(Example output)
(Output)
(Example output)
Before you begin working on Google Cloud, you must ensure that your project has the correct permissions within Identity and Access Management (IAM).
In the Google Cloud console, on the Navigation menu (), click 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.
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.
From the Project info card, copy the Project number.
On the Navigation menu, click IAM & Admin > IAM.
At the top of the IAM page, click Add.
For New principals, type:
Replace {project-number} with your project number.
For Select a role, select Basic (or Project) > Editor.
Click Save.
In the Google Cloud Console, on the Navigation Menu, click Vertex AI > Workbench. Select User-Managed Notebooks.
On the Notebook instances page, Click Create New and choose the latest version of TensorFlow Enterprise 2.6 (with LTS) in Environment.
In the New notebook instance dialog, confirm the name of the deep learning VM, if you don’t want to change the region and zone, leave all settings as they are and then click Create. The new VM will take 2-3 minutes to start.
Click Open JupyterLab.
A JupyterLab window will open in a new tab.
The GitHub repo contains both the lab file and solutions files for the course.
training-data-analyst repository.training-data-analyst directory and ensure that you can see its contents.In this task, you navigate to the notebook for this lab. You then clear all outputs to reset the notebook and then complete the lines required in order to run the code.
In the notebook interface, navigate to training-data-analyst > courses > machine_learning > deepdive2 > production_ml > labs, and open serving_ml_prediction.ipynb.
In the notebook interface, click Edit > Clear All Outputs.
Carefully read through the notebook instructions and fill in lines marked with a #TODO where you need to complete the code. Don't forget to set your PROJECT ID in the #Replace with your PROJECT field.
Hints may also be provided for the tasks to guide you along. Highlight the text to read the hints (they are in white text).
If you need more help, look at the complete solution at training-data-analyst > courses > machine_learning > deepdive2 > production_ml > solutions, and open serving_ml_prediction.ipynb.
In this task, you clone the course repository and explore the folder that contains code for this lab. You then run a script that highlights which code you need to add or modify.
A list of filenames is returned, and lines within those files are marked with TODO. These are the lines where you have to add/modify code. For this lab, you will focus on #TODO items for .java files only, namely BabyweightMLService.java : which is your prediction service.
In this task, you fix the code in BabyweightMLService.java and test it with the run\_once.sh script that is provided. If you need help with the code, look at the next section that provides hints on how to fix code in BabyweightMLService.java.
On the Cloud Shell toolbar, click Open Editor. You can use the Cloud Shell code editor to view and edit the contents of these files.
Navigate to the following directory: training-data-analyst > courses> machine_learning > deepdive > 06_structured > labs > serving > pipeline > src > main > java > com > google > cloud > training > mlongcp.
Open the BabyweightMLService.java files and replace #TODOs in the code.
In Cloud Shell, run the following script to test your ML service:
In this task, you call AddPrediction.java, which takes a batch input (one big CSV), calls the prediction service to generate babyweight predictions, and writes them into local files (multiple CSVs).
In your Cloud Shell code editor, open the AddPrediction.java file available in the following directory: training-data-analyst > courses> machine_learning > deepdive > 06_structured > labs > serving > pipeline > src > main > java > com > google > cloud > training > mlongcp.
Look through the code and notice how, based on input argument, it decides to set up a batch or streaming pipeline and creates the appropriate TextInputOutput or PubSubBigQuery io object respectively to handle the reading and writing.
run_ontext.sh script provided in the lab directory:In this task you launch a streaming pipeline with Dataflow, which will accept incoming information from Pub/Sub, use the information to call the prediction service to get babyweight predictions, and finally write that information into a BigQuery table.
In the Google Cloud Console, on the Navigation menu, click Pub/Sub.
Click Create topic, and create a topic called babies.
Return to Cloud Shell, modify the script run_dataflow.sh to get Project ID (using --project) from command line arguments, and then run the following code:
This will create a streaming Dataflow pipeline.
./run_dataflow.sh.Click on the job name to view the pipeline graph.
Click on the pipeline steps (boxes) and look at the run details (like system lag, elements added, etc.) of that step.
This means that your pipeline is running and waiting for input. You can provide input through the Pub/Sub topic.
In the Google Cloud Console, return to the Pub/Sub page and click on the babies topic.
On the bottom panel click on Messages and then click Publish message.
In the message box, paste the lines you just copied from exampledata.csv.gz, and click Publish.
In the Google Cloud Console, return to the Dataflow page, click on your job, and see how the run details have changed for the steps; for example, click on write_toBQ and look at Elements added.
Verify that the predicted weights have been recorded in the BigQuery table.
In the Google Cloud Console, on the Navigation menu, click BigQuery.
The Welcome to BigQuery in the Cloud Console message box opens.
Click Done.
On the Explorer tab, expand your Google Cloud Project ID.
The babyweight dataset is listed, and the predictions table is nested under the dataset.
Remember that your pipeline is still running. You can publish additional messages from your example.csv.gz and verify new rows added to your predictions table. When you are satisfied, to stop the Dataflow pipeline,
On the Dataflow Jobs page, click Stop.
Select Drain, and then click Stop Job.
In this lab you learned how to:
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:
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.
현재 이 콘텐츠를 이용할 수 없습니다
이용할 수 있게 되면 이메일로 알려드리겠습니다.
감사합니다
이용할 수 있게 되면 이메일로 알려드리겠습니다.
한 번에 실습 1개만 가능
모든 기존 실습을 종료하고 이 실습을 시작할지 확인하세요.