ShellTask to execute bash scripts within a Flyte workflow. Shell tasks are useful when you need to run system commands, invoke external tools, or orchestrate scripts that are not written in Python.
Imports
shell_task.py
Define a shell task
Create aShellTask by providing a name, the bash script to execute, and optional inputs and outputs:
shell_task.py
ShellTask constructor accepts these key parameters:
| Parameter | Description |
|---|---|
name | Unique name for the task |
script | The bash script to run. Use {inputs.<name>} and {outputs.<name>} as placeholders |
inputs | Input type definitions using kwtypes |
output_locs | Output file locations — a list of OutputLocation objects |
debug | When True, prints the rendered script before execution |
Inputs and outputs
Reference inputs and outputs inside the script using{inputs.<name>} and {outputs.<name>} syntax. Flyte replaces these placeholders with the actual values at execution time.
shell_task.py
Create FlyteFile and FlyteDirectory inputs
Define a Python task to create theFlyteFile and FlyteDirectory inputs needed by the shell tasks. A .gitkeep placeholder file ensures the directory exists:
shell_task.py
Wire tasks into a workflow
shell_task.py
Run locally
shell_task.py
pyflyte run:
Complete example
shell_task.py