Skip to content

Commit

Permalink
Fix script_annotations_artifact_passing example
Browse files Browse the repository at this point in the history
Signed-off-by: Elliot Gunton <egunton@bloomberg.net>
  • Loading branch information
elliotgunton committed Sep 27, 2023
1 parent 013445e commit b6d25d0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions docs/examples/workflows/script_annotations_artifact_passing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ 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 pathlib import Path
from hera.shared import global_config
from hera.workflows import (
Artifact,
ArtifactLoader,
Parameter,
Steps,
Workflow,
models as m,
script,
)

Expand All @@ -38,8 +37,14 @@ This example will reuse the outputs volume across script steps.


@script(constructor="runner")
def use_artifact(successor_in: Annotated[int, Artifact(name="successor_in")]):
def use_artifact(
successor_in: Annotated[
int,
Artifact(name="successor_in", path="/my-path", loader=ArtifactLoader.json),
]
):
print(successor_in)
print(Path("/my-path").read_text()) # if you still need the actual path, it is still mounted where you specify


with Workflow(
Expand Down Expand Up @@ -101,6 +106,7 @@ This example will reuse the outputs volume across script steps.
- inputs:
artifacts:
- name: successor_in
path: /my-path
name: use-artifact
script:
args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ spec:
- inputs:
artifacts:
- name: successor_in
path: /my-path
name: use-artifact
script:
args:
Expand Down
13 changes: 9 additions & 4 deletions examples/workflows/script_annotations_artifact_passing.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
"""This example will reuse the outputs volume across script steps."""


from hera.workflows.volume import Volume

try:
from typing import Annotated # type: ignore
except ImportError:
from typing_extensions import Annotated # type: ignore


from pathlib import Path
from hera.shared import global_config
from hera.workflows import (
Artifact,
ArtifactLoader,
Parameter,
Steps,
Workflow,
models as m,
script,
)

Expand All @@ -31,8 +30,14 @@ def output_artifact(


@script(constructor="runner")
def use_artifact(successor_in: Annotated[int, Artifact(name="successor_in")]):
def use_artifact(
successor_in: Annotated[
int,
Artifact(name="successor_in", path="/my-path", loader=ArtifactLoader.json),
]
):
print(successor_in)
print(Path("/my-path").read_text()) # if you still need the actual path, it is still mounted where you specify


with Workflow(
Expand Down

0 comments on commit b6d25d0

Please sign in to comment.