Trigger a pipeline

There are numerous ways to trigger a pipeline

In ZenML, the simplest way to execute a run is to use your pipeline function:

from zenml import step, pipeline


@step  # Just add this decorator
def load_data() -> dict:
    training_data = [[1, 2], [3, 4], [5, 6]]
    labels = [0, 1, 0]
    return {'features': training_data, 'labels': labels}


@step
def train_model(data: dict) -> None:
    total_features = sum(map(sum, data['features']))
    total_labels = sum(data['labels'])

    # Train some model here...

    print(
        f"Trained model using {len(data['features'])} data points. "
        f"Feature sum is {total_features}, label sum is {total_labels}."
    )


@pipeline  # This function combines steps together 
def simple_ml_pipeline():
    dataset = load_data()
    train_model(dataset)


if __name__ == "__main__":
    simple_ml_pipeline()

However, there are other ways to trigger a pipeline, specifically a pipeline with a remote stack (remote orchestrator, artifact store, and container registry).

Run Templates

Run Templates are pre-defined, parameterized configurations for your ZenML pipelines that can be easily executed from the ZenML dashboard or via our Client/REST API. Think of them as blueprints for your pipeline runs, ready to be customized on the fly.

This is a ZenML Pro-only feature. Please sign up here to get access.

ZenML Scarf

Last updated