-
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 validation error for retry strategy (#558)
Fix validation error for retry strategy Signed-off-by: lakhanjindam <lakhanj569@gmail.com>
- Loading branch information
1 parent
7a441ae
commit 0ecec66
Showing
5 changed files
with
115 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Retry Script | ||
|
||
> 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/master/examples/retry-script.yaml). | ||
|
||
|
||
|
||
=== "Hera" | ||
|
||
```python linenums="1" | ||
from hera.workflows import Workflow, script, RetryStrategy | ||
|
||
|
||
@script(image="python:alpine3.6", retry_strategy=RetryStrategy(limit=10), add_cwd_to_sys_path=False) | ||
def retry_script(): | ||
import random | ||
import sys | ||
|
||
exit_code = random.choice([0, 1, 1]) | ||
sys.exit(exit_code) | ||
|
||
|
||
with Workflow(generate_name="retry-script-", entrypoint="retry-script") as w: | ||
retry_script() | ||
``` | ||
|
||
=== "YAML" | ||
|
||
```yaml linenums="1" | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: retry-script- | ||
spec: | ||
entrypoint: retry-script | ||
templates: | ||
- name: retry-script | ||
retryStrategy: | ||
limit: '10' | ||
script: | ||
command: | ||
- python | ||
image: python:alpine3.6 | ||
source: 'import random | ||
|
||
import sys | ||
|
||
|
||
exit_code = random.choice([0, 1, 1]) | ||
|
||
sys.exit(exit_code) | ||
|
||
' | ||
``` | ||
|
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,20 @@ | ||
# This example demonstrates the use of retries for a single script. | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: retry-script- | ||
spec: | ||
entrypoint: retry-script | ||
templates: | ||
- name: retry-script | ||
retryStrategy: | ||
limit: "10" | ||
script: | ||
image: python:alpine3.6 | ||
command: ["python"] | ||
# fail with a 66% probability | ||
source: | | ||
import random; | ||
import sys; | ||
exit_code = random.choice([0, 1, 1]); | ||
sys.exit(exit_code) |
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: Workflow | ||
metadata: | ||
generateName: retry-script- | ||
spec: | ||
entrypoint: retry-script | ||
templates: | ||
- name: retry-script | ||
retryStrategy: | ||
limit: '10' | ||
script: | ||
command: | ||
- python | ||
image: python:alpine3.6 | ||
source: 'import random | ||
import sys | ||
exit_code = random.choice([0, 1, 1]) | ||
sys.exit(exit_code) | ||
' |
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,14 @@ | ||
from hera.workflows import RetryStrategy, Workflow, script | ||
|
||
|
||
@script(image="python:alpine3.6", retry_strategy=RetryStrategy(limit=10), add_cwd_to_sys_path=False) | ||
def retry_script(): | ||
import random | ||
import sys | ||
|
||
exit_code = random.choice([0, 1, 1]) | ||
sys.exit(exit_code) | ||
|
||
|
||
with Workflow(generate_name="retry-script-", entrypoint="retry-script") as w: | ||
retry_script() |
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