From a1f6bca25d778c6032645c301af160c2887f506b Mon Sep 17 00:00:00 2001 From: Elliot Gunton Date: Fri, 21 Jul 2023 08:51:26 +0000 Subject: [PATCH] Fix artifact example Signed-off-by: Elliot Gunton --- docs/examples/workflows/artifact.md | 36 ++++++++++++++--------------- examples/workflows/artifact.py | 12 +++++----- examples/workflows/artifact.yaml | 24 +++++++++---------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/docs/examples/workflows/artifact.md b/docs/examples/workflows/artifact.md index 5f985c2b4..60ac490ed 100644 --- a/docs/examples/workflows/artifact.md +++ b/docs/examples/workflows/artifact.md @@ -10,25 +10,25 @@ task, consumer, takes this artifact, places it at its own `/file` path, and prin === "Hera" ```python linenums="1" - from hera.workflows import DAG, Artifact, Workflow, script + from hera.workflows import DAG, Artifact, NoneArchiveStrategy, Workflow, script - @script(outputs=Artifact(name="test", path="/file")) + @script(outputs=Artifact(name="out-art", path="/tmp/file", archive=NoneArchiveStrategy())) def writer(): - with open("/file", "w+") as f: + with open("/tmp/file", "w+") as f: f.write("Hello, world!") - @script(inputs=Artifact(name="test", path="/file")) + @script(inputs=Artifact(name="in-art", path="/tmp/file")) def consumer(): - with open("/file", "r") as f: + with open("/tmp/file", "r") as f: print(f.readlines()) # prints `Hello, world!` to `stdout` with Workflow(generate_name="artifact-", entrypoint="d") as w: with DAG(name="d"): w_ = writer() - c = consumer(arguments={"test": w_.get_artifact("test")}) + c = consumer(arguments=w_.get_artifact("out-art").as_name("in-art")) w_ >> c ``` @@ -47,12 +47,10 @@ task, consumer, takes this artifact, places it at its own `/file` path, and prin - name: writer template: writer - arguments: - parameters: - - name: test - value: '{"name": "test", "archive": null, "archive_logs": null, "artifact_gc": - null, "deleted": null, "from_": "{{tasks.writer.outputs.artifacts.test}}", - "from_expression": null, "global_name": null, "mode": null, "path": - "/file", "recurse_mode": null, "sub_path": null}' + artifacts: + - from: '{{tasks.writer.outputs.artifacts.out-art}}' + name: in-art + path: /tmp/file depends: writer name: consumer template: consumer @@ -60,24 +58,26 @@ task, consumer, takes this artifact, places it at its own `/file` path, and prin - name: writer outputs: artifacts: - - name: test - path: /file + - archive: + none: {} + name: out-art + path: /tmp/file script: command: - python image: python:3.8 - source: "import os\nimport sys\nsys.path.append(os.getcwd())\nwith open('/file',\ + source: "import os\nimport sys\nsys.path.append(os.getcwd())\nwith open('/tmp/file',\ \ 'w+') as f:\n f.write('Hello, world!')" - inputs: artifacts: - - name: test - path: /file + - name: in-art + path: /tmp/file name: consumer script: command: - python image: python:3.8 - source: "import os\nimport sys\nsys.path.append(os.getcwd())\nwith open('/file',\ + source: "import os\nimport sys\nsys.path.append(os.getcwd())\nwith open('/tmp/file',\ \ 'r') as f:\n print(f.readlines())" ``` diff --git a/examples/workflows/artifact.py b/examples/workflows/artifact.py index 8fc8cc052..1a39ef925 100644 --- a/examples/workflows/artifact.py +++ b/examples/workflows/artifact.py @@ -3,23 +3,23 @@ task, consumer, takes this artifact, places it at its own `/file` path, and print out the content. """ -from hera.workflows import DAG, Artifact, Workflow, script +from hera.workflows import DAG, Artifact, NoneArchiveStrategy, Workflow, script -@script(outputs=Artifact(name="test", path="/file")) +@script(outputs=Artifact(name="out-art", path="/tmp/file", archive=NoneArchiveStrategy())) def writer(): - with open("/file", "w+") as f: + with open("/tmp/file", "w+") as f: f.write("Hello, world!") -@script(inputs=Artifact(name="test", path="/file")) +@script(inputs=Artifact(name="in-art", path="/tmp/file")) def consumer(): - with open("/file", "r") as f: + with open("/tmp/file", "r") as f: print(f.readlines()) # prints `Hello, world!` to `stdout` with Workflow(generate_name="artifact-", entrypoint="d") as w: with DAG(name="d"): w_ = writer() - c = consumer(arguments={"test": w_.get_artifact("test")}) + c = consumer(arguments=w_.get_artifact("out-art").as_name("in-art")) w_ >> c diff --git a/examples/workflows/artifact.yaml b/examples/workflows/artifact.yaml index 866368d46..7b2dc1d5b 100644 --- a/examples/workflows/artifact.yaml +++ b/examples/workflows/artifact.yaml @@ -10,12 +10,10 @@ spec: - name: writer template: writer - arguments: - parameters: - - name: test - value: '{"name": "test", "archive": null, "archive_logs": null, "artifact_gc": - null, "deleted": null, "from_": "{{tasks.writer.outputs.artifacts.test}}", - "from_expression": null, "global_name": null, "mode": null, "path": - "/file", "recurse_mode": null, "sub_path": null}' + artifacts: + - from: '{{tasks.writer.outputs.artifacts.out-art}}' + name: in-art + path: /tmp/file depends: writer name: consumer template: consumer @@ -23,22 +21,24 @@ spec: - name: writer outputs: artifacts: - - name: test - path: /file + - archive: + none: {} + name: out-art + path: /tmp/file script: command: - python image: python:3.8 - source: "import os\nimport sys\nsys.path.append(os.getcwd())\nwith open('/file',\ + source: "import os\nimport sys\nsys.path.append(os.getcwd())\nwith open('/tmp/file',\ \ 'w+') as f:\n f.write('Hello, world!')" - inputs: artifacts: - - name: test - path: /file + - name: in-art + path: /tmp/file name: consumer script: command: - python image: python:3.8 - source: "import os\nimport sys\nsys.path.append(os.getcwd())\nwith open('/file',\ + source: "import os\nimport sys\nsys.path.append(os.getcwd())\nwith open('/tmp/file',\ \ 'r') as f:\n print(f.readlines())"