How googlecloudplatform/mlops-with-vertex-ai works
1. Repository purpose
- This is an end-to-end MLOps sample for Vertex AI on Google Cloud.
- It covers the full lifecycle: data exploration, feature processing, model training, pipeline orchestration, CI/CD, deployment, prediction serving, and monitoring.
2. Primary user-facing entrypoints
- The main workflow is documented through the numbered Jupyter notebooks (01-... to 08-...).
- Those notebooks act as the operational “chapters” of the system and are the clearest high-level architecture guide for how the pieces fit together.
3. Data source and dataset management
- The source dataset is Chicago Taxi Trips in BigQuery.
- The repository treats BigQuery as the raw analytical data source, then creates a Vertex AI Dataset resource and a raw schema (src/raw_schema/schema.pbtxt) for validation.
- This is the first boundary: public warehouse data is transformed into ML-ready managed dataset artifacts.
4. Preprocessing and feature engineering
- src/preprocessing contains the ETL and transformation logic used before training.
- etl.py and transformations.py separate data extraction/cleanup from feature transforms.
- src/common/features.py and src/common/datasource_utils.py hold shared feature definitions and datasource helpers, which keeps feature logic consistent between notebooks, local tests, and pipeline execution.
5. Model training package
- src/model_training encapsulates the custom Keras model and training workflow.
- Important responsibilities are split across:
- model.py for model definition,
- data.py for input data handling,
- trainer.py and runner.py for training orchestration,
- exporter.py for saving/exporting the trained model,
- task.py and defaults.py for command-line/task configuration.
- This package is the training “engine” used both interactively and inside pipeline steps.
6. TFX pipeline layer
- src/tfx_pipelines formalizes the training workflow as a TFX pipeline.
- training_pipeline.py and prediction_pipeline.py define separate pipeline flows for training and batch prediction.
- components.py and config.py centralize pipeline component wiring and runtime configuration.
- The pipeline uses TFX components to read from BigQuery, validate data, run Dataflow-based transforms, train a custom model, evaluate it, and push a blessed model.
7. Pipeline data flow
- The training path is: BigQuery ingest → schema/statistics validation → Dataflow transform → Vertex AI training → model evaluation → model push/export → Vertex AI model upload.
- The README also calls out custom Python components for hyperparameter generation and Vertex model upload, indicating that the pipeline mixes standard TFX components with repo-specific glue code.
- This is the key orchestration boundary: data/feature work is separated from execution scheduling and deployment.
8. Continuous training trigger
- src/pipeline_triggering/main.py implements a Cloud Function used to start training when a Pub/Sub message arrives.
- The trigger is external to the pipeline itself: Pub/Sub provides the event, Cloud Function translates it into a pipeline run.
- This gives the system a decoupled continuous-training mechanism rather than relying on manual notebook execution.
9. Deployment automation
- The build/ directory contains Cloud Build definitions for CI/CD.
- build/pipeline-deployment.yaml covers pipeline validation, local e2e testing, container build, pipeline compilation, and upload to Cloud Storage.
- build/model-deployment.yaml covers model interface tests and deployment of the trained model to a Vertex AI endpoint.
- This split shows two release artifacts: the pipeline definition and the serving model.
10. Serving architecture
- The trained model is served through Vertex AI endpoints for online prediction.
- The repo also supports batch prediction using the uploaded Vertex AI model and Vertex Pipelines.
- Serving is therefore dual-mode: synchronous endpoint inference and offline/batch inference.
11. Monitoring and feedback loop
- 08-model-monitoring.ipynb configures Vertex AI Model Monitoring for skew and drift detection.
- Monitoring jobs watch deployed models under an endpoint, produce artifacts, and support pause/delete lifecycle management.
- This closes the operational loop by providing the signal that can feed future retraining.
12. Infrastructure and environment provisioning
- provision/terraform defines the cloud foundation: GCS buckets, notebook instance, service accounts, and enabled services.
- This is the repo’s environment bootstrap layer and is separate from ML logic, which helps distinguish platform setup from model lifecycle code.
13. Testing and validation boundaries
- src/tests contains unit/integration-style tests for datasource utilities, ETL, model behavior, pipeline deployment, and model deployment.
- These tests support the CI/CD flows in build/ and are important for architecture because they validate both training logic and deployment assumptions.
14. Overall architecture view
- The repo is structured around a cloud-native ML lifecycle:
- notebooks for interactive exploration,
- Python packages for preprocessing, training, and pipelines,
- Terraform for cloud provisioning,
- Cloud Build for release automation,
- Pub/Sub + Cloud Functions for triggering,
- Vertex AI for training, registry, serving, and monitoring.
- The main diagram should center on BigQuery data flowing into TFX training pipelines, with trained models flowing into Vertex AI deployment and monitoring, and a separate event path triggering retraining.
Main entry points: training_pipeline.py Train pipeline · pipeline-deployment.yaml Pipeline CI/CD · trainer.py Training flow · model-deployment.yaml Model CI/CD
Components 21
Notebooks
Interactive lifecycle chapters
- Dataset mgmt · Data exploration and dataset setup
01-dataset-management.ipynb - Experimentation · Interactive feature and model exploration
02-experimentation.ipynb - Train formalize · Moves experiments into reproducible training
03-training-formalization.ipynb - Pipeline deploy · Pipeline validation and deployment workflow
04-pipeline-deployment.ipynb - Continuous train · Event-driven retraining setup
05-continuous-training.ipynb - Model deploy · Serving deployment workflow
06-model-deployment.ipynb - Prediction serving · Online and batch inference usage
07-prediction-serving.ipynb - Monitoring · Drift and skew monitoring setup
08-model-monitoring.ipynb
Source Code
Core ML and pipeline packages
- Raw schema · Schema for raw BigQuery data validation
src/raw_schema/schema.pbtxt - Shared logic · Feature definitions and datasource helpers
src/common/features.py - Preprocessing · Extraction, cleanup, and feature transforms
src/preprocessing/etl.py - Model core · Custom Keras model definition
src/model_training/model.py - Training flow · Training run, task wiring, and export
src/model_training/trainer.py - Train pipeline · End-to-end training pipeline definition
src/tfx_pipelines/training_pipeline.py - Batch pipeline · Batch prediction pipeline definition
src/tfx_pipelines/prediction_pipeline.py - Pipeline wiring · Component assembly and runtime config
src/tfx_pipelines/components.py
Delivery
CI/CD, triggering, and serving
- Trigger function · Pub/Sub-driven pipeline trigger
src/pipeline_triggering/main.py - Pipeline CI/CD · Validate, test, compile, and upload pipeline
build/pipeline-deployment.yaml - Model CI/CD · Test and deploy the serving model
build/model-deployment.yaml - Tests · Unit and deployment checks for training and serving
src/tests/model_tests.py
Platform
Cloud foundation and provisioning
- Terraform · Buckets, notebooks, service accounts, and services
provision/terraform/main.tf
Connections 22
- Dataset mgmt → Raw schema: define schema · Raw data validation boundary
- Dataset mgmt → Shared logic: prepare data · Dataset access and feature helpers
- Experimentation → Preprocessing: explore transforms · Interactive preprocessing and feature engineering
- Train formalize → Model core: formalize model · Moves notebook experiments into code
- Shared logic → Preprocessing: shared features · Consistent feature logic across flows
- Shared logic → Training flow: shared input · Datasource and feature utilities for training
- Preprocessing → Training flow: train data · Prepared examples feed training
- Model core → Training flow: run model · Model definition used by trainer
- Training flow → Pipeline wiring: integrate · Training logic is embedded in pipeline components
- Pipeline wiring → Train pipeline: assemble · Component wiring for the training pipeline
- Pipeline wiring → Batch pipeline: assemble · Component wiring for the batch prediction pipeline
- Train pipeline → Pipeline CI/CD: compile/deploy · Pipeline artifact is validated and uploaded
- Pipeline CI/CD → Terraform: run on cloud · Uses provisioned project resources and storage
- Pipeline CI/CD → Tests: validate · Pipeline deployment checks are enforced
- Model CI/CD → Tests: validate · Model interface and deployment checks
- Trigger function → Train pipeline: start run · Pub/Sub event triggers training pipeline
- Continuous train → Trigger function: set trigger · Continuous training setup in notebook
- Model deploy → Model CI/CD: deploy model · Serving release workflow
- Train pipeline → Model CI/CD: blessed model · Trained model flows to serving deployment
- Batch pipeline → Prediction serving: serve batch · Batch prediction workflow is exercised interactively
- Monitoring → Model CI/CD: monitor endpoint · Monitoring is configured against deployed serving
- Pipeline deploy → Pipeline CI/CD: release pipeline · Notebook documents pipeline deployment