Build Runner
Generate Python code to run a pipe with all necessary imports and example inputs.
Usage
From a bundle
pipelex build runner bundle <PATH> [OPTIONS]
Arguments:
PATH- Path to a.mthdsbundle file or a pipeline directory
Options:
--pipe- Pipe code to use (optional if the.mthdsdeclares amain_pipe)--output,-o- Path to save the generated Python file (defaults to target's directory)--library-dirs,-L- Directories to search for pipe definitions. Can be specified multiple times.
From an installed method
pipelex build runner method <NAME> [OPTIONS]
Arguments:
NAME- Name of the installed method
Options:
--pipe- Pipe code (overrides method'smain_pipe)--output,-o- Path to save the generated Python file--library-dirs,-L- Directories to search for pipe definitions. Can be specified multiple times.
Examples
Generate runner from a bundle (uses main_pipe):
pipelex build runner bundle my_bundle.mthds
Generate runner from a pipeline directory:
pipelex build runner bundle pipeline_01/
Specify which pipe to use from a bundle:
pipelex build runner bundle my_bundle.mthds --pipe my_pipe
With additional library directories:
pipelex build runner bundle my_bundle.mthds -L ./shared_pipes/ -L ./common/
Custom output path:
pipelex build runner bundle my_bundle.mthds --output custom_runner.py
What Gets Generated
The generated Python file includes:
- All necessary imports - Imports for Pipelex execution, content types, and any custom structures
- Generated Pydantic structures - Models for your concepts (also generated separately)
- Input memory setup - Example input values based on the pipe's input types
- Pipeline execution - Async function that executes the pipeline
- Output handling - Code to extract and display the results
- Main execution block - Pipelex initialization and asyncio setup
Input Type Handling
- Native concepts (Text, Image, Document, etc.) - Automatically generates appropriate content objects
- Custom concepts - Recursively generates the structure with example values
- Structured content - Creates example data matching the concept's fields
Using the Generated Runner
After generating the runner file:
- Open the generated Python file
- Review and customize the example input values
- Run the script:
python results/run_{pipe_code}.py - Iterate and adjust as needed
Related Documentation
- Build Structures - Generate Pydantic models separately
- Build Inputs - Generate example input JSON for a pipe
- Build Output - Generate example output JSON for a pipe
- Run Command - Run pipes directly from CLI