-
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.
Manual changes required for #1215 --------- Signed-off-by: Elliot Gunton <[email protected]>
- Loading branch information
1 parent
88e7b68
commit 5182067
Showing
12 changed files
with
324 additions
and
14 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
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
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
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
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"], | ||
) |
22 changes: 22 additions & 0 deletions
22
examples/workflows/upstream/cron_workflow_multiple_schedules.py
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,22 @@ | ||
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}}"], | ||
) |
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
Oops, something went wrong.