For the complete documentation index, see llms.txt. This page is also available as Markdown.

Integrate ML platforms with Harness CI

Run training, evaluation, and deployment jobs on Azure ML, AWS SageMaker, Databricks, Google Vertex AI, or MLflow from a Harness CI pipeline.

Harness CI runs your machine learning workload on the platform that already hosts it. A Plugin step submits the training job, deployment, or tracking call to Azure ML, AWS SageMaker, Databricks, Google Vertex AI, or MLflow, so the model moves through the same governed pipeline as the rest of your software.

This page covers the Harness side of each integration. The data science work stays on your ML platform, and each section links to the vendor documentation for the platform-specific detail.


What you will learn from this topic

  • Plugin configuration: The plugin image and settings for each supported ML platform.

  • Pipeline placement: Where the training step sits relative to evaluation, packaging, and deployment.

  • Credential handling: How to pass cloud credentials to a plugin without writing them into YAML.

  • Evaluation and promotion: How to turn model metrics into a pipeline gate.


Before you begin

  • Harness CI project access: Permission to create and run pipelines. Go to RBAC in Harness to configure roles.

  • CI pipeline familiarity: Go to CI pipeline components to review stages and steps.

  • Docker connector: Each plugin runs as a container image. Go to Docker connector settings to create one.

  • ML platform account: An active account on your chosen platform, with a prepared workspace or project.

  • Training dataset: Prepare and store training datasets according to your model type and ML framework, and record an immutable path or version identifier for the dataset you train against.

  • Secrets: Store every credential as a text secret before you configure a plugin.

The plugin images in this guide are published to the harnesscommunity Docker Hub organization and are community-maintained. Each image publishes only a latest tag. Before you depend on one in a production pipeline, confirm the image still meets your needs, and consider mirroring it to your own registry so a rebuild upstream cannot change your pipeline behavior without warning.


Prepare your ML platform

Complete the platform setup before you add a step to Harness. Each platform needs a workspace or project, compute, and credentials that the plugin can use.

  1. Go to Create Azure ML resources to set up your workspace and compute instance.

  2. Note your subscription ID, resource group, and workspace name. The plugin requires all three.

  3. Go to Data concepts in Azure ML to register your dataset as a data asset.

  1. Go to Set up SageMaker Studio to create an AWS account, onboard a SageMaker domain and user, and add Studio permissions.

  2. Create an execution role with SageMaker and S3 permissions, and note its ARN.

  3. Upload your prepared dataset to S3 so the training job can reach it:

  1. Go to Prepare your Databricks Runtime environment to configure a cluster.

  2. Go to Create a notebook in your Databricks workspace, and note its workspace path.

  3. Note your workspace host URL and cluster ID, and create a personal access token. The plugin requires all three.

  1. Go to Set up Vertex AI on Google Cloud to create a project and enable the Vertex AI and Compute Engine APIs.

  2. Create a service account with Vertex AI and Cloud Storage permissions, then download its key.

  3. Create a source bucket for your notebook and an output bucket for results. Go to Manage datasets with Vertex AI to register your dataset.

  1. Install MLflow in the environment where your training code runs:

  2. Set up a remote tracking server that every team member and pipeline can reach. A local file store does not work for pipeline runs, because each build machine is ephemeral.

  3. Note the tracking server URI and the backend store it writes to, such as a SQL database with an S3, Azure Blob Storage, or Google Cloud Storage artifact store.


Train a model from your pipeline

Add a Plugin step to a CI stage. The plugin submits the job to your ML platform and waits for the result, so the pipeline fails when training fails.

Settings:

  • connectorRef: A Docker connector.

  • image: harnesscommunity/azure-ml.

  • username, password, tenant_id, SUBSCRIPTION_ID: Azure credentials and subscription. Pass all four as secrets.

  • AZURE_ML_WORKSPACE_NAME, RESOURCE_GROUP: The workspace and resource group you created.

  • PROJECT_PATH: Repository URL for your Azure ML project.

  • TRAINING_JOB_FILE: Path in the project repository to the training job definition.

  • MODEL_NAME: Name to register the trained model under.

  • ENDPOINT_NAME, ENDPOINT_YAML: Endpoint name and its definition file.

  • DEPLOYMENT_NAME, DEPLOYMENT_YAML: Deployment name and its definition file.

