Define Your Job Types
Migrating to Valohai is simpler than you think. You can run your existing code with just a YAML file — no rewrites, no vendor lock-in.
This guide shows you how to define your ML jobs and run them on Valohai's infrastructure while keeping your code portable.
💡 Already using MLflow, W&B, or other tools? Keep using them. Valohai runs your code as-is.
Step 0: Keep Your Code Portable
The best code for Valohai is code that runs anywhere. Before defining your jobs:
Remove vendor-specific decorators (they'll still work, but why lock yourself in?)
Use standard Python/R code that runs locally
Keep dependencies explicit in
requirements.txtor similar
Your code stays yours — portable in and out of Valohai.
💡 Want to use some other language than Python or R? No problem! Valohai jobs run inside Docker containers so you just need to provide a suitable image in your
valohai.yaml.
Step 1: Create valohai.yaml
Add a valohai.yaml file to your project root. This tells Valohai what job types exist in your project.
A minimal example:
- step:
name: train-model
image: docker.io/python:3.10
command:
- pip install -r requirements.txt
- python train.pyThat's it. Your existing train.py runs unchanged.
What's in a Step?
name: How you'll reference this job type (e.g.,
preprocessing,training,evaluation)image: A Docker image with your base dependencies (Python, TensorFlow, etc.)
command: Exactly what you'd run locally
💡 No Docker experience? Start with official images like
python:3.10ortensorflow/tensorflow:2.6.0from Docker Hub.
Step 2: Run Your First Execution
An "execution" is just Valohai's term for running your job once.
Quick Test with Local Code
Your code runs on Valohai's infrastructure, but behaves exactly like it does locally.
Production Runs from Git
Once you're happy, push to Git and run from there:
Common Patterns
Multiple Job Types
Define all your workflow steps:
Using Private Registries
Have custom Docker images? After connecting a private Docker registry to Valohai, you can use images from there in your executions:
Non-pip Dependencies
Valohai doesn’t restrict what you can run inside your jobs. Instead of running pip install you can also install packages using for example conda or apt-get install -y.
What About My Existing Tools?
Keep using them. Valohai runs your code as-is:
MLflow tracking? Works
Weights & Biases? Works
TensorBoard? Works
Custom logging? Works
You can migrate gradually — or not at all. Your choice.
Next Steps
Try one job — Start with your simplest script
Add parameters — Make jobs configurable (covered in the next guide)
Handle data — Connect to your data sources
Build pipelines — Chain jobs together
💡 Want the full picture? Check out Valohai Academy for comprehensive tutorials.
Quick Reference
Minimal valohai.yaml
CLI Commands
Common Docker Images
python:3.10— Standard Pythontensorflow/tensorflow:2.6.0— TensorFlow CPU onlytensorflow/tensorflow:2.6.0-gpu— TensorFlow with GPUpytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime— PyTorchrocker/r-base:4.3.0— R language
Bottom line: If your code runs locally, it runs on Valohai. No rewrites needed.
Last updated
Was this helpful?
