Skip to content

Commit b51f468

Browse files
authored
Update models for 3.7 compatibility (#1519)
**Pull Request Checklist** - [x] Fixes #1461, also fixes #1312 - [x] Tests added - [x] Documentation/examples added - [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title **Description of PR** * Update models by using `3.7.3` to generate code. * Update examples that have changed and use the new fields * Remove mappings to non-existent fields (`pod_priority` was removed) * Changes to `scripts/spec.py` to avoid creating a cycle in the dependency graph (for `dlqTrigger`, see 6bf1b80) I don't think there are any backwards-incompatible changes in this PR, except for if you are importing from `hera.events.models.io.argoproj.events.v1alpha1` directly for Argo Workflows models as it is now under `hera.events.models.github.com.argoproj.argo_events.pkg.apis.events.v1alpha1` -- users should be importing from `hera.events.models` instead. --------- Signed-off-by: Elliot Gunton <[email protected]>
1 parent c6e3262 commit b51f468

File tree

99 files changed

+1426
-582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1426
-582
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARGO_WORKFLOWS_VERSION="3.6.2"
1+
ARGO_WORKFLOWS_VERSION=3.7.3
22
OPENAPI_SPEC_URL="https://raw.githubusercontent.com/argoproj/argo-workflows/v$(ARGO_WORKFLOWS_VERSION)/api/openapi-spec/swagger.json"
33
SPEC_PATH="$(shell pwd)/argo-workflows-$(ARGO_WORKFLOWS_VERSION).json"
44

@@ -56,6 +56,7 @@ test-cli: ## Run cli tests for Hera
5656

5757
.PHONY: workflows-models
5858
workflows-models: ## Generate the Workflows models portion of Argo Workflows
59+
@rm -rf src/hera/workflows/models
5960
@touch $(SPEC_PATH)
6061
@poetry run python scripts/spec.py $(OPENAPI_SPEC_URL) $(SPEC_PATH)
6162
@poetry run datamodel-codegen \
@@ -79,6 +80,7 @@ workflows-models: ## Generate the Workflows models portion of Argo Workflows
7980

8081
.PHONY: events-models
8182
events-models: ## Generate the Events models portion of Argo Workflows
83+
@rm -rf src/hera/events/models
8284
@touch $(SPEC_PATH)
8385
@poetry run python scripts/spec.py $(OPENAPI_SPEC_URL) $(SPEC_PATH)
8486
@poetry run datamodel-codegen \

docs/api/events/models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## `hera.events.models`
44

5-
::: hera.events.models.io.argoproj.events.v1alpha1
5+
::: hera.events.models.github.com.argoproj.argo_events.pkg.apis.events.v1alpha1
66
options:
77
inherited_members: false
88
show_source: false

docs/examples/workflows-examples.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Explore the examples through the side bar!
2222

2323
| Example |
2424
|---------|
25+
| [artifact-passing-explicit-plugin](https://github.com/argoproj/argo-workflows/blob/main/examples/artifact-passing-explicit-plugin.yaml) |
2526
| [cluster-workflow-template/clustertemplates](https://github.com/argoproj/argo-workflows/blob/main/examples/cluster-workflow-template/clustertemplates.yaml) |
2627
| [configmaps/simple-parameters-configmap](https://github.com/argoproj/argo-workflows/blob/main/examples/configmaps/simple-parameters-configmap.yaml) |
2728
| [cron-backfill](https://github.com/argoproj/argo-workflows/blob/main/examples/cron-backfill.yaml) |

docs/examples/workflows/upstream/loops_param_argument.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
5656
template="cat-os-release",
5757
)
5858
Container(
59+
name="cat-os-release",
60+
annotations={"workflows.argoproj.io/display-name": "os-{{inputs.parameters.image}}-{{inputs.parameters.tag}}"},
5961
inputs=Inputs(
6062
parameters=[
6163
Parameter(
@@ -66,7 +68,6 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
6668
),
6769
],
6870
),
69-
name="cat-os-release",
7071
args=["/etc/os-release"],
7172
command=["cat"],
7273
image="{{inputs.parameters.image}}:{{inputs.parameters.tag}}",
@@ -98,6 +99,9 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
9899
parameters:
99100
- name: os-list
100101
- name: cat-os-release
102+
metadata:
103+
annotations:
104+
workflows.argoproj.io/display-name: os-{{inputs.parameters.image}}-{{inputs.parameters.tag}}
101105
container:
102106
image: '{{inputs.parameters.image}}:{{inputs.parameters.tag}}'
103107
args:

docs/examples/workflows/upstream/retry_backoff.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,7 @@
55
This example is a replication of an Argo Workflow example in Hera.
66
The upstream example can be [found here](https://github.com/argoproj/argo-workflows/blob/main/examples/retry-backoff.yaml).
77

8-
# This example demonstrates the use of retry back offs
9-
apiVersion: argoproj.io/v1alpha1
10-
kind: Workflow
11-
metadata:
12-
generateName: retry-backoff-
13-
spec:
14-
entrypoint: retry-backoff
15-
templates:
16-
- name: retry-backoff
17-
retryStrategy:
18-
limit: "10"
19-
backoff:
20-
duration: "1" # Must be a string. Default unit is seconds. Could also be a Duration, e.g.: "2m", "6h"
21-
factor: "2"
22-
maxDuration: "1m" # Must be a string. Default unit is seconds. Could also be a Duration, e.g.: "2m", "6h"
23-
container:
24-
image: python:alpine3.6
25-
command: ["python", -c]
26-
# fail with a 66% probability
27-
args: ["import random; import sys; exit_code = random.choice([0, 1, 1]); sys.exit(exit_code)"]
8+
289

2910

3011
=== "Hera"
@@ -52,6 +33,7 @@ spec:
5233
duration="1",
5334
factor="2",
5435
max_duration="1m",
36+
cap="5",
5537
),
5638
),
5739
)
@@ -78,6 +60,7 @@ spec:
7860
retryStrategy:
7961
limit: '10'
8062
backoff:
63+
cap: '5'
8164
duration: '1'
8265
factor: '2'
8366
maxDuration: 1m

docs/examples/workflows/upstream/synchronization_db_mutex_tmpl_level.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
5656
mutexes=[
5757
Mutex(
5858
name="welcome",
59+
database=True,
5960
)
6061
],
6162
),
@@ -69,6 +70,7 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
6970
mutexes=[
7071
Mutex(
7172
name="test",
73+
database=True,
7274
)
7375
],
7476
),
@@ -115,6 +117,7 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
115117
synchronization:
116118
mutexes:
117119
- name: welcome
120+
database: true
118121
- name: acquire-lock-1
119122
container:
120123
image: alpine:latest
@@ -126,5 +129,6 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
126129
synchronization:
127130
mutexes:
128131
- name: test
132+
database: true
129133
```
130134

docs/examples/workflows/upstream/synchronization_db_mutex_wf_level.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
2323
mutexes=[
2424
Mutex(
2525
name="test",
26+
database=True,
2627
)
2728
],
2829
),
@@ -55,5 +56,6 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
5556
synchronization:
5657
mutexes:
5758
- name: test
59+
database: true
5860
```
5961

docs/examples/workflows/upstream/synchronization_db_tmpl_level.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
1212

1313
```python linenums="1"
1414
from hera.workflows import Container, Step, Steps, Workflow
15-
from hera.workflows.models import Arguments, Parameter, SemaphoreRef, Synchronization
15+
from hera.workflows.models import Arguments, Parameter, SemaphoreRef, SyncDatabaseRef, Synchronization
1616

1717
with Workflow(
1818
api_version="argoproj.io/v1alpha1",
@@ -39,7 +39,11 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
3939
Container(
4040
name="acquire-lock",
4141
synchronization=Synchronization(
42-
semaphores=[SemaphoreRef()],
42+
semaphores=[
43+
SemaphoreRef(
44+
database=SyncDatabaseRef(key="template"),
45+
)
46+
]
4347
),
4448
args=["sleep 10; echo acquired lock"],
4549
command=["sh", "-c"],
@@ -76,6 +80,7 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
7680
- -c
7781
synchronization:
7882
semaphores:
79-
- {}
83+
- database:
84+
key: template
8085
```
8186

docs/examples/workflows/upstream/synchronization_db_wf_level.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
1212

1313
```python linenums="1"
1414
from hera.workflows import Container, Workflow
15-
from hera.workflows.models import SemaphoreRef, Synchronization
15+
from hera.workflows.models import SemaphoreRef, SyncDatabaseRef, Synchronization
1616

1717
with Workflow(
1818
api_version="argoproj.io/v1alpha1",
1919
kind="Workflow",
2020
generate_name="synchronization-db-wf-level-",
2121
entrypoint="hello-world",
2222
synchronization=Synchronization(
23-
semaphores=[SemaphoreRef()],
23+
semaphores=[
24+
SemaphoreRef(
25+
database=SyncDatabaseRef(key="workflow"),
26+
)
27+
]
2428
),
2529
) as w:
2630
Container(
@@ -50,6 +54,7 @@ The upstream example can be [found here](https://github.com/argoproj/argo-workfl
5054
- echo
5155
synchronization:
5256
semaphores:
53-
- {}
57+
- database:
58+
key: workflow
5459
```
5560

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This example demonstrates the ability to pass artifacts
2+
# from one step to the next with an explicit artifact plugin
3+
apiVersion: argoproj.io/v1alpha1
4+
kind: Workflow
5+
metadata:
6+
generateName: artifact-passing-
7+
spec:
8+
entrypoint: artifact-example
9+
templates:
10+
- name: artifact-example
11+
steps:
12+
- - name: generate-artifact
13+
template: hello-world-to-file
14+
- - name: consume-artifact
15+
template: print-message-from-file
16+
arguments:
17+
artifacts:
18+
- name: message
19+
from: "{{steps.generate-artifact.outputs.artifacts.hello-art}}"
20+
21+
- name: hello-world-to-file
22+
container:
23+
image: busybox
24+
command: [sh, -c]
25+
args: ["sleep 1; echo hello world | tee /tmp/hello_world.txt"]
26+
outputs:
27+
artifacts:
28+
- name: hello-art
29+
path: /tmp/hello_world.txt
30+
plugin:
31+
name: test
32+
configuration: |
33+
bucket: my-bucket
34+
endpoint: minio:9000
35+
insecure: true
36+
accessKeySecret:
37+
name: my-minio-cred
38+
key: accesskey
39+
secretKeySecret:
40+
name: my-minio-cred
41+
key: secretkey
42+
key: hi
43+
44+
- name: print-message-from-file
45+
inputs:
46+
artifacts:
47+
- name: message
48+
path: /tmp/message
49+
container:
50+
image: alpine:latest
51+
command: [sh, -c]
52+
args: ["cat /tmp/message"]

0 commit comments

Comments
 (0)