Skip to main content

Overview

Remote blocks let one pipeline pass references to block outputs from another pipeline run. Mage stores a reference to the source block, source pipeline, source repository path, and execution partition, then resolves that reference when a downstream block runs. Remote blocks are used by global data products and can also be returned when triggering a pipeline from code. Use remote blocks when a downstream pipeline needs data that was already produced by an upstream pipeline run. This avoids copying the data into runtime variables and lets Mage read the saved block variables from the source pipeline partition.

How it works

A remote block reference contains: When the receiving block executes, Mage replaces each reference with that remote block’s saved outputs and makes them available in kwargs['remote_blocks']. The resulting shape is a list of remote block output groups:
Each inner list contains the saved output variables from one referenced block.

Use with global data products

When a pipeline uses a global data product block, Mage triggers or reuses the source pipeline run for that data product. After the source run is available, Mage returns remote block references for the configured output blocks in that global data product. Downstream blocks can read those outputs from kwargs['remote_blocks']:
If the source block returns more than one value, each value appears in the inner list for that remote block.

Pass remote blocks to another pipeline

Remote blocks do not require a global data product. If the current pipeline has already produced outputs that another pipeline should consume, build remote block references from the current pipeline context and pass them to trigger_pipeline. For example, this data exporter triggers another pipeline and passes outputs from five blocks in the current pipeline run:
In the downstream pipeline, add a block that reads the resolved outputs from kwargs['remote_blocks']. The order matches the order of the references passed to trigger_pipeline.
Each item in remote_blocks is a list because a source block can save multiple output variables. Use index 0 when the source block returns a single output.

Trigger a pipeline and return remote blocks

You can also request remote block references when triggering a pipeline from code:
When return_remote_blocks=True, Mage returns a payload containing remote_blocks for the blocks in the triggered pipeline run. Pass that payload into another pipeline trigger to make those outputs available to the downstream pipeline:
In blocks inside downstream_pipeline_uuid, read the resolved outputs from kwargs['remote_blocks'].

Notes and limitations

  • Remote blocks read saved block variables. The source block must have completed and saved outputs for the referenced execution partition.
  • pipeline_uuid and execution_partition are not filled in automatically when you build remote block references manually. Use the current block context, such as kwargs['pipeline_uuid'] and kwargs.get('execution_partition'), when passing outputs from the current pipeline run.
  • execution_partition pins the downstream read to the source pipeline run that produced the referenced outputs. If it is omitted, Mage reads from the unpartitioned variable path.
  • Remote blocks pass data into block code through keyword arguments, not positional upstream arguments.
  • Global data product blocks pass remote block references while the global data product block itself is executing. Downstream blocks receive the resolved outputs.
  • The partitions setting for a global data product controls how many completed source run partitions are included when reading outputs through the global data product API. Remote block references point to the source run partition returned by the trigger path.