{"id":4562,"library":"hera","title":"Hera","description":"Hera is a Python library that enables orchestration of Python code on Argo Workflows. It allows users to construct and submit Argo Workflows entirely in Python, simplifying interaction with the underlying Argo API. Currently at version 6.0.0, Hera maintains an active release cadence with frequent updates.","status":"active","version":"6.0.0","language":"en","source_language":"en","source_url":"https://github.com/argoproj-labs/hera","tags":["argo","workflow","orchestration","kubernetes","mlops","ci/cd","automation","data-pipelines"],"install":[{"cmd":"pip install hera","lang":"bash","label":"Install latest version"},{"cmd":"pip install hera[yaml]","lang":"bash","label":"Install with YAML support"}],"dependencies":[{"reason":"Hera is an SDK for Argo Workflows and requires an Argo server to be deployed and configured in a Kubernetes cluster.","package":"argo-workflows","optional":false},{"reason":"Required for YAML output functionality.","package":"PyYAML","optional":true},{"reason":"While core Hera models now use dataclasses, Pydantic (v2) is still used internally for some auto-generated models and can be used within script template functions for type validation.","package":"pydantic","optional":false}],"imports":[{"symbol":"Workflow","correct":"from hera.workflows import Workflow"},{"symbol":"script","correct":"from hera.workflows import script"},{"symbol":"DAG","correct":"from hera.workflows import DAG"},{"symbol":"Steps","correct":"from hera.workflows import Steps"},{"note":"Configuration is now managed via `hera.shared.global_config` for broader applicability, rather than instantiating `WorkflowService` directly for host/token setup.","wrong":"from hera.workflow_service import WorkflowService (deprecated pattern)","symbol":"global_config","correct":"from hera.shared import global_config"}],"quickstart":{"code":"import os\nfrom hera.workflows import DAG, Workflow, script\nfrom hera.shared import global_config\n\n# Configure Hera to connect to your Argo Workflows server\n# Set ARGO_SERVER_HOST and ARGO_SERVER_TOKEN environment variables\n# For local testing, ensure Argo Server is port-forwarded (e.g., kubectl -n argo port-forward service/argo-server 2746:2746)\nglobal_config.host = os.environ.get(\"ARGO_SERVER_HOST\", \"http://localhost:2746\")\nglobal_config.token = os.environ.get(\"ARGO_SERVER_TOKEN\", \"\") # Use actual token if required\n\n@script(image=\"python:3.11\")\ndef echo(message: str):\n    \"\"\"A simple Python function to echo a message.\"\"\"\n    print(message)\n\nwith Workflow(\n    generate_name=\"hera-dag-diamond-\",\n    entrypoint=\"diamond\",\n    namespace=\"argo\", # Ensure this matches your Argo Workflows namespace\n    labels={\n        \"example\": \"true\",\n        \"sdk\": \"hera\",\n    }\n) as w:\n    with DAG(name=\"diamond\"):\n        A = echo(name=\"A\", arguments={\"message\": \"Task A\"})\n        B = echo(name=\"B\", arguments={\"message\": \"Task B\"})\n        C = echo(name=\"C\", arguments={\"message\": \"Task C\"})\n        D = echo(name=\"D\", arguments={\"message\": \"Task D\"})\n\n        A >> [B, C] >> D\n\n# Submit the workflow\ntry:\n    submitted_workflow = w.create()\n    print(f\"Workflow '{submitted_workflow.metadata.name}' submitted successfully.\")\n    print(f\"Access UI at {global_config.host}/workflows/{submitted_workflow.metadata.namespace}/{submitted_workflow.metadata.name}\")\nexcept Exception as e:\n    print(f\"Error submitting workflow: {e}\")\n    print(\"Please ensure your Argo Workflows server is running and accessible, and ARGO_SERVER_HOST/TOKEN are configured correctly.\")\n","lang":"python","description":"This quickstart demonstrates how to define a DAG (Directed Acyclic Graph) workflow using Hera, where tasks 'B' and 'C' run in parallel after 'A' completes, and 'D' runs after both 'B' and 'C' are finished. The `echo` function is converted into an Argo script template using the `@script` decorator. The workflow is then submitted to an Argo Workflows server configured via environment variables or a default local endpoint."},"warnings":[{"fix":"Migrate code using `Workflow.dag()`, `Workflow.steps()`, etc., decorators back to using context managers (e.g., `with DAG(...)`) or standard `@script()` for functions. The base `@script()` decorator remains supported.","message":"The experimental decorator feature for `DAG`, `Steps`, `Container`, and `script` (introduced in v5.16) has been removed in v6.0.0. This means users should revert to the context manager pattern or the standard `@script()` decorator if they were using the `Workflow.dag()` or `Workflow.steps()` decorators.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Upgrade Pydantic to v2 across your project. Review Pydantic's official migration guide for v1 to v2 breaking changes. Hera's internal models are now dataclasses, impacting direct interaction with `hera.workflows.models` classes.","message":"Hera v6.0.0 migrates core Hera classes to Python dataclasses and uses Pydantic v2 API models internally where Pydantic is still needed, removing support for Pydantic v1. If your custom script functions relied on Hera's internal Pydantic v1 models or if your project mixes Hera with Pydantic v1 models, you must upgrade your Pydantic dependency to v2 and address any compatibility issues.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Upgrade your Python environment to version 3.10 or higher. Python 3.9 is also End-of-Life upstream, making an upgrade advisable regardless.","message":"Hera v5.27.0 dropped support for Python 3.9. Users on Python 3.9 will need to upgrade their Python environment to 3.10 or newer to use Hera versions 5.27.0 and later.","severity":"breaking","affected_versions":">=5.27.0"},{"fix":"Ensure an Argo Workflows server is deployed and accessible. Configure `hera.shared.global_config.host` and `global_config.token` with the correct server address and authentication token, or ensure necessary port-forwarding is active for local development.","message":"Hera requires an active Argo Workflows server in a Kubernetes cluster for workflow submission. It does not run workflows locally or manage Argo deployments. Proper authentication (e.g., Bearer token) and server accessibility (e.g., port-forwarding) must be configured.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For Hera versions 5.0.0 and later, use `pip install hera`. If you need to install versions prior to 5.0.0, use `pip install hera-workflows`.","message":"The Python package name for Hera changed from `hera-workflows` to `hera` for versions 5.0.0 and above. Attempting to install `hera-workflows` for newer Hera versions will result in an outdated installation.","severity":"gotcha","affected_versions":"<5.0.0 (old name), >=5.0.0 (new name)"},{"fix":"Specify a Docker image in the `@script(image=\"...\")` decorator that includes all necessary Python dependencies (e.g., `numpy`, custom modules) for your function. Alternatively, build and use a custom Docker image from your project's codebase.","message":"Functions decorated with `@script()` are executed as containerized templates on Argo. This means the Docker image specified in the decorator (or default global image) must contain the Python environment and all dependencies required by the decorated function. Local imports and non-standard libraries need to be bundled into the image.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}