Skip to content

Commit

Permalink
Fix compatibility with Argo Workflows 3.6 (#1293)
Browse files Browse the repository at this point in the history
**Pull Request Checklist**
- [x] Fixes #1215
- [x] Fixes #1292 
- [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR
title

**Description of PR**
Updates auto-generated models to Argo 3.6. Note there are a few changes
to Hera code which are technically breaking changes (but are very simple
for users to change):
* `resources: Optional[ResourceRequirements]` is now `resources:
Optional[VolumeResourceRequirements]` for volumes. The attributes in the
classes are the same except for `claims` is removed in
`VolumeResourceRequirements`. Updated 4 examples that were using this
* `cluster_name` has been removed in `ObjectMeta` so is also removed in
the `Workflow` class. It was never used by the Argo server (and is
explicitly noted as an "ignored" field in the field description in
`ObjectMeta`).

The rest are changes in the Argo models (i.e. in
`src/hera/workflows/models/io/argoproj/workflow/v1alpha1.py`), that will
affect users using the models directly. **i.e. They'll be
(relatively<sup>1</sup>) stuck on the current `Hera` version until they
upgrade Argo to 3.6 if they are using the following classes in
Argo<3.6**:
* `PodGC` structurally changed - see #1292
* Multiple classes removed with the `Artifact` prefix
* ArtifactGCSpec, ArtifactGCStatus, ArtifactNodeSpec, ArtifactResult,
ArtifactResultNodeStatus
* Duration and Effect removed (now just `str`)
* Container imagePullPolicy is now a str not an enum (we handled either
case in `ContainerMixin` so no change on the Hera side)

1. The workaround would be to use `ModelClass.construct` as seen
[here](#1292 (comment)).

---------

Signed-off-by: Elliot Gunton <[email protected]>
  • Loading branch information
elliotgunton authored Jan 14, 2025
1 parent 964f400 commit bb97fab
Show file tree
Hide file tree
Showing 89 changed files with 4,370 additions and 4,570 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARGO_WORKFLOWS_VERSION="3.5.5"
ARGO_WORKFLOWS_VERSION="3.6.2"
OPENAPI_SPEC_URL="https://raw.githubusercontent.com/argoproj/argo-workflows/v$(ARGO_WORKFLOWS_VERSION)/api/openapi-spec/swagger.json"
SPEC_PATH="$(shell pwd)/argo-workflows-$(ARGO_WORKFLOWS_VERSION).json"

Expand Down
2 changes: 0 additions & 2 deletions docs/examples/workflows-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ Explore the examples through the side bar!
| [conditionals-complex](https://github.com/argoproj/argo-workflows/blob/main/examples/conditionals-complex.yaml) |
| [configmaps/simple-parameters-configmap](https://github.com/argoproj/argo-workflows/blob/main/examples/configmaps/simple-parameters-configmap.yaml) |
| [cron-backfill](https://github.com/argoproj/argo-workflows/blob/main/examples/cron-backfill.yaml) |
| [cron-when](https://github.com/argoproj/argo-workflows/blob/main/examples/cron-when.yaml) |
| [cron-workflow-multiple-schedules](https://github.com/argoproj/argo-workflows/blob/main/examples/cron-workflow-multiple-schedules.yaml) |
| [daemon-step](https://github.com/argoproj/argo-workflows/blob/main/examples/daemon-step.yaml) |
| [daemoned-stateful-set-with-service](https://github.com/argoproj/argo-workflows/blob/main/examples/daemoned-stateful-set-with-service.yaml) |
| [dag-coinflip](https://github.com/argoproj/argo-workflows/blob/main/examples/dag-coinflip.yaml) |
Expand Down
67 changes: 67 additions & 0 deletions docs/examples/workflows/misc/cron_workflow_stop_strategy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Cron Workflow Stop Strategy






=== "Hera"

```python linenums="1"
from hera.workflows import Container, CronWorkflow
from hera.workflows.models import StopStrategy

with CronWorkflow(
name="hello-world-multiple-schedules",
entrypoint="whalesay",
schedules=[
"*/3 * * * *",
"*/2 * * * *",
],
stop_strategy=StopStrategy(expression="cronworkflow.failed >= 3"),
timezone="America/Los_Angeles",
starting_deadline_seconds=0,
concurrency_policy="Replace",
successful_jobs_history_limit=4,
failed_jobs_history_limit=4,
cron_suspend=False,
) as w:
Container(
name="whalesay",
image="docker/whalesay:latest",
command=["cowsay"],
args=["🕓 hello world. Scheduled on: {{workflow.scheduledTime}}"],
)
```

=== "YAML"

```yaml linenums="1"
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
name: hello-world-multiple-schedules
spec:
concurrencyPolicy: Replace
failedJobsHistoryLimit: 4
schedules:
- '*/3 * * * *'
- '*/2 * * * *'
startingDeadlineSeconds: 0
stopStrategy:
expression: cronworkflow.failed >= 3
successfulJobsHistoryLimit: 4
suspend: false
timezone: America/Los_Angeles
workflowSpec:
entrypoint: whalesay
templates:
- container:
args:
- "\U0001F553 hello world. Scheduled on: {{workflow.scheduledTime}}"
command:
- cowsay
image: docker/whalesay:latest
name: whalesay
```

2 changes: 1 addition & 1 deletion docs/examples/workflows/misc/user_container.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This example showcases the user of a user container with a volume mount.
metadata=m.ObjectMeta(name="something"),
spec=m.PersistentVolumeClaimSpec(
access_modes=["ReadWriteOnce"],
resources=m.ResourceRequirements(requests={"storage": "64Mi"}),
resources=m.VolumeResourceRequirements(requests={"storage": "64Mi"}),
),
)
],
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/workflows/upstream/ci_output_artifact.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
metadata=m.ObjectMeta(name="workdir"),
spec=m.PersistentVolumeClaimSpec(
access_modes=["ReadWriteOnce"],
resources=m.ResourceRequirements(
resources=m.VolumeResourceRequirements(
requests={
"storage": m.Quantity(__root__="1Gi"),
}
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/workflows/upstream/ci_workflowtemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
metadata=m.ObjectMeta(name="work"),
spec=m.PersistentVolumeClaimSpec(
access_modes=["ReadWriteOnce"],
resources=m.ResourceRequirements(
resources=m.VolumeResourceRequirements(
requests={
"storage": m.Quantity(__root__="64Mi"),
}
Expand Down
54 changes: 54 additions & 0 deletions docs/examples/workflows/upstream/cron_when.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Cron When

## Note

This example is a replication of an Argo Workflow example in Hera.
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/main/examples/cron-when.yaml).




=== "Hera"

```python linenums="1"
from hera.workflows import Container, CronWorkflow

with CronWorkflow(
name="sleep-when",
entrypoint="sleep-busybox",
schedule="* * * * *",
concurrency_policy="Allow",
when="{{= cronworkflow.lastScheduledTime == nil || (now() - cronworkflow.lastScheduledTime).Seconds() > 360 }}",
) as w:
print_message = Container(
name="sleep-busybox",
image="busybox",
command=["sleep"],
args=["10"],
)
```

=== "YAML"

```yaml linenums="1"
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
name: sleep-when
spec:
concurrencyPolicy: Allow
schedule: '* * * * *'
when: '{{= cronworkflow.lastScheduledTime == nil || (now() - cronworkflow.lastScheduledTime).Seconds()
> 360 }}'
workflowSpec:
entrypoint: sleep-busybox
templates:
- container:
args:
- '10'
command:
- sleep
image: busybox
name: sleep-busybox
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Cron Workflow Multiple Schedules

## Note

This example is a replication of an Argo Workflow example in Hera.
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/main/examples/cron-workflow-multiple-schedules.yaml).




=== "Hera"

```python linenums="1"
from hera.workflows import Container, CronWorkflow

with CronWorkflow(
name="hello-world-multiple-schedules",
entrypoint="whalesay",
schedules=[
"*/3 * * * *",
"*/2 * * * *",
],
timezone="America/Los_Angeles",
starting_deadline_seconds=0,
concurrency_policy="Replace",
successful_jobs_history_limit=4,
failed_jobs_history_limit=4,
cron_suspend=False,
) as w:
Container(
name="whalesay",
image="docker/whalesay:latest",
command=["cowsay"],
args=["🕓 hello world. Scheduled on: {{workflow.scheduledTime}}"],
)
```

=== "YAML"

```yaml linenums="1"
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
name: hello-world-multiple-schedules
spec:
concurrencyPolicy: Replace
failedJobsHistoryLimit: 4
schedules:
- '*/3 * * * *'
- '*/2 * * * *'
startingDeadlineSeconds: 0
successfulJobsHistoryLimit: 4
suspend: false
timezone: America/Los_Angeles
workflowSpec:
entrypoint: whalesay
templates:
- container:
args:
- "\U0001F553 hello world. Scheduled on: {{workflow.scheduledTime}}"
command:
- cowsay
image: docker/whalesay:latest
name: whalesay
```

2 changes: 1 addition & 1 deletion docs/examples/workflows/use-cases/fine_tune_llama.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ There are several implicit dependencies in this script:
m.PersistentVolumeClaim(
metadata=m.ObjectMeta(name=f"rank-{i}"),
spec=m.PersistentVolumeClaimSpec(
resources=m.ResourceRequirements(requests={"storage": "20Gi"}, limits={"storage": "20Gi"}),
resources=m.VolumeResourceRequirements(requests={"storage": "20Gi"}, limits={"storage": "20Gi"}),
# TODO: it's possible to spin up pods in one zone of a region and a disk in another zone of a region!
# I recommend setting a `storage_class_name` that specifically tells K8s that it should create
# the volumes only when pods actually want to _mount_ a volume! That way the disks are
Expand Down
26 changes: 26 additions & 0 deletions examples/workflows/misc/cron-workflow-stop-strategy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
name: hello-world-multiple-schedules
spec:
concurrencyPolicy: Replace
failedJobsHistoryLimit: 4
schedules:
- '*/3 * * * *'
- '*/2 * * * *'
startingDeadlineSeconds: 0
stopStrategy:
expression: cronworkflow.failed >= 3
successfulJobsHistoryLimit: 4
suspend: false
timezone: America/Los_Angeles
workflowSpec:
entrypoint: whalesay
templates:
- container:
args:
- "\U0001F553 hello world. Scheduled on: {{workflow.scheduledTime}}"
command:
- cowsay
image: docker/whalesay:latest
name: whalesay
24 changes: 24 additions & 0 deletions examples/workflows/misc/cron_workflow_stop_strategy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from hera.workflows import Container, CronWorkflow
from hera.workflows.models import StopStrategy

with CronWorkflow(
name="hello-world-multiple-schedules",
entrypoint="whalesay",
schedules=[
"*/3 * * * *",
"*/2 * * * *",
],
stop_strategy=StopStrategy(expression="cronworkflow.failed >= 3"),
timezone="America/Los_Angeles",
starting_deadline_seconds=0,
concurrency_policy="Replace",
successful_jobs_history_limit=4,
failed_jobs_history_limit=4,
cron_suspend=False,
) as w:
Container(
name="whalesay",
image="docker/whalesay:latest",
command=["cowsay"],
args=["🕓 hello world. Scheduled on: {{workflow.scheduledTime}}"],
)
2 changes: 1 addition & 1 deletion examples/workflows/misc/user_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def foo():
metadata=m.ObjectMeta(name="something"),
spec=m.PersistentVolumeClaimSpec(
access_modes=["ReadWriteOnce"],
resources=m.ResourceRequirements(requests={"storage": "64Mi"}),
resources=m.VolumeResourceRequirements(requests={"storage": "64Mi"}),
),
)
],
Expand Down
2 changes: 1 addition & 1 deletion examples/workflows/upstream/ci_output_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
metadata=m.ObjectMeta(name="workdir"),
spec=m.PersistentVolumeClaimSpec(
access_modes=["ReadWriteOnce"],
resources=m.ResourceRequirements(
resources=m.VolumeResourceRequirements(
requests={
"storage": m.Quantity(__root__="1Gi"),
}
Expand Down
2 changes: 1 addition & 1 deletion examples/workflows/upstream/ci_workflowtemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
metadata=m.ObjectMeta(name="work"),
spec=m.PersistentVolumeClaimSpec(
access_modes=["ReadWriteOnce"],
resources=m.ResourceRequirements(
resources=m.VolumeResourceRequirements(
requests={
"storage": m.Quantity(__root__="64Mi"),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
workflows.argoproj.io/test: "true"
annotations:
workflows.argoproj.io/description: |
This workflow demonstrates running a parallel containers within a single pod.
This workflow demonstrates running parallel containers within a single pod.
workflows.argoproj.io/version: ">= 3.1.0"
spec:
entrypoint: main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
workflows.argoproj.io/test: "true"
annotations:
workflows.argoproj.io/description: |
This workflow demonstrates running a parallel containers within a single pod.
This workflow demonstrates running parallel containers within a single pod.
workflows.argoproj.io/version: ">= 3.1.0"
spec:
entrypoint: main
Expand Down
19 changes: 19 additions & 0 deletions examples/workflows/upstream/cron-when.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
name: sleep-when
spec:
concurrencyPolicy: Allow
schedule: '* * * * *'
when: '{{= cronworkflow.lastScheduledTime == nil || (now() - cronworkflow.lastScheduledTime).Seconds()
> 360 }}'
workflowSpec:
entrypoint: sleep-busybox
templates:
- container:
args:
- '10'
command:
- sleep
image: busybox
name: sleep-busybox
24 changes: 24 additions & 0 deletions examples/workflows/upstream/cron-workflow-multiple-schedules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
name: hello-world-multiple-schedules
spec:
concurrencyPolicy: Replace
failedJobsHistoryLimit: 4
schedules:
- '*/3 * * * *'
- '*/2 * * * *'
startingDeadlineSeconds: 0
successfulJobsHistoryLimit: 4
suspend: false
timezone: America/Los_Angeles
workflowSpec:
entrypoint: whalesay
templates:
- container:
args:
- "\U0001F553 hello world. Scheduled on: {{workflow.scheduledTime}}"
command:
- cowsay
image: docker/whalesay:latest
name: whalesay
15 changes: 15 additions & 0 deletions examples/workflows/upstream/cron_when.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from hera.workflows import Container, CronWorkflow

with CronWorkflow(
name="sleep-when",
entrypoint="sleep-busybox",
schedule="* * * * *",
concurrency_policy="Allow",
when="{{= cronworkflow.lastScheduledTime == nil || (now() - cronworkflow.lastScheduledTime).Seconds() > 360 }}",
) as w:
print_message = Container(
name="sleep-busybox",
image="busybox",
command=["sleep"],
args=["10"],
)
Loading

0 comments on commit bb97fab

Please sign in to comment.