{"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":"python","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,"search_vec":"'6.0.0':38 'activ':42 'allow':17 'api':34 'argo':14,23,33,48 'autom':54 'cadenc':44 'ci/cd':53 'code':12 'construct':20 'current':35 'data':56 'data-pipelin':55 'enabl':8 'entir':25 'frequent':46 'hera':1,2,39 'interact':29 'kubernet':51 'librari':6 'maintain':40 'mlop':52 'orchestr':9,50 'pipelin':57 'python':5,11,27 'releas':43 'simplifi':28 'submit':22 'under':32 'updat':47 'user':18 'version':37 'workflow':15,24,49","created_at":"2026-04-12T13:57:57.217782+00:00","updated_at":"2026-04-16T15:33:51.984842+00:00","problems":[{"fix":"Ensure you have the correct package installed for your Hera version. For Hera v5.0.0 and later, use `pip install hera`. If you are using an older version (pre-5.0.0), use `pip install hera-workflows`.","cause":"This error occurs when the 'hera' package is not installed in your Python environment, or if you are trying to import it using an incorrect name. Prior to version 5.0.0, the package was named 'hera-workflows'.","error":"ModuleNotFoundError: No module named 'hera'"},{"fix":"Verify the `host` and `token` provided to `WorkflowService` or `global_config`. Ensure the Argo Workflows server is accessible, the token is valid, and the associated Kubernetes Service Account has the necessary RBAC permissions to create and manage workflows in the target namespace. For local testing, port-forwarding to `localhost:2746` can often bypass some authentication complexities.","cause":"This error indicates that Hera is unable to authenticate with the Argo Workflows server. This is commonly due to an incorrect Argo Server host, a missing or invalid authentication token, or insufficient Kubernetes Role-Based Access Control (RBAC) permissions for the service account Hera is using.","error":"argo.workflows.client.exceptions.ApiException: (401) Reason: Unauthorized"},{"fix":"Ensure that `Steps` and `Task` definitions are always placed within the context manager of a `Workflow` or `DAG`. For example, use `with Workflow(...) as wf: with Steps(...) as steps: ...` or `with Workflow(...) as wf: with DAG(...) as dag: ...` to properly associate the components.","cause":"This error typically occurs when attempting to define or instantiate `Steps` (or other workflow building blocks like `Tasks`) outside the proper context of a `Workflow` or `DAG` object, where they are expected to be nested using Python's `with` statement. Hera requires these components to be part of an active workflow context to correctly build the Argo YAML.","error":"AttributeError: 'Steps' object has no attribute 'templates'"},{"fix":"Review the type hints of parameters in your `@script` decorated functions. Ensure they are correctly specified and compatible with Python's `typing` module and Hera's type introspection. If using complex types or Pydantic models, verify Hera's compatibility with the specific Pydantic version and consider simplifying type hints or ensuring all arguments correctly resolve to class types. Sometimes, simplifying generics or providing explicit class types can resolve the issue.","cause":"This `TypeError` often arises within Hera's runner when it attempts to introspect types of parameters passed to `@script` decorated functions, particularly with complex type hints (e.g., `Optional[str]`, `List[PydanticModel]`) or when `get_args` from the `typing` module returns something that is not a class, leading to an invalid argument for `issubclass`. This can be a subtle issue related to how types are resolved or passed.","error":"TypeError: issubclass() arg 1 must be a class"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"7.1.0","cli_name":"hera","cli_version":"Traceback (most recent call last):","type":"library","homepage":"https://hera.readthedocs.io","github":"https://github.com/argoproj-labs/hera","docs":"https://hera.readthedocs.io/en/stable/","changelog":null,"pypi":"https://pypi.org/project/hera/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","workflow","aws"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}