Sample training script

This script trains a credit card approval classifier with scikit-learn and logs metrics through MLflow, which Azure ML uses for run tracking in SDK v2. It assumes the dataset is preprocessed, contains features relevant to approval decisions such as income, credit score, and debt level, and has a binary ApprovalStatus target. It also assumes scikit-learn, pandas, and mlflow are installed in the job environment or listed in requirements.txt.

Adapt the feature engineering, model parameters, and metrics to your use case, and pass the data asset path through the --data argument in your job.yml. Go to Train models with Azure ML to define the job.

Settings:

  • connectorRef: A Docker connector.

  • image: harnesscommunity/aws-sagemaker.

  • model_name: Name to register the model under in SageMaker.

  • EXECUTION_ROLE_ARN: The SageMaker execution role you created.

  • IMAGE_URL: Container image that serves the model.

  • MODEL_DATA_URL: S3 path to the model artifact. SageMaker expects a model.tar.gz archive, not a raw dataset file.

  • ENDPOINT_CONFIG_NAME, ENDPOINT_NAME, VARIANT_NAME: Endpoint configuration, endpoint, and production variant names.

  • INSTANCE_TYPE, INITIAL_INSTANCE_COUNT: Serving instance size and count.

  • USERNAME: AWS.

  • AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION: Credentials and region. Pass both keys as secrets.

Sample training script

This example uses the SageMaker Python SDK v2 to train a scikit-learn model. It assumes your preprocessed data is in S3 and that train.py sits in a local code/ directory alongside its requirements.txt.

entry_point takes a path relative to source_dir, not an s3:// URL. Your train.py must load data from the channel directory SageMaker mounts, serialize the model with joblib or pickle, and write it to the output path SageMaker provides.

To test predictions, deploy to a temporary endpoint and delete it as soon as evaluation finishes:

An endpoint left running bills by the hour whether or not it serves traffic. Delete it in the same script that creates it so a failed run does not leave it behind. Go to Train ML models with SageMaker for the full training workflow.

Settings:

  • connectorRef: A Docker connector.

  • image: harnesscommunity/databricks-ml.

  • host: Your Databricks workspace URL.

  • pat: A Databricks personal access token. Pass it as a secret.

  • job_name: Name for the job the plugin creates.

  • NOTEBOOK_PATH: Workspace path to the notebook to run.

  • TASK_KEY: Unique key for the job task.

  • Description: Job description.

  • CLUSTER_ID: The cluster to run on.

Sample training notebook

This notebook trains a credit card approval classifier with scikit-learn. It assumes the dataset has features relevant to approval decisions and a binary ApprovalStatus target, and that scikit-learn and pandas are available on the cluster.

Preprocess evaluation data the same way as training data, and confirm the format your model expects. Go to Train models on Databricks to use AutoML or other libraries, and to Run notebooks to execute and view results interactively.

This plugin executes a notebook and stores the output in Cloud Storage.

Settings:

  • connectorRef: A Docker connector.

  • image: harnesscommunity/gcloud-vertex.

  • allowlist: The notebook file to execute.

  • project_id: Your GCP project ID.

  • GCLOUD_SOURCE_BUCKET: Bucket holding the notebook.

  • GCLOUD_OUTPUT_BUCKET: Bucket path for notebook output.

  • SERVICE_ACCOUNT_KEY: Service account key. Pass it as a secret.

  • DISPLAY_NAME: Display name for the job.

Sample training script

This train.py script loads data from Cloud Storage, trains a random forest classifier, and uploads the serialized model back to Cloud Storage. It assumes the dataset has features relevant to credit card approval decisions and a binary ApprovalStatus target, and that scikit-learn, pandas, and google-cloud-storage are installed.

To run this outside a notebook, create a custom training job that specifies the scikit-learn training container, your script, and any arguments. Grant the job service account read access to the data bucket and write access to the output bucket, otherwise the upload fails after training completes successfully.

The MLflow plugin runs an MLflow Project against your tracking server and records the run.

