• Stars
    star
    594
  • Rank 75,329 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 3 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Hera makes Python code easy to orchestrate on Argo Workflows through native Python integrations. It lets you construct and submit your Workflows entirely in Python. ⭐️ Remember to star!

Hera

See the Quick Start guide to start using Hera to orchestrate your Argo Workflows!

The Argo was constructed by the shipwright Argus,
and its crew were specially protected by the goddess Hera.

Open in Gitpod

Build Docs codecov License: MIT

Pypi CondaForge Versions

Stats after the rename to Hera

Downloads Downloads/month Downloads/week

Stats before the rename to Hera

Downloads Downloads/month Downloads/week

Hera is a Python framework for constructing and submitting Argo Workflows. The main goal of Hera is to make the Argo ecosystem accessible by simplifying workflow construction and submission.

You can watch the introductory Hera presentation at the "Argo Workflows and Events Community Meeting 20 Oct 2021" here!

Table of content

Requirements

Hera requires an Argo server to be deployed to a Kubernetes cluster. Currently, Hera assumes that the Argo server sits behind an authentication layer that can authenticate workflow submission requests by using the Bearer token on the request. To learn how to deploy Argo to your own Kubernetes cluster you can follow the Argo Workflows guide!

Another option for workflow submission without the authentication layer is using port forwarding to your Argo server deployment and submitting workflows to localhost:2746 (2746 is the default, but you are free to use yours). Please refer to the documentation of Argo Workflows to see the command for port forward!

Note Since the deprecation of tokens being automatically created for ServiceAccounts and Argo using Bearer tokens in place, it is necessary to use --auth=server and/or --auth=client when setting up Argo Workflows on Kubernetes v1.24+ in order for hera to communicate to the Argo Server.

Installation

Note

Hera went through a name change - from hera-workflows to hera. This is reflected in the published Python package. If you'd like to install versions prior to 5.0.0, you have to use hera-workflows. Hera currently publishes releases to both hera and hera-workflows for backwards compatibility purposes.

Source Command
PyPi pip install hera
PyPi pip install hera-workflows
Conda conda install -c conda-forge hera-workflows
GitHub repo python -m pip install git+https://github.com/argoproj-labs/hera --ignore-installed/pip install .

Optional dependencies

yaml

  • Install via hera[yaml]
  • PyYAML is required for the yaml output format, which is accessible via
    hera.workflows.Workflow.to_yaml(*args, **kwargs). This enables GitOps practices and easier debugging

Examples

Single step script

from hera.workflows import Steps, Workflow, script


@script()
def echo(message: str):
    print(message)


with Workflow(
    generate_name="single-script-",
    entrypoint="steps",
) as w:
    with Steps(name="steps"):
        echo(arguments={"message": "A"})

w.create()

DAG diamond

from hera.workflows import DAG, Workflow, script


@script()
def echo(message: str):
    print(message)


with Workflow(
    generate_name="dag-diamond-",
    entrypoint="diamond",
) as w:
    with DAG(name="diamond"):
        A = echo(name="A", arguments={"message": "A"})
        B = echo(name="B", arguments={"message": "B"})
        C = echo(name="C", arguments={"message": "C"})
        D = echo(name="D", arguments={"message": "D"})
        A >> [B, C] >> D

w.create()

See the examples directory for a collection of Argo workflow construction and submission via Hera!

Contributing

If you plan to submit contributions to Hera you can install Hera in a virtual environment managed by poetry:

poetry install

Once the dependencies are installed, you can use the various make targets to replicate the CI jobs.

make help
check-codegen                  Check if the code is up to date
ci                             Run all the CI checks
codegen                        Generate all the code
events-models                  Generate the Events models portion of Argo Workflows
events-service                 Generate the events service option of Hera
examples                       Generate all the examples
format                         Format and sort imports for source, tests, examples, etc.
help                           Showcase the help instructions for all the available `make` commands
lint                           Run a `lint` process on Hera and report problems
models                         Generate all the Argo Workflows models
services                       Generate the services of Hera
test                           Run tests for Hera
workflows-models               Generate the Workflows models portion of Argo Workflows
workflows-service              Generate the Workflows service option of Hera

Also, see the contributing guide!

Comparison

