-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compatibility with Argo Workflows 3.6 (#1293)
**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
1 parent
964f400
commit bb97fab
Showing
89 changed files
with
4,370 additions
and
4,570 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
docs/examples/workflows/misc/cron_workflow_stop_strategy.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
66 changes: 66 additions & 0 deletions
66
docs/examples/workflows/upstream/cron_workflow_multiple_schedules.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}}"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
examples/workflows/upstream/cron-workflow-multiple-schedules.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"], | ||
) |
Oops, something went wrong.