-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Do not use /tmp for script outputs * Allow mounting own volume with use_volume_for_outputs * Fix examples using volumes incorrectly and simplify where possible * Fix passing artifacts as argument (remove path), and simplify examples Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
- Loading branch information
1 parent
bb3c7c0
commit 91196d8
Showing
30 changed files
with
570 additions
and
56 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
2 changes: 1 addition & 1 deletion
2
docs/examples/workflows/http_.md → docs/examples/workflows/http.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Http | ||
# Http | ||
|
||
|
||
|
||
|
145 changes: 145 additions & 0 deletions
145
docs/examples/workflows/script_annotations_artifact_custom_volume.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,145 @@ | ||
# Script Annotations Artifact Custom Volume | ||
|
||
|
||
|
||
This example will reuse the outputs volume across script steps. | ||
|
||
|
||
=== "Hera" | ||
|
||
```python linenums="1" | ||
from hera.workflows.artifact import ArtifactLoader | ||
from hera.workflows.volume import Volume | ||
|
||
try: | ||
from typing import Annotated # type: ignore | ||
except ImportError: | ||
from typing_extensions import Annotated # type: ignore | ||
|
||
|
||
from hera.shared import global_config | ||
from hera.workflows import ( | ||
Artifact, | ||
Parameter, | ||
RunnerScriptConstructor, | ||
Steps, | ||
Workflow, | ||
models as m, | ||
script, | ||
) | ||
|
||
global_config.experimental_features["script_annotations"] = True | ||
global_config.experimental_features["script_runner"] = True | ||
|
||
vol = Volume(name="my-vol", size="1Gi") | ||
|
||
|
||
@script( | ||
constructor=RunnerScriptConstructor(use_volume_for_outputs=vol.name), | ||
volume_mounts=[m.VolumeMount(name="my-vol", mount_path="/mnt/here")], | ||
) | ||
def output_artifact( | ||
a_number: Annotated[int, Parameter(name="a_number")], | ||
) -> Annotated[int, Artifact(name="successor_out")]: | ||
return a_number + 1 | ||
|
||
|
||
@script( | ||
constructor=RunnerScriptConstructor(use_volume_for_outputs=vol.name), | ||
volume_mounts=[m.VolumeMount(name="my-vol", mount_path="/mnt/here")], | ||
) | ||
def use_artifact(successor_in: Annotated[int, Artifact(name="successor_in", loader=ArtifactLoader.json)]): | ||
print(successor_in) | ||
|
||
|
||
with Workflow( | ||
generate_name="test-output-annotations-", | ||
entrypoint="my-steps", | ||
volumes=[vol], | ||
) as w: | ||
with Steps(name="my-steps") as s: | ||
out = output_artifact(arguments={"a_number": 3}) | ||
use_artifact(arguments=[out.get_artifact("successor_out").as_name("successor_in")]) | ||
``` | ||
|
||
=== "YAML" | ||
|
||
```yaml linenums="1" | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: test-output-annotations- | ||
spec: | ||
entrypoint: my-steps | ||
templates: | ||
- name: my-steps | ||
steps: | ||
- - arguments: | ||
parameters: | ||
- name: a_number | ||
value: '3' | ||
name: output-artifact | ||
template: output-artifact | ||
- - arguments: | ||
artifacts: | ||
- from: '{{steps.output-artifact.outputs.artifacts.successor_out}}' | ||
name: successor_in | ||
name: use-artifact | ||
template: use-artifact | ||
- inputs: | ||
parameters: | ||
- name: a_number | ||
name: output-artifact | ||
outputs: | ||
artifacts: | ||
- name: successor_out | ||
path: /hera/outputs/artifacts/successor_out | ||
script: | ||
args: | ||
- -m | ||
- hera.workflows.runner | ||
- -e | ||
- examples.workflows.script_annotations_artifact_custom_volume:output_artifact | ||
command: | ||
- python | ||
env: | ||
- name: hera__script_annotations | ||
value: '' | ||
- name: hera__outputs_directory | ||
value: /hera/outputs | ||
image: python:3.8 | ||
source: '{{inputs.parameters}}' | ||
volumeMounts: | ||
- mountPath: /mnt/here | ||
name: my-vol | ||
- inputs: | ||
artifacts: | ||
- name: successor_in | ||
name: use-artifact | ||
script: | ||
args: | ||
- -m | ||
- hera.workflows.runner | ||
- -e | ||
- examples.workflows.script_annotations_artifact_custom_volume:use_artifact | ||
command: | ||
- python | ||
env: | ||
- name: hera__script_annotations | ||
value: '' | ||
image: python:3.8 | ||
source: '{{inputs.parameters}}' | ||
volumeMounts: | ||
- mountPath: /mnt/here | ||
name: my-vol | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: my-vol | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
``` | ||
|
125 changes: 125 additions & 0 deletions
125
docs/examples/workflows/script_annotations_artifact_passing.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,125 @@ | ||
# Script Annotations Artifact Passing | ||
|
||
|
||
|
||
This example will reuse the outputs volume across script steps. | ||
|
||
|
||
=== "Hera" | ||
|
||
```python linenums="1" | ||
from hera.workflows.volume import Volume | ||
|
||
try: | ||
from typing import Annotated # type: ignore | ||
except ImportError: | ||
from typing_extensions import Annotated # type: ignore | ||
|
||
|
||
from hera.shared import global_config | ||
from hera.workflows import ( | ||
Artifact, | ||
Parameter, | ||
Steps, | ||
Workflow, | ||
models as m, | ||
script, | ||
) | ||
|
||
global_config.experimental_features["script_annotations"] = True | ||
global_config.experimental_features["script_runner"] = True | ||
|
||
|
||
@script(constructor="runner") | ||
def output_artifact( | ||
a_number: Annotated[int, Parameter(name="a_number")], | ||
) -> Annotated[int, Artifact(name="successor_out")]: | ||
return a_number + 1 | ||
|
||
|
||
@script(constructor="runner") | ||
def use_artifact(successor_in: Annotated[int, Artifact(name="successor_in")]): | ||
print(successor_in) | ||
|
||
|
||
with Workflow( | ||
generate_name="annotations-artifact-passing", | ||
entrypoint="my-steps", | ||
) as w: | ||
with Steps(name="my-steps") as s: | ||
out = output_artifact(arguments={"a_number": 3}) | ||
use_artifact(arguments=[out.get_artifact("successor_out").as_name("successor_in")]) | ||
``` | ||
|
||
=== "YAML" | ||
|
||
```yaml linenums="1" | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: annotations-artifact-passing | ||
spec: | ||
entrypoint: my-steps | ||
templates: | ||
- name: my-steps | ||
steps: | ||
- - arguments: | ||
parameters: | ||
- name: a_number | ||
value: '3' | ||
name: output-artifact | ||
template: output-artifact | ||
- - arguments: | ||
artifacts: | ||
- from: '{{steps.output-artifact.outputs.artifacts.successor_out}}' | ||
name: successor_in | ||
name: use-artifact | ||
template: use-artifact | ||
- inputs: | ||
parameters: | ||
- name: a_number | ||
name: output-artifact | ||
outputs: | ||
artifacts: | ||
- name: successor_out | ||
path: /hera/outputs/artifacts/successor_out | ||
script: | ||
args: | ||
- -m | ||
- hera.workflows.runner | ||
- -e | ||
- examples.workflows.script_annotations_artifact_passing:output_artifact | ||
command: | ||
- python | ||
env: | ||
- name: hera__script_annotations | ||
value: '' | ||
- name: hera__outputs_directory | ||
value: /hera/outputs | ||
image: python:3.8 | ||
source: '{{inputs.parameters}}' | ||
volumeMounts: | ||
- mountPath: /hera/outputs | ||
name: hera-outputs-directory | ||
volumes: | ||
- emptyDir: {} | ||
name: hera-outputs-directory | ||
- inputs: | ||
artifacts: | ||
- name: successor_in | ||
name: use-artifact | ||
script: | ||
args: | ||
- -m | ||
- hera.workflows.runner | ||
- -e | ||
- examples.workflows.script_annotations_artifact_passing:use_artifact | ||
command: | ||
- python | ||
env: | ||
- name: hera__script_annotations | ||
value: '' | ||
image: python:3.8 | ||
source: '{{inputs.parameters}}' | ||
``` | ||
|
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
Oops, something went wrong.