ClearML

2.1.5 · active · verified Mon Apr 13

ClearML is an open-source MLOps platform that provides auto-magical experiment management, version control for data and models, and MLOps capabilities for AI workflows. It helps track, compare, and reproduce machine learning experiments. The library sees active development with frequent patch releases (multiple per month) and regular minor/major version updates, with the current version being 2.1.5.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a ClearML Task to start tracking an experiment. It sets up ClearML credentials via environment variables and then creates a `Task` object. Metrics are logged using the task's logger. It is crucial to call `Task.init()` early in your script to ensure comprehensive tracking. Replace 'YOUR_ACCESS_KEY' and 'YOUR_SECRET_KEY' with your actual ClearML credentials, or run `clearml-init` in your terminal to configure them interactively.

import os
from clearml import Task

# Set ClearML credentials (replace with your actual keys or configure via `clearml-init` CLI)
os.environ['CLEARML_WEB_HOST'] = os.environ.get('CLEARML_WEB_HOST', 'https://app.clear.ml')
os.environ['CLEARML_API_HOST'] = os.environ.get('CLEARML_API_HOST', 'https://api.clear.ml')
os.environ['CLEARML_FILES_HOST'] = os.environ.get('CLEARML_FILES_HOST', 'https://files.clear.ml')
os.environ['CLEARML_API_ACCESS_KEY'] = os.environ.get('CLEARML_API_ACCESS_KEY', 'YOUR_ACCESS_KEY')
os.environ['CLEARML_API_SECRET_KEY'] = os.environ.get('CLEARML_API_SECRET_KEY', 'YOUR_SECRET_KEY')

# Initialize a ClearML Task (experiment)
task = Task.init(project_name='My Project', task_name='My First ClearML Task')

print(f"ClearML Task initialized: {task.name}")

# Log a simple metric
logger = task.get_logger()
for i in range(10):
    logger.report_scalar(series="loss", value=10 - i, iteration=i)

# Simulate some work
import time
time.sleep(2)

# Close the task (optional, often handled automatically on script exit)
task.close()
print("Task completed and closed.")

view raw JSON →