Skip to main content

No project description provided

Project description

GitLab MLOps Python Client

A Python client for integrating GitLab's MLOps features, specifically designed to leverage GitLab's experiment tracking and model registry capabilities. This client simplifies the management of machine learning workflows by combining MLflow's flexibility with GitLab's powerful MLOps tools.

Build Status Latest Release

Features

  • GitLab Experiment Tracking: Easily track machine learning experiments within GitLab.
  • Model Registry Integration: Register and manage models in GitLab's model registry.
  • Experiment Management: Create and manage experiments directly from the client.
  • Run Tracking: Initiate and monitor training runs with ease.
  • Model Lifecycle Management: Promote runs to model versions effortlessly.

Feedback

The MLOPs Python client is currently in Beta. We welcome feedback and feature requests either in this repository's issue tracker or on our feedback issue

Installation

Install the client using pip:

pip install gitlab-mlops

Alternatively, to install the latest version from the source, use Poetry:

# Clone the repository
git clone https://gitlab.com/gitlab-org/modelops/mlops/gitlab-mlops.git
cd gitlab-mlops

# Install dependencies
poetry install

Usage

Configuration

Configure the client using environment variables or initialization arguments.

Using Environment Variables:

export MLFLOW_TRACKING_URI="https://gitlab.com/api/v4/projects/<project_id>/mlflow"
export MLFLOW_TRACKING_TOKEN="your_access_token"
from gitlab_mlops import Client

client = Client()

Using Initialization Arguments:

from gitlab_mlops import Client

client = Client(
    tracking_uri="https://gitlab.com/api/v4/projects/<project_id>/mlflow",
    gitlab_token="your_access_token"
)

Create a New Experiment

from gitlab_mlops import Client

client = Client()
experiment = client.create_experiment("Experiment Name")

Create a New Run

from gitlab_mlops import Client

client = Client()
experiment = client.get_experiment(name="Experiment Name")
run = experiment.create_run()

Log Parameters, Metrics, and Model artifacts

from gitlab_mlops import Client

client = Client()

run = client.get_run(run_id="19e547d3-8de7-42c3-9575-fae1142dec69")

run.log_param(key="param_name", value="value")
run.log_metric(key="metric_name", value=0.95)
run.log_artifact(
    local_path="<path to the model file or directory>",
    artifact_path="<optional relative path to log the artifact(s) at>"
)

Create a New Model

from gitlab_mlops import Client

client = Client()
model = client.create_model(name="Model Name", description="Model Description")

Create a New Model Version

from gitlab_mlops import Client

client = Client()

model = client.get_model(name="Model Name")

model_version = model.create_version(description="New version", version="1.0.0")

model_version.log_param(key="param_name", value="value")
model_version.log_text("How to run this model [...]", "README.md")

Importing existing models

To import existing models from various external sources, you can use the export_to_gitlab method. This method allows you to import models from the following sources:

  • Google Cloud Platform - Vertex AI

Importing from Google Cloud Platform - Vertex AI

from gitlab_mlops import Client
from gitlab_mlops.providers.gcp.vertex import VertexAIClient

client = Client()
vertex = VertexAIClient(
    project_id="your_project_id",
    location="us-central1",
    client=client
)

resource_name = "projects/your_project_id/locations/us-central1/models/your_model_id"

vertex.export_model_to_gitlab(
    model_id=resource_name
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitlab_mlops-0.3.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitlab_mlops-0.3.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file gitlab_mlops-0.3.0.tar.gz.

File metadata

  • Download URL: gitlab_mlops-0.3.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: poetry/2.1.1 CPython/3.11.9 Linux/5.15.154+

File hashes

Hashes for gitlab_mlops-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7c5497a8fddcf8dd06f854cfb7db2a84c372cb14c1ba9e54b34cbe41b23bca77
MD5 b879cd38d73c97bb0610b4f1f0432fc0
BLAKE2b-256 57473bc089963652c73fe96ce9d10414ebb0ed29d70e4f1c82ad2cb3f71cea0a

See more details on using hashes here.

File details

Details for the file gitlab_mlops-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: gitlab_mlops-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: poetry/2.1.1 CPython/3.11.9 Linux/5.15.154+

File hashes

Hashes for gitlab_mlops-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 601cce15ed28d4cf4b2c4ded524ce67b31ba17fcd97e951624e2c7110ca148ea
MD5 598f097f9c147c06c822b1cdfc2b8742
BLAKE2b-256 0f7ac21cea0478f7ea0b641cfdf5feb8919374c1c6368d2ca196bd18087c7f46

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page