Settings:

  • connectorRef: A Docker connector.

  • image: harnesscommunity/mlflow.

  • MLFLOW_TRACKING_URI: URI of your remote tracking server, for example http://mlflow.example.com:5000. Reference it through a stage variable so it differs per environment.

  • MLFLOW_EXPERIMENT_NAME: Experiment to log the run under.

  • MLFLOW_PROJECT_PATH: Repository URL of the MLflow Project to run.

  • MLFLOW_RUN_PARAMETERS: Parameters passed to the project entry point.

Instrument your training code with MLflow Tracking

MLflow Tracking logs parameters, metrics, and artifacts so you can compare runs later. Wrap your training code in a run context:

Log the trained model in a servable format, where sk_model is a trained scikit-learn model and "model" is the artifact path within the run:

Point your code at the remote tracking server through the environment:

Or set it in code:

If the tracking URI is unset, MLflow writes to the local filesystem. On an ephemeral build machine that means the run disappears when the step finishes, so always set it explicitly in a pipeline.


Evaluate the trained model

Evaluation turns a trained model into a promotion decision. The workflow is the same on every platform:

  1. Prepare evaluation data: Store a held-out dataset in a format your model accepts. Confirm the model has not seen it during training, and preprocess it exactly as you preprocessed the training data.

  2. Select metrics: Choose metrics that match the prediction task. Binary classification tasks such as credit card approval commonly use accuracy, precision, recall, F1 score, and area under the ROC curve. Consider business metrics that weigh false positives against false negatives.

  3. Run the evaluation and fail on a miss: Compute the metrics, compare them against your threshold, and exit non-zero when the model misses it. This is what converts a metric into a pipeline gate.

  4. Iterate: Adjust hyperparameters, algorithms, or preprocessing, then retrain and re-evaluate.

Model evaluation is iterative and might require multiple rounds of training, evaluation, and tuning to reach the performance you need. Confirm the metrics you choose align with your project objectives before you set a threshold, because a threshold on the wrong metric passes models that fail in production.

The following example computes metrics and enforces a threshold. Run it in a CI Run step after training so a failing model stops the pipeline:

Platform-native evaluation tooling is also available:

Go to View metrics for jobs and runs to review logged metrics in Azure ML studio.

Run evaluation as a SageMaker Processing Job, and compare runs with SageMaker Experiments. For foundation models, go to Evaluate a foundation model to use automatic and human evaluation. Delete processing jobs and test endpoints after evaluation to avoid unnecessary charges.

Evaluate in the notebook and visualize results with Databricks visualization tools. Log metrics to MLflow rather than to notebook output alone, so results survive past the run.

Go to Model evaluation in Vertex AI to review metrics for AutoML and custom-trained models, and enable model monitoring on deployed models to detect skew, drift, and anomalies.

Log evaluation metrics to the same MLflow run as training so both appear together in the tracking UI. Start the UI with mlflow ui, which serves on http://127.0.0.1:5000 by default, or open your remote tracking server URL to compare runs and visualize parameters and outputs.


Deploy the model and get predictions

Once a model passes evaluation, deploy it and call its endpoint for predictions. Harness CD manages the deployment and rollback for container and serverless targets, and each ML platform also offers a managed serving path.

Go to Deploy models with online endpoints for managed serving, or to Package and deploy models outside Azure ML to serve from your own infrastructure. The plugin handles endpoint creation when you supply ENDPOINT_YAML and DEPLOYMENT_YAML.

Go to Deploy models for inference to create a real-time or batch endpoint. The plugin creates the model, endpoint configuration, and endpoint from the settings above.

Go to Databricks Model Serving to serve a registered model behind an endpoint.

Go to Vertex AI deployment to deploy to an endpoint, and to Get predictions for online and batch prediction options.

Register the logged model in the MLflow Model Registry, then serve it with mlflow models serve or package it as a container image and deploy it with Harness CD. Go to MLflow Models to review the supported serving flavors.


Monitor, improve, and iterate

Set up monitoring and logging for every deployed model so you detect degradation before it reaches a business metric. Then feed what you learn back into retraining, using triggers or scheduled pipelines to rerun the training stage when drift crosses a threshold.


Troubleshooting


Next steps

Wire the integration into a complete pipeline, then add the governance controls that make model promotion auditable.

Last updated

Was this helpful?