forked from flyteorg/flytekit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flytekit] Support attribute access on promises (flyteorg#1825)
Support attribute access on promises In the following workflow: - `basic_workflow` contains trivial examples to access output attributes - `failed_workflow` contains examples that causes exception (e.g. out of range) - `advanced_workflow` contains examples with more complex attribute access ```python from dataclasses import dataclass from typing import Dict, List, NamedTuple from dataclasses_json import dataclass_json from flytekit import WorkflowFailurePolicy, task, workflow @dataclass_json @DataClass class foo: a: str @task def t1() -> (List[str], Dict[str, str], foo): return ["a", "b"], {"a": "b"}, foo(a="b") @task def t2(a: str) -> str: print("a", a) return a @task def t3() -> (Dict[str, List[str]], List[Dict[str, str]], Dict[str, foo]): return {"a": ["b"]}, [{"a": "b"}], {"a": foo(a="b")} @task def t4(a: List[str]): print("a", a) @task def t5(a: Dict[str, str]): print("a", a) @workflow def basic_workflow(): l, d, f = t1() t2(a=l[0]) t2(a=d["a"]) t2(a=f.a) @workflow( # The workflow doesn't fail when one of the nodes fails but other nodes are still executable failure_policy=WorkflowFailurePolicy.FAIL_AFTER_EXECUTABLE_NODES_COMPLETE ) def failed_workflow(): # This workflow is supposed to fail due to exceptions l, d, f = t1() t2(a=l[100]) t2(a=d["b"]) t2(a=f.b) @workflow def advanced_workflow(): dl, ld, dd = t3() t2(a=dl["a"][0]) t2(a=ld[0]["a"]) t2(a=dd["a"].a) t4(a=dl["a"]) t5(a=ld[0]) ``` Signed-off-by: byhsu <[email protected]>
- Loading branch information
1 parent
8b2b975
commit 88fe671
Showing
8 changed files
with
284 additions
and
18 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
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.