There have been other libraries available for structuring and submitting Argo Workflows:

  • Couler, which aimed to provide a unified interface for constructing and managing workflows on different workflow engines. It has now been unmaintained since its last commit in April 2022.
  • Argo Python DSL, which allows you to programmatically define Argo worfklows using Python. It was archived in October 2021.

While the aforementioned libraries provided amazing functionality for Argo workflow construction and submission, they required an advanced understanding of Argo concepts. When Dyno Therapeutics started using Argo Workflows, it was challenging to construct and submit experimental machine learning workflows. Scientists and engineers at Dyno Therapeutics used a lot of time for workflow definition rather than the implementation of the atomic unit of execution - the Python function - that performed, for instance, model training.

Hera presents an intuitive Python interface to the underlying API of Argo, with custom classes making use of context managers and callables, empowering users to focus on their own executable payloads rather than workflow setup.

Here's a side by side comparison of Hera, Couler, and Argo Python DSL

You will see how Hera has focused on reducing the complexity of Argo concepts while also reducing the total lines of code required to construct the diamond example, which can be found in the upstream Argo repository.

HeraCoulerArgo Python DSL

from hera.workflows import DAG, Container, Parameter, Workflow

with Workflow(
    generate_name="dag-diamond-",
    entrypoint="diamond",
) as w:
    echo = Container(
        name="echo",
        image="alpine:3.7",
        command=["echo", "{{inputs.parameters.message}}"],
        inputs=[Parameter(name="message")],
    )
    with DAG(name="diamond"):
        A = echo(name="A", arguments={"message": "A"})
        B = echo(name="B", arguments={"message": "B"})
        C = echo(name="C", arguments={"message": "C"})
        D = echo(name="D", arguments={"message": "D"})
        A >> [B, C] >> D

w.create()

import couler.argo as couler
from couler.argo_submitter import ArgoSubmitter


def job(name):
    couler.run_container(
        image="docker/whalesay:latest",
        command=["cowsay"],
        args=[name],
        step_name=name,
    )


def diamond():
    couler.dag(
        [
            [lambda: job(name="A")],
            [lambda: job(name="A"), lambda: job(name="B")],  # A -> B
            [lambda: job(name="A"), lambda: job(name="C")],  # A -> C
            [lambda: job(name="B"), lambda: job(name="D")],  # B -> D
            [lambda: job(name="C"), lambda: job(name="D")],  # C -> D
        ]
    )


diamond()
submitter = ArgoSubmitter()
couler.run(submitter=submitter)

from argo.workflows.dsl import Workflow

from argo.workflows.dsl.tasks import *
from argo.workflows.dsl.templates import *


class DagDiamond(Workflow):

    @task
    @parameter(name="message", value="A")
    def A(self, message: V1alpha1Parameter) -> V1alpha1Template:
        return self.echo(message=message)

    @task
    @parameter(name="message", value="B")
    @dependencies(["A"])
    def B(self, message: V1alpha1Parameter) -> V1alpha1Template:
        return self.echo(message=message)

    @task
    @parameter(name="message", value="C")
    @dependencies(["A"])
    def C(self, message: V1alpha1Parameter) -> V1alpha1Template:
        return self.echo(message=message)

    @task
    @parameter(name="message", value="D")
    @dependencies(["B", "C"])
    def D(self, message: V1alpha1Parameter) -> V1alpha1Template:
        return self.echo(message=message)

    @template
    @inputs.parameter(name="message")
    def echo(self, message: V1alpha1Parameter) -> V1Container:
        container = V1Container(
            image="alpine:3.7",
            name="echo",
            command=["echo", "{{inputs.parameters.message}}"],
        )

        return container

More Repositories

1

argocd-image-updater

Automatic container image update for Argo CD
Go
1,241
star
2

argocd-autopilot

Argo-CD Autopilot
Go
889
star
3

argocd-vault-plugin

An Argo CD plugin to retrieve secrets from Secret Management tools and inject them into Kubernetes secrets
Go
805
star
4

argocd-operator

A Kubernetes operator for managing Argo CD clusters.
Go
646
star
5

argocd-notifications

Notifications for Argo CD
Go
492
star
6

terraform-provider-argocd

Terraform provider for ArgoCD
Go
397
star
7

old-argo-dataflow

