Custom Execution Status

Track progress and communicate execution state beyond Valohai's default statuses (queued, started, completed, error). Custom statuses help ML teams monitor long-running jobs, debug failures faster, and integrate with external monitoring systems.

Why Use Custom Status

For ML Engineers: Get real-time visibility into multi-hour training jobs without SSH access or log diving.

For Teams: Share meaningful progress updates like "Loading 50GB dataset" or "Epoch 45/100" that stakeholders actually understand.

For Integration: Feed execution state into monitoring dashboards, Slack notifications, or CI/CD pipelines via API.

Set Status with Direct API

This method works without additional dependencies and gives you full control over status updates.

import json
import requests

# Read Valohai execution config
with open("/valohai/config/api.json", "r") as json_file:
    data = json.load(json_file)

    headers = data["set_status_detail"]["headers"]

    # Set your custom status
    response = requests.post(
        data["set_status_detail"]["url"],
        headers=headers,
        json={"status_detail": "Processing epoch 23/100"},
    )
    print(f"Status updated: {response.status_code}")

💡 The status overwrites previous custom statuses. Set it at key milestones for best visibility.

Set Status with valohai-utils

If you're already using valohai-utils in your project, this one-liner handles the API call:

Remember to add valohai-utils to your requirements.txt.

Common Status Patterns

Milestone Updates

Set status at major workflow transitions:

Progress Tracking

Update status during long-running operations:

Error Context

Provide debugging context when things go wrong:

Rich Status Content

Add visual elements like progress bars and charts to your status updates. Each rich element must be valid JSON on a single line.

Text with Color

Available colors: good, bad, warn, or any CSS color value.

Progress Gauge

Sparkline Charts

Access Status via API

Retrieve custom status from external services or local scripts:

🔐 Keep your API token secure and out of version control. Use environment variables or secret management.

Best Practices

Update Strategically: Don't spam status updates. Set them at meaningful milestones or every N iterations.

Keep It Readable: Status shows in the UI and API responses. Make it human-friendly.

Handle Failures Gracefully: Wrap status updates in try/catch blocks so they don't crash your execution.

Use Rich Content Sparingly: Gauges and charts are great for long processes, but plain text is often clearer for distinct operations.

Last updated

Was this helpful?