Event-Driven ML Retraining with Cloud Storage and Pub/Sub

PMLE By islever Editorial Last updated

Developing end-to-end ML pipelines. Training models.

Short answer

C Use a Cloud Storage trigger to publish a Pub/Sub message, then deploy a Pub/Sub-triggered Cloud Function to start the Kubeflow Pipelines training job on GKE.

Question

You work with a data engineering team that has developed a pipeline to clean your dataset and save it in a Cloud Storage bucket. You have created an ML model
and want to use the data to refresh your model as soon as new data is available. As part of your CI/CD workflow, you want to automatically run a Kubeflow
Pipelines training job on Google Kubernetes Engine (GKE). How should you architect this workflow?
  1. Configure your pipeline with Dataflow, which saves the files in Cloud Storage. After the file is saved, start the training job on a GKE cluster.
  2. Use App Engine to create a lightweight python client that continuously polls Cloud Storage for new files. As soon as a file arrives, initiate the training job.
  3. Configure a Cloud Storage trigger to send a message to a Pub/Sub topic when a new file is available in a storage bucket. Use a Pub/Sub-triggered Cloud Function to start the training job on a GKE cluster. Correct Answer
  4. Use Cloud Scheduler to schedule jobs at a regular interval. For the first step of the job, check the timestamp of objects in your Cloud Storage bucket. If there are no new files since the last run, abort the job.

Key Takeaways

The question tests the ability to choose an event-driven architecture over polling or scheduling for real-time model updates, specifically utilizing Cloud Storage's Pub/Sub integration.

Learn how to architect an automated ML retraining workflow using Cloud Storage events, Pub/Sub, and Cloud Functions to trigger Kubeflow Pipelines on GKE efficiently.

Common mistake: Candidates often choose Option A, assuming the data pipeline should directly control downstream processes. However, this creates tight coupling and operational overhead, whereas Option C provides a cleaner, decoupled, and more scalable solution.

Expert Analysis

The core requirement is to trigger an ML training job as soon as new data becomes available, integrating with an existing CI/CD workflow. This demands an event-driven architecture rather than a polling or scheduled one.

Option C leverages Cloud Storage's native integration with Pub/Sub. When a new file lands in the bucket, it publishes a message to a Pub/Sub topic. A Cloud Function, triggered by this subscription, then initiates the Kubeflow Pipelines job on GKE. This approach ensures immediate reaction to new data, minimizes resource waste (no constant polling), and decouples the storage layer from the compute layer, which aligns perfectly with modern MLOps practices.

Option A suggests modifying the Dataflow pipeline itself to start the training job. While technically possible via service accounts, it tightly couples the data engineering pipeline with the model training workflow, violating separation of concerns and making the system harder to maintain across teams. The comments highlight that relying on the data team to modify their pipelines for ML triggers is error-prone and cumbersome.

Options B and D rely on polling mechanisms. Option B uses App Engine to continuously check for files, which incurs unnecessary costs and latency due to the polling interval. Option D uses Cloud Scheduler to run at regular intervals, leading to delays between data availability and model retraining, as well as wasted compute cycles when no new data exists. For "as soon as" requirements, event-driven architectures are superior.

Official Reference

Exam Strategy

When a question specifies 'as soon as' or 'immediately' upon a data change, prioritize event-driven solutions involving Pub/Sub and Cloud Functions over polling (App Engine/Cloud Run loops) or scheduling (Cloud Scheduler). Look for native integrations like Cloud Storage triggers publishing to Pub/Sub, which provide the lowest latency and cost efficiency for reactive workflows.

Frequently Asked Questions

Why not use Cloud Scheduler to check for new files?

Cloud Scheduler runs at fixed intervals. If you schedule it every hour, there could be up to an hour of delay before the model retrains. Event-driven approaches react instantly.

Can Dataflow start the training job directly?

Technically yes, but it couples the data pipeline with the training workflow. Using Pub/Sub decouples them, allowing independent scaling and maintenance of each component.

More PMLE FAQ →

Community Votes

C
89%
A
11%

89% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 13 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 13

  1. Paul_Dirac 👍 7
    C https://cloud.google.com/architecture/architecture-for-mlops-using-tfx-kubeflow-pipelines-and-cloud-build#triggering-and-scheduling-kubeflow-pipelines
  2. hiromi 👍 2 Answered C
    C Pubsub is the keyword
  3. Fatiy 👍 1 Answered C
    The scenario involves automatically running a Kubeflow Pipelines training job on GKE as soon as new data becomes available. To achieve this, we can use Cloud Storage to store the cleaned dataset, and then configure a Cloud Storage trigger that sends a message to a Pub/Sub topic whenever a new file is added to the storage bucket. We can then create a Pub/Sub-triggered Cloud Function that starts the training job on a GKE cluster.
  4. taylz876 👍 1 Answered C
    C - You want training to start as soon as new data is available. That's an event-driven design, where the arrival of the file is the trigger: 1. A new cleaned file lands in Cloud Storage. 2. Cloud Storage publishes a message to Pub/Sub. 3. A Cloud Function receives the message and starts the Kubeflow Pipelines training job on GKE. It reacts immediately, runs only when needed, and needs no manual steps.
  5. behzadsw 👍 1 Answered A
    The question says: As part of your CI/CD workflow, you want to automatically run a Kubeflow.. C is also an option but it seems more cumbersome. One thing hat could be against A is that the data engineering team is separate team so they might not access your CI/CD if any changes from their side is needed..
Show 8 more comments
  1. ori5225 👍 1
    On a schedule, using Cloud Scheduler. Responding to an event, using Pub/Sub and Cloud Functions. For example, the event can be the availability of new data files in a Cloud Storage bucket.
  2. tavva_prudhvi 👍 1
    Option D requires the job to be scheduled at regular intervals, even if there are no new files. This can waste resources and lead to unnecessary delays in the training process.
  3. tavva_prudhvi 👍 1
    Option A requires the data engineering team to modify the pipeline, which can be time-consuming and error-prone.
  4. Mohamed_Mossad 👍 1 Answered C
    event driven architecture is better than polling based architecure so I will vote for C
  5. PhilipKoku 👍 1 Answered C
    C) PUB/sub trigger from Cloud Storage & Cloud Function
  6. Sum_Sum 👍 1 Answered C
    C- because you don't want to re-engineer the pipeline
  7. fragkris 👍 1 Answered C
    C - This is the google reccomended method.
  8. M25 👍 1 Answered C
    Went with C

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All PMLE Questions

Access 65 questions with complete answers and detailed explanations.

View Full PMLE Practice Test →

← Back to PMLE Study Guide