-
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.
Document incremental migration option
Signed-off-by: Alice Purcell <[email protected]>
- Loading branch information
1 parent
fd52a83
commit d9af1f5
Showing
3 changed files
with
118 additions
and
0 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
53 changes: 53 additions & 0 deletions
53
examples/workflows/experimental/incremental-workflow-migration.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,53 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
name: my-template | ||
spec: | ||
templates: | ||
- name: steps | ||
steps: | ||
- - name: double | ||
template: double | ||
- - arguments: | ||
parameters: | ||
- name: value | ||
value: '{{steps.double.outputs.parameters.value}}' | ||
name: print-value | ||
template: print-value | ||
- inputs: | ||
parameters: | ||
- name: value | ||
name: double | ||
outputs: | ||
parameters: | ||
- name: value | ||
script: | ||
command: | ||
- python | ||
image: python:3.9 | ||
source: |- | ||
import os | ||
import sys | ||
sys.path.append(os.getcwd()) | ||
import json | ||
try: value = json.loads(r'''{{inputs.parameters.value}}''') | ||
except: value = r'''{{inputs.parameters.value}}''' | ||
return MyOutput(value=input.value * 2) | ||
- inputs: | ||
parameters: | ||
- name: value | ||
name: print-value | ||
script: | ||
command: | ||
- python | ||
image: python:3.9 | ||
source: |- | ||
import os | ||
import sys | ||
sys.path.append(os.getcwd()) | ||
import json | ||
try: value = json.loads(r'''{{inputs.parameters.value}}''') | ||
except: value = r'''{{inputs.parameters.value}}''' | ||
print('Value was', value) |
28 changes: 28 additions & 0 deletions
28
examples/workflows/experimental/incremental_workflow_migration.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,28 @@ | ||
from hera.shared import global_config | ||
from hera.workflows import Input, Output, Steps, Workflow, script | ||
|
||
global_config.experimental_features["context_manager_pydantic_io"] = True | ||
|
||
class MyInput(Input): | ||
value: int | ||
|
||
class MyOutput(Output): | ||
value: int | ||
|
||
# Function migrated to Pydantic I/O | ||
@script() | ||
def double(input: MyInput) -> MyOutput: | ||
return MyOutput(value = input.value * 2) | ||
|
||
# Not yet migrated to Pydantic I/O | ||
@script() | ||
def print_value(value: int) -> None: | ||
print("Value was", value) | ||
|
||
# Not yet migrated to decorator syntax | ||
with Workflow(name="my-template") as w: | ||
with Steps(name="steps"): | ||
# Can now pass Pydantic types to/from functions | ||
first_step = double(Input(value=5)) | ||
# Results can be passed into non-migrated functions | ||
print_value(arguments={"value": first_step.value}) |