Dataflow is a Kubernetes-native platform for executing large parallel data-processing pipelines.
Go
269
star
8

rollout-extension

Argo Rollout visualization in Argo CD Web UI
TypeScript
186
star
9

argocd-bot

Bot to automate Kubernetes deployment via Github PRs
TypeScript
135
star
10

argocd-extension-metrics

An Argo CD extension to enable visualization of metrics in Argo CD UI.
TypeScript
115
star
11

argocd-extensions

Support for extending Argo CD
Go
108
star
12

argo-python-dsl

Python DSL for Argo Workflows
Python
99
star
13

argo-kube-notifier

Argo Kube Notifier controller monitors Kubernetes resources
Go
95
star
14

argo-rollouts-manager

Kubernetes Operator for Argo Rollouts controller.
Go
93
star
15

rollouts-plugin-trafficrouter-gatewayapi

The Argo Rollouts plugin implementing the Kubernetes Gateway API specification for using different traffic providers in progressive delivery scenarios
Go
92
star
16

argo-workflows-catalog

Argo Workflows Catalog
Go
86
star
17

gordian

Gordian applies transformations to files across multiple github repositories and creates pull requests for the owners of the repositories to review and merge them.
Python
79
star
18

argocd-interlace

Enabling Software Supply Chain Security Capabilities in ArgoCD
Go
78
star
19

argo-client-python

⚠️⚠️⚠️This repository is no longer maintained, please find your Java SDKs https://github.com/argoproj/argo-workflows/blob/master/docs/client-libraries.md ⚠️⚠️⚠️
Python
78
star
20

argocd-agent

Redefining the multi cluster story of Argo CD
Go
53
star
21

argo-client-java

⚠️This repository is no longer maintained, please find your Java SDKs https://github.com/argoproj/argo-workflows/blob/master/docs/client-libraries.md
Java
35
star
22

appsource

Automatically self-serviced applications for ArgoCD.
Go
24
star
23

argocd-extension-installer

Install Argo CD extensions using init-containers
Shell
17
star
24

rollouts-plugin-trafficrouter-contour

The Argo Rollouts plugin implementing the Contour HTTPProxy traffic control in progressive delivery scenarios.
Go
15
star
25

argocd-rbac-operator

Kubernetes Operator for Argo CD RBAC Management.
Go
14
star
26

applicationset-hello-plugin

Python
13
star
27

community

Community documents for argoproj-labs
12
star
28

argo-java-client

Created java data model from argo project by it's swagger files. Argo proj does use Kubernetes api so this client only contains Model and no APIs
Java
12
star
29

argoverse

ShaderLab
11
star
30

training-material

Shell
8
star
31

argo-client-gen

⚠️⚠️⚠️This repository is no longer maintained, please find your Java SDKs https://github.com/argoproj/argo-workflows/blob/master/docs/client-libraries.md ⚠️⚠️⚠️
8
star
32

argo-cd-benchmarking

JavaScript
7
star
33

gitops-promoter

A GitOps Environment Promotion Tool
Go
7
star
34

multi-cluster-kubernetes

Proof of concept of amalgamating multiple Kubernetes APIs into a single view
Go
6
star
35

argo-cd-tokens

Go
6
star
36

argo-workflows-slack-executor-plugin

Python
5
star
37

argocd-example-extension

JavaScript
5
star
38

argo-workflows-python-executor-plugin

Python
5
star
39

argo-graph

TypeScript
4
star
40

rollouts-plugin-trafficrouter-consul

Argo Rollouts Plugin for Consul Service Mesh
Go
4
star
41

friends

Projects which would love to associate themselves with the Argo ecosystem of projects!
4
star
42

argo-workflows-events-workshop

3
star
43

couler

This project has been moved to https://github.com/couler-proj/couler
3
star
44

argo-eventbus

Go
3
star
45

argocd-ephemeral-access

A kubernetes controller to manage Argo CD temporary access
Go
3
star
46

argocd-cmp-plugin-examples

2
star
47

terraform-provider-argocd-old

2
star
48

argo-workflows-hello-executor-plugin

Python
1
star
49

rollouts-opsmx-metric-plugin

Argo Rollouts plugin implementation for logs and metrics analysis
1
star
50

rollouts-plugin-trafficrouter-openshift

Go
1
star