Skip to main content

Reusable Outerbounds project patterns.

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.
  • NeuralNetworkFlow: 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 on the local workstation

Run flows from the project root:

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

Note you don't neeed to use a package manager since we've installed the package directly on our local workstation.

Publishing to PyPI

Build and Publish

# Build distribution
uv build

# Publish to PyPI
uv publish

# Or publish to test PyPI first
uv publish --publish-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 NeuralNetworkFlow

class MyTrainingFlow(ProjectFlow, NeuralNetworkFlow):
    
    @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 --environment=fast-bakery 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.1.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.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: min_obproject-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 208dc3b88ebe68d7cf0114a0d67977af93b8504bd966ab3c75ce5a2a07d21338
MD5 26dbdb8c3221e07fa37906f559728de8
BLAKE2b-256 cb5cf948c6a2f8b759a56de1677e9efa0091e6fc70b2d56a6a6153e8e0a70649

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for min_obproject-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a44f8e6bacaad5fa3a7eff6055fa8bbded0c169df7c3eef15bf799bafacde40b
MD5 c52a7e0eb1979788e83736af7e3511c5
BLAKE2b-256 a55c789a732441f17ac99fda12c537f55b598b4cb0076fcc70c9b249be5036d7

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