How to trigger a pipeline

There are 2 ways you can trigger a pipeline from code:

Block template

Add a data loader or data exporter block template named Orchestration → Trigger pipeline.

Custom code

Add a block and use the following code example within the block’s function:

from mage_ai.orchestration.triggers.api import trigger_pipeline


trigger_pipeline(
    'pipeline_uuid',
    variables={},
    check_status=False,
    error_on_failure=False,
    poll_interval=60,
    poll_timeout=None,
    schedule_name=None,  # Enter a unique name to create a new trigger each time
    verbose=True,
)

Parameters

Parameter nameDescriptionDefaultSampleRequired
pipeline_uuidThe UUID of the pipeline to trigger.example_pipeline
variablesRuntime variables for the pipeline.{}{ 'env': 'dev' }
check_statusPoll and check the status of the triggered pipeline.FalseFalse or True
error_on_failureRaise an exception if the triggered pipeline fails.FalseFalse or True
poll_intervalCheck the status of triggered pipeline every N seconds.60300
poll_timeoutAfter N seconds have elapsed, raise an exception if the triggered pipeline hasn’t finished running successful.None3600
verbosePrint status of triggered pipeline run.TrueFalse or True