Fetch Failed Executions
Query your failed executions programmatically to build automated retry workflows, monitoring dashboards, or failure analysis tools.
This example shows how to filter executions by status and extract failure details, perfect for building resilient ML pipelines that automatically recover from transient errors.
Prerequisites
A Valohai project with some executions (successful or failed)
Python 3.8+ and the
requestslibrary installed
Generate a Valohai API Token
Create an API token to authenticate your requests:
Click "Hi, <username>!" in the top-right corner
Go to My Profile → Authentication
Click Manage Tokens and scroll to the bottom
Click Generate New Token
Copy the token immediately — it's shown only once
Store your token as an environment variable:
# Linux/Mac
export VH_API_TOKEN=your_token_value
# Windows
set VH_API_TOKEN=your_token_valueGet Your Project ID
Find your project ID in Project Settings → General
Fetch Failed Executions
Create fetch_failed_executions.py:
import requests
import json
import os
# Authenticate with your API token
auth_token = os.environ['VH_API_TOKEN']
headers = {'Authorization': f'Token {auth_token}'}
# Replace with your project ID
project_id = 'your-project-id-here'
# Fetch only failed executions
url = f'https://app.valohai.com/api/v0/executions/?project={project_id}&status=error'
resp = requests.get(url, headers=headers)
resp.raise_for_status()
# Print the response
print('Failed Executions:\n')
print(json.dumps(resp.json(), indent=4))Run the script:
python fetch_failed_executions.pyUnderstanding the Response
The API returns a paginated list of executions. Each failed execution includes:
{
"count": 3,
"next": null,
"previous": null,
"results": [
{
"id": "exec-id-here",
"counter": 42,
"status": "error",
"step": "train-model",
"project": "project-id-here",
"commit": "abc123...",
"ctime": "2025-10-29T10:30:00Z",
"duration": 125,
"error_text": "Connection timeout during data download",
"urls": {
"display": "https://app.valohai.com/p/owner/project/execution/exec-id/"
}
}
]
}Key fields:
status: Always"error"when filtered bystatus=errorerror_text: Human-readable failure reasonstep: Which step failedduration: How long it ran before failing (in seconds)urls.display: Direct link to the execution in Valohai
Status Filters
Query executions by different statuses:
# All failed executions
status=error
# All successful executions
status=completed
# Manually stopped executions
status=stopped
# Currently running executions
status=startedNext Steps
Now that you can fetch failed executions, you can:
Parse
error_textto categorize failure typesSend alerts when critical executions fail
Generate daily failure reports
Troubleshooting
Empty results:
Verify your project ID is correct
Check that you have executions with
status=errorTry removing the status filter to see all executions
Authentication errors:
Confirm
VH_API_TOKENenvironment variable is setVerify your token is valid in My Profile → Authentication
Self-hosted Valohai: Replace https://app.valohai.com with your installation URL
Last updated
Was this helpful?
