Execute a Python script

This task is deprecated, please use the io.kestra.plugin.scripts.python.Script or io.kestra.plugin.scripts.python.Commands task instead.

With the Python task, you can execute a full Python script. The task will create a fresh virtualenv for every tasks and allows to install some Python package define in requirements property.

By convention, you need to define at least a main.py files in inputFiles that will be the script used. But you are also able to add as many script as you need in inputFiles.

You can also add a pip.conf in inputFiles to customize the pip download of dependencies (like a private registry).

You can send outputs & metrics from your python script that can be used by others tasks. In order to help, we inject a python package directly on the working dir.Here is an example usage:

python
from kestra import Kestra
Kestra.outputs({'test': 'value', 'int': 2, 'bool': True, 'float': 3.65})
Kestra.counter('count', 1, {'tag1': 'i', 'tag2': 'win'})
Kestra.timer('timer1', lambda: time.sleep(1), {'tag1': 'i', 'tag2': 'lost'})
Kestra.timer('timer2', 2.12, {'tag1': 'i', 'tag2': 'destroy'})
yaml
type: "io.kestra.core.tasks.scripts.Python"