๐ Stack Configuration
FlowyML provides clean separation of concerns between your ML code and infrastructure configuration. Your code uses abstract functions, and the configuration determines where things actually go.
๐ Same Code, Any Infrastructure
Write once, deploy anywhere. Swap from local SQLite โ GCS + Vertex AI โ S3 + SageMaker with a single config change. No code rewrites.
๐๏ธ The Principle
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your ML Code โ
โ (uses abstract functions) โ
โ โ
โ save_model(model, "classifier")โ
โ log_metrics({"accuracy": 0.95})โ
โ save_artifact(data, "data.pkl")โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ flowyml.yaml โ
โ (configuration determines โ
โ where data actually goes) โ
โ โ
โ artifact_store: gcs/s3/azure โ
โ experiment_tracker: mlflow โ
โ orchestrator: vertex_ai/k8s โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Switching from GCS to S3? Just edit flowyml.yaml. No code changes needed.
๐ Quick Start
1๏ธโฃ Initialize Your Stack
# Create flowyml.yaml with your plugins
flowyml stack init --tracker mlflow --store gcs --orchestrator vertex_ai
This creates:
2๏ธโฃ Install the Plugins
# Install all plugins in your stack
flowyml stack install
# Or install individually
flowyml plugin install mlflow
flowyml plugin install gcs
flowyml plugin install vertex_ai
3๏ธโฃ Write Clean ML Code
4๏ธโฃ Switch Stack Without Code Changes
Going to production on AWS? Just update flowyml.yaml:
Same code, different infrastructure. โจ
๐ Configuration Options
๐ฌ Experiment Trackers
๐พ Artifact Stores
โ๏ธ Orchestrators
๐ณ Container Registries
๐ณ Docker & Containerization
When running pipelines remotely (Vertex AI, SageMaker, Kubernetes), each step runs inside a Docker container. Understanding when FlowyML builds images for you vs. when you must build and push manually is critical.
๐ค Auto-Build (Remote Orchestrators)
With cloud orchestrators like Vertex AI and SageMaker, FlowyML can automatically build a Docker image from your code and push it to the configured container registry:
๐ง What happens under the hood
- FlowyML generates a
Dockerfilefrom your config - Installs dependencies from
requirements.txtorpyproject.toml - Copies your source code into the image
- Builds the image locally via Docker
- Pushes to the configured container registry
- Submits the pipeline with the image URI
๐จ Manual Build + Push
If you need full control over the Docker image (custom system packages, GPU drivers, multi-stage builds), build and push it yourself:
Build and push:
# Build
docker build -t us-central1-docker.pkg.dev/my-project/ml-pipelines/training:v1 .
# Push
docker push us-central1-docker.pkg.dev/my-project/ml-pipelines/training:v1
Reference the pre-built image in your config:
๐ฎ GPU Images
For GPU workloads, start from an NVIDIA base image:
๐ก When to use auto-build vs. manual
| Scenario | Recommended |
|---|---|
| Quick prototyping | โ Auto-build |
| Standard Python dependencies only | โ Auto-build |
| Custom system packages (ffmpeg, CUDA) | ๐จ Manual build |
| Multi-stage builds for smaller images | ๐จ Manual build |
| CI/CD pipeline with image caching | ๐จ Manual build |
| GPU workloads with NVIDIA base | ๐จ Manual build |
๐ฆ Dependency Management
FlowyML supports both requirements.txt and pyproject.toml (Poetry/PDM) for managing Python dependencies in containerized environments.
๐ Using requirements.txt
The simplest approach โ works everywhere:
# requirements.txt
flowyml[all]>=1.9.0
scikit-learn>=1.3.0
pandas>=2.0.0
mlflow>=2.8.0
google-cloud-aiplatform>=1.38.0
๐ฆ Using Poetry (pyproject.toml)
For teams using Poetry:
โ ๏ธ Poetry in Docker
When using Poetry, FlowyML generates a poetry.lock export step in the Dockerfile. For manual builds, add:
๐ช Step Resources & GPU Allocation
Configure CPU, memory, and GPU resources per step. This is essential for remote execution where steps run in separate containers.
โ๏ธ Configuring Resources on Steps
๐ Available Resource Fields
| Field | Type | Description | Example |
|---|---|---|---|
cpu |
str |
Number of CPU cores | "4", "0.5" |
memory |
str |
RAM allocation | "16Gi", "512Mi" |
accelerator_type |
str |
GPU type | "NVIDIA_TESLA_T4", "NVIDIA_TESLA_A100" |
accelerator_count |
int |
Number of GPUs | 1, 4, 8 |
disk |
str |
Ephemeral disk | "100Gi" |
timeout |
int |
Max execution time (seconds) | 3600 |
๐๏ธ Default Resources via YAML
Set defaults for all steps, then override per-step:
๐ก Resource right-sizing
Start with smaller resources and scale up. Use @step(resources={"cpu": "1", "memory": "4Gi"}) for data preprocessing and reserve GPUs only for training steps. This reduces costs significantly.
๐ Environment Variables
You can use environment variables anywhere in your config:
๐ฅ๏ธ Stack Management Commands
# Create initial configuration
flowyml stack init --tracker mlflow --store gcs
# Show current stack
flowyml stack show
# Validate configuration
flowyml stack validate
# Install all plugins in stack
flowyml stack install
# List all stacks
flowyml stack list
๐ Named Multi-Stack Support
FlowyML supports named stacks for managing development, staging, and production environments in a single config file:
๐ Switching Stacks
# Via environment variable
FLOWYML_STACK=gcp-prod flowyml run my_pipeline
# Via CLI
flowyml stack set gcp-prod
flowyml stack list
flowyml stack show gcp-prod
๐ Type-Based Artifact Routing
Route artifacts automatically based on their type annotations:
Configure routing rules per type:
โ Deep Dive: Type Routing Guide
๐ API Reference
Tracking Functions
| Function | Description |
|---|---|
start_run(name) |
Start a new experiment run |
end_run() |
End the current run |
log_params(dict) |
Log parameters |
log_metrics(dict) |
Log metrics |
set_tag(key, value) |
Set a tag |
Artifact Functions
| Function | Description |
|---|---|
save_artifact(obj, path) |
Save any artifact |
load_artifact(path) |
Load an artifact |
artifact_exists(path) |
Check if exists |
list_artifacts(path) |
List artifacts |
Model Functions
| Function | Description |
|---|---|
save_model(model, path) |
Save model with tracking |
load_model(path) |
Load a model |
Container Functions
| Function | Description |
|---|---|
push_image(name, tag) |
Push Docker image |
get_image_uri(name, tag) |
Get image URI |
Utility Functions
| Function | Description |
|---|---|
show_stack() |
Show configured stack |
validate_stack() |
Validate all plugins installed |