Blueprints
Add a parametrized Python script as a Namespace File and run it in parallel in Docker containers
Source
yaml
id: parallel-python
namespace: company.team
tasks:
- id: parallel
type: io.kestra.plugin.core.flow.ForEach
concurrencyLimit: 0
values:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
tasks:
- id: python
type: io.kestra.plugin.scripts.python.Commands
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
containerImage: ghcr.io/kestra-io/pydata:latest
inputFiles:
parametrized.py: |
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--num", type=int, default=42, help="Enter an integer")
args = parser.parse_args()
result = args.num * 2
print(result)
commands:
- python parametrized.py --num {{ taskrun.value }}
About this blueprint
Python Kestra
Add a Python script called parametrized.py
as a Namespace File and run it
in parallel with different parameter values
using a Python script.
You can also add that script directly to NamespaceFiles and set the namespaceFiles.enabled to true instead of using the inputFiles
property.
More Related Blueprints