跳转到主要内容

Hera通过本机Python集成,使Python代码在Argo Workflows上编排变得容易。它允许您完全在Python中构建和提交您的Workflows。

项目描述

Hera

Hera mascot

Hera通过本机Python集成,使Python代码在Argo Workflows上编排变得容易。它允许您完全在Python中构建和提交您的Workflows。

查看快速入门指南 以开始使用Hera来编排您的Argo Workflows!

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

PyPI统计

PyPI Versions

Downloads Downloads/month Downloads/week

仓库信息

License: Apache-2.0 CICD Docs codecov

探索代码

Open in GitHub Codespaces

Open in Gitpod

Hera概述

步骤钻石

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") as s:
        echo(name="A", arguments={"message": "I'm a step"})
        with s.parallel():
            echo(name="B", arguments={"message": "We're steps"})
            echo(name="C", arguments={"message": "in parallel!"})
        echo(name="D", arguments={"message": "I'm another step!"})

w.create()

DAG钻石

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()

查看示例,了解如何通过Hera构建和提交Argo Workflows!

需求

赫拉需要部署一个Argo服务器到Kubernetes集群中。目前,赫拉假设Argo服务器位于一个身份验证层之后,该层可以使用请求中的Bearer令牌对工作流提交请求进行身份验证。要了解如何将Argo部署到自己的Kubernetes集群,请参考Argo Workflows指南!

在没有身份验证层的情况下提交工作流的另一种选项是使用端口转发到Argo服务器部署,并将工作流提交到localhost:2746(2746是默认端口,但您可以自由更改)。请参阅Argo Workflows文档以查看端口转发的命令!

注意 由于为ServiceAccounts和Argo自动创建令牌以及在使用Bearer令牌的情况下替换它们已被弃用,因此在使用Kubernetes v1.24+上的Argo Workflows时,必须使用--auth=server和/或--auth=client,以便赫拉能够与Argo服务器通信。

在赫拉中进行身份验证

在赫拉中进行身份验证有几种方法 - 在身份验证教程中了解更多信息 - 现在,如果已安装argo cli工具,此示例将帮助您快速启动

from hera.workflows import Workflow, Container
from hera.shared import global_config
from hera.auth import ArgoCLITokenGenerator

global_config.host = "http://localhost:2746"
global_config.token = ArgoCLITokenGenerator

with Workflow(generate_name="local-test-", entrypoint="c") as w:
    Container(name="c", image="docker/whalesay", command=["cowsay", "hello"])

w.create()

安装

源代码 命令
PyPI pip install hera
GitHub仓库 python -m pip install git+https://github.com/argoproj-labs/hera --ignore-installed

注意 赫拉进行了名称变更 - 从hera-workflows变更为hera。这在发布的Python包中得到反映。如果您想安装版本低于5.0.0的版本,您应该执行pip install hera-workflows<5。赫拉目前为了向后兼容,同时发布到herahera-workflows

可选依赖项

yaml

  • 通过hera[yaml]安装
  • PyYAML是必需的,用于yaml输出格式,可通过hera.workflows.Workflow.to_yaml(*args, **kwargs)访问。这可以启用GitOps实践和更轻松的调试。

cli

  • 通过hera[cli]安装。该[cli]选项安装了CLI所需的额外依赖项Cappa
  • CLI旨在启用GitOps实践、更轻松的调试以及与Argo Workflows的更无缝体验。
  • CLI是一个实验性功能,可能随时更改! 目前,它仅支持通过hera generate yaml生成工作流的YAML文件。有关更多信息,请参阅hera generate yaml --help

实验性

  • 通过hera[experimental]安装。该[experimental]选项添加了实验性功能所需的依赖项,这些功能尚未毕业为稳定功能。

演示

博客

贡献

查看贡献指南

项目详情


版本历史 发布通知 | RSS订阅

下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

hera_workflows-5.17.1.tar.gz (288.6 kB 查看哈希值)

上传时间 源代码

构建分发版本

hera_workflows-5.17.1-py3-none-any.whl (333.0 kB 查看哈希值)

上传时间 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面