MixtrainDocsBlog

Simple Workflow

A basic example demonstrating the structure of a Mixtrain workflow with inputs.

To follow along, import the Hello Workflow example into Mixtrain.

Code

from mixtrain import MixFlow


class ExampleWorkflow(MixFlow):
    def setup(self):
        print("Optional: Setting up workflow...")

    def run(
        self,
        model_name: str,
        learning_rate: float = 0.001,
        batch_size: int = 32,
        epochs: int = 10,
        use_gpu: bool = True,
    ):
        print(f"Training {model_name} for {epochs} epochs")
        print(f"Batch size: {batch_size}")
        print(f"Learning rate: {learning_rate}")
        print(f"GPU: {'enabled' if use_gpu else 'disabled'}")

    def cleanup(self):
        print("Optional: Cleaning up...")

Running the Workflow

Create the workflow

mixtrain workflow create example_workflow.py \
  --name my-workflow \
  --description "Example workflow"

Run with default inputs

mixtrain workflow run my-workflow

Run with custom inputs

mixtrain workflow run my-workflow \
  --input '{"model_name": "resnet50", "epochs": 20, "batch_size": 64}'

Key Concepts

Inputs in run() signature

Define inputs as parameters in the run() method:

PatternDescription
param: strRequired input (no default)
param: int = 10Optional input with default

Lifecycle Methods

MethodDescription
setup()Initialize resources before execution. Optional.
run()Main workflow logic (required)
cleanup()Release resources after execution. Optional.

Next Steps

On this page