MixtrainDocs

Simple Workflow

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

Code

from mixtrain import MixFlow


class ExampleWorkflow(MixFlow):
    """Example workflow with configurable inputs."""

    def setup(self):
        """Initialize the workflow."""
        print("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,
    ):
        """Execute the workflow.

        Args:
            model_name: Name of the model to use (required)
            learning_rate: Learning rate for training
            batch_size: Training batch size
            epochs: Number of training epochs
            use_gpu: Whether to use GPU acceleration
        """
        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):
        """Clean up resources."""
        print("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