Hera Workflows

6.0.0 · active · verified Fri Apr 17

Hera Workflows is a Python library that simplifies the orchestration of Python code on Argo Workflows. It allows users to define, construct, and submit complex workflows entirely in Python, abstracting away much of the underlying YAML complexity. The current version is 6.0.0, and the project maintains an active release cadence with frequent updates.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates a basic Hera workflow with a single task that prints a greeting. It shows how to define a Python function as a task, configure it with parameters, and submit the workflow to an Argo Workflows instance. Ensure `ARGO_SERVER` and `ARGO_TOKEN` environment variables are set for a remote Argo server, or configure `global_config.host` appropriately for local development.

import os
from hera.workflows import Workflow, Task, Parameter
from hera.shared import global_config

# Configure Hera to connect to Argo Workflows (adjust as needed)
# For local testing, ensure ARGO_SERVER and ARGO_TOKEN are set,
# or modify client configuration directly.
global_config.host = os.environ.get('ARGO_SERVER', 'http://localhost:2746')
global_config.token = os.environ.get('ARGO_TOKEN', '')
global_config.verify_ssl = False # Set to True in production

def my_task_func(name: str):
    print(f"Hello, {name} from Hera!")

with Workflow(generate_name="my-first-hera-workflow-", entrypoint="my-entrypoint") as w:
    my_task = Task(
        name="my-entrypoint",
        inputs=[Parameter(name="message", default="World")],
        func=my_task_func,
        arguments=["{{inputs.parameters.message}}"]
    )

w.submit()

view raw JSON →