Read Deployment Details
Every deployment includes a valohai-metadata.json file with details about the current deployment, version, and endpoint configuration.
Access the metadata
Read and parse the file from your endpoint code:
import json
with open("valohai-metadata.json", "r") as f:
metadata = json.load(f)
# Access specific values
deployment_name = metadata["deployment"]["name"]
version_name = metadata["version"]["name"]
endpoint_name = metadata["endpoint"]["name"]Common use cases
Log deployment info on startup:
print(f"Starting {metadata['endpoint']['name']} from version {metadata['version']['name']}")Conditional logic based on environment:
if metadata["deployment"]["target"] == "production-cluster":
enable_strict_validation = TrueTrack which model files are loaded:
Metadata structure
The JSON contains these top-level keys:
deployment- Deployment details (name, target, URLs)version- Version info (name, commit, creation time)endpoint- Endpoint configuration (resources, files, status)project- Project details (name, owner)meta- Metadata about the metadata file itself
Example metadata file
Next: Learn about installing additional packages in your deployments.
Last updated
Was this helpful?
