Blueprints

Docker container installing pip packages before starting a Python Script task

Source

yaml
id: pip-packages-docker
namespace: company.team

tasks:
  - id: run_python
    type: io.kestra.plugin.scripts.python.Script
    beforeCommands:
      - pip install requests kestra > /dev/null
    warningOnStdErr: false
    script: |
      import requests
      import json

      response = requests.get("https://api.github.com")
      data = response.json()
      print(data)

About this blueprint

pip Python Software Engineering

This flow uses the default Docker Task Runner and the default python:latest Docker image. This means that pip is available out of the box and you can add several beforeCommands to install custom Pip packages, and prepare the environment for the task. Adding warningOnStdErr: false ensures that warnings raised during pip package installation don't set the task to a WARNING state. However, by default, any warning raised during the setup process (i.e. when executing beforeCommands) will end the task in the WARNING state.

Script

More Related Blueprints

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra