Skip to main content

Reusable Metaflow flow templates and configurations

Project description

min-obproject

This obproject demonstrates

  1. Configuration patterns for machine learning workflows where there are both many parameters inducing a need for a config file, and you want to dynamically override config values.
  2. How to build Metaflow flow templates.

Repository Structure

min-obproject/
├── src/                          # Shared Python modules
│   └── flow_templates.py         # Reusable flow base classes
├── flows/                        # Individual Metaflow workflows
│   ├── 01-config-override/       # Example: basic config override pattern
│   └── 02-projectflow-inheritance/  # Example: template inheritance
└── obproject.toml                # Outerbounds project configuration

Key Features

  • Makes use of Metaflow Configs.
  • ConfigurableNeuralNetworkFlow: Base class example that auto-resolves a config.json assumed to be in an inheriting flow's directory. This pattern helps downstream flows leverage configs for automating experiments with many parameters, while avoiding a lot of boilerplate in FlowSpec-inheriting classes.
  • Dynamic Config Resolution: Configs can be selectively overridden using individual Metaflow Parameters. This way, we get the best of both worlds, and individual parameters of the config files can be overridden with arbitrarily complex logic that library authors write once, and downstream flow consumers can operate.

Development Setup

Install as Editable Package (Local Development)

# Install uv if needed
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install package in editable mode
uv pip install -e .

# With dev dependencies
uv pip install -e ".[dev]"

Now src modules are importable from anywhere:

from src.flow_templates import NeuralNetworkFlow

Run Flows

Always run from project root:

python flows/02-projectflow-inheritance/flow.py run
python flows/02-projectflow-inheritance/flow.py run --with kubernetes

Publishing to PyPI

Build and Publish

# Build distribution
uv build

# Publish to PyPI
uv publish

# Or publish to test PyPI first
uv publish --index-url https://test.pypi.org/legacy/

Use Published Package in Production

from metaflow import FlowSpec, step, pypi_base

@pypi_base(packages={"min-obproject": "0.1.0"})
class MyFlow(FlowSpec):
    ...

Example Usage

from metaflow import step
from obproject import ProjectFlow
from src.flow_templates import ConfigurableNeuralNetworkFlow

class MyTrainingFlow(ProjectFlow, ConfigurableNeuralNetworkFlow):
    
    @step
    def start(self):
        self._resolve_config()  # Loads config.json from flow directory
        print(f"Training with lr={self.config['lr']}")
        self.next(self.end)
    
    @step
    def end(self):
        pass

Create config.json in the same directory as your flow:

{
    "train_args": {
        "lr": 0.001,
        "optimizer": "adam"
    }
}

Override config values via CLI:

python flow.py run --lr 0.01

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

min_obproject-0.1.0.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

min_obproject-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file min_obproject-0.1.0.tar.gz.

File metadata

  • Download URL: min_obproject-0.1.0.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.16

File hashes

Hashes for min_obproject-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e5ce35b94068bfbf987b784b41427c97a22219fc47d7d519f4398eecfaf3c4aa
MD5 1154cd4830db5a10b2bbc40b5613d0f3
BLAKE2b-256 461780fe1d507bfad4bc13b25785ed68945d8bf8015d6935c9229670517601f0

See more details on using hashes here.

File details

Details for the file min_obproject-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for min_obproject-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aab2ef9559e65abb70fac403252700af1cfa059beb965f090068b2ad56079067
MD5 1f3af7bc8e26174e2670412ce3a4aa28
BLAKE2b-256 b57ccfe28ef45d2b9a2bcb54908a5574ae6c406890aef124e7515d849e0fc14c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page