Connecting to MLOps#

For interacting with MLOps we need to access the clients.

To interact with the MLOps platform, you will need to access the provided clients.

MLOps Codex offers three primary clients:

You need the server URL, an email and a password to access the MLOps. The best way to do it is using a .env file with the following env variables

MLOPS_URL='https://neomaril.datarisk.net'
MLOPS_USER='email@email.com'
MLOPS_PASSWORD='password@123'

If you create the .env file in the same directory where you are running your code, it will be automatically imported.

# Import the client
from mlops_codex.model import MLOpsModelClient
from mlops_codex.training import MLOpsTrainingClient
from mlops_codex.datasources import MLOpsDataSourceClient
from mlops_codex.preprocessing import MLOpsPreprocessingClient
from mlops_codex.external_monitoring import MLOpsExternalMonitoringClient

# Start the client via model client
model_client = MLOpsModelClient()

# Start the client via training client
training_client = MLOpsTrainingClient()

# Start the client via data source client
datasource_client = MLOpsDataSourceClient()

# Start the client via preprocessing client
preprocessing_client = MLOpsPreprocessingClient()

# Start the client via external monitoring client
external_monitoring_client = MLOpsExternalMonitoringClient()

Creating a group#

Groups provide a way to organize training experiments and models that may have different end-users or purposes, enabling the creation of isolated environments for each group. When a group is created, a unique token is generated, which is used to run models and enhance platform security. This token will expire after one year. Every resource you create in MLOps should belong to a group, making the creation of a group the first step in your workflow. You can create a group using any of the available clients, simply by providing its name and a description to the group for better clarity and organization.

# Import the client
from mlops_codex.training import MLOpsTrainingClient

training_client = MLOpsTrainingClient()

training_client.create_group(
    name='nb_demo',
    description='Group for the demo'
)

# This token has a 1 year expiration date, to generate a new one use the refresh method

model_client.refresh_group_token(
    name='nb_demo', # Group name
    force=True # To force creating a new token even if the old is valid
)

Add your group token to the .env file:

MLOPS_GROUP_TOKEN='YOUR_GROUP_TOKEN'