Install & Compatibility
Where this runs
tested against v1.2.32 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.9
✕ build_error
✓ 24.6s
324MB installed
● package 324MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
DataloopMetrics
✓ from dtlpymetrics.dtlpm import DataloopMetrics
Initializes the DataloopMetrics client, ensures Dataloop SDK login, and reports a sample score to a specific project and dataset. Requires an active Dataloop account, `dtlpy` SDK, and a pre-defined metric on the Dataloop platform.
import dtlpy as dl
from dtlpymetrics.dtlpm import DataloopMetrics
import os
# Ensure Dataloop SDK is logged in or configured
try:
if not dl.token_expired():
print("Already logged into Dataloop SDK.")
else:
# Replace with your actual Dataloop token or ensure `dl.login()` is called elsewhere
dl.login(token=os.environ.get('DATALOOP_API_TOKEN', ''))
except Exception as e:
print(f"Failed to login to Dataloop SDK. Please ensure 'dtlpy' is installed and you are logged in or DATALOOP_API_TOKEN is set. Error: {e}")
exit(1)
# 1. Initialize the metrics client
metrics_client = DataloopMetrics()
# 2. Define your target Dataloop Project and Dataset IDs
# Replace 'YOUR_PROJECT_ID' and 'YOUR_DATASET_ID' with actual IDs or set environment variables.
project_id = os.environ.get('DATALOOP_PROJECT_ID', 'YOUR_PROJECT_ID')
dataset_id = os.environ.get('DATALOOP_DATASET_ID', 'YOUR_DATASET_ID')
# Check if placeholder IDs are still present to guide the user
if project_id == 'YOUR_PROJECT_ID' or dataset_id == 'YOUR_DATASET_ID':
print("Warning: Please replace 'YOUR_PROJECT_ID' and 'YOUR_DATASET_ID' with actual Dataloop IDs or set the DATALOOP_PROJECT_ID/DATALOOP_DATASET_ID environment variables.")
exit(1)
# For demonstration, use a placeholder metric_id and score
metric_id = "example_accuracy_score"
score_value = 0.85
# 3. Report a score
try:
# Before reporting, ensure the metric_id exists in your Dataloop project/dataset.
# You can create metrics using metrics_client.metrics_create() if needed.
metrics_client.metrics_report_score(
metric_id=metric_id,
score=score_value,
project_id=project_id,
dataset_id=dataset_id
# Optional: Link to specific entities with filters or entity_id/entity_type
# filters=dl.Filters(resource=dl.FiltersResource.ITEM).add(field='filename', values=['my_image.jpg']),
# entity_id='your-item-id',
# entity_type='item'
)
print(f"Successfully reported score {score_value} for metric '{metric_id}' to Dataloop.")
except Exception as e:
print(f"Failed to report score: {e}. Make sure the metric_id exists and you have correct permissions for project '{project_id}' and dataset '{dataset_id}'.")
Upgrade
Version history
1.2.32latest on PyPI · released Feb 26, 2026
Audit
Dependencies
dtlpyrequiredRequired for all Dataloop API interactions (authentication, project/dataset management, entity IDs). Version `~=1.x.x` is typically required based on `dtlpymetrics` setup.
numpyrequiredNumerical operations within the library.