-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support failure node #840
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
823c528
wip
kumare3 0508159
wip
kumare3 703b681
updated
kumare3 1a04695
Failure node added
kumare3 72d2e84
update
kumare3 15f5761
Merge branch 'master' into error-handler
kumare3 052768f
merged master
pingsutw 69163c3
Merge branch 'master' into error-handler
kumare3 789f295
updated failed node
kumare3 1c3b6c5
error transformer
pingsutw 12356aa
nit
pingsutw 2bfed27
updated
kumare3 325bdf2
updated node id
kumare3 5de495b
wip
pingsutw c71fcf2
wip
pingsutw 5a41510
Add FlyteError
pingsutw 683964d
merged master
pingsutw c9b60dd
update tests
pingsutw c489c64
lint
pingsutw c83f625
debug
pingsutw b27f3b7
Merged master
pingsutw 2582a8b
Merge branch 'master' of github.com:flyteorg/flytekit into error-handler
pingsutw 38a67bf
Merge branch 'master' of github.com:flyteorg/flytekit into error-handler
pingsutw 0e5b5dc
Merge branch 'master' of github.com:flyteorg/flytekit into error-handler
pingsutw c2c1feb
Serialize failure subworkflow node
pingsutw 4559823
Fix lint
pingsutw 7384315
fix tests
pingsutw 2cb4530
fix tests
pingsutw 3a43dc6
nit
pingsutw a6b9da5
lint
pingsutw 8c075ef
merged master
pingsutw f6fa9b3
nit
pingsutw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Flytekit Error Type | ||
========================================================== | ||
.. currentmodule:: flytekit.types.error | ||
|
||
.. autosummary:: | ||
:toctree: generated/ | ||
|
||
FlyteError | ||
""" | ||
|
||
from .error import FlyteError |
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,58 @@ | ||
from dataclasses import dataclass | ||
from typing import Type, TypeVar | ||
|
||
from mashumaro.mixins.json import DataClassJSONMixin | ||
|
||
from flytekit.core.context_manager import FlyteContext | ||
from flytekit.core.type_engine import TypeEngine, TypeTransformer, TypeTransformerFailedError | ||
from flytekit.models import types as _type_models | ||
from flytekit.models.literals import Error, Literal, Scalar | ||
from flytekit.models.types import LiteralType | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
@dataclass | ||
class FlyteError(DataClassJSONMixin): | ||
""" | ||
Special Task type that will be used in the failure node. Propeller will pass this error to failure task, so users | ||
have to add an input with this type to the failure task. | ||
""" | ||
|
||
message: str | ||
failed_node_id: str | ||
|
||
|
||
class ErrorTransformer(TypeTransformer[FlyteError]): | ||
""" | ||
Enables converting a python type FlyteError to LiteralType.Error | ||
""" | ||
|
||
def __init__(self): | ||
super().__init__(name="FlyteError", t=FlyteError) | ||
|
||
def get_literal_type(self, t: Type[T]) -> LiteralType: | ||
return LiteralType(simple=_type_models.SimpleType.ERROR) | ||
|
||
def to_literal( | ||
self, ctx: FlyteContext, python_val: FlyteError, python_type: Type[T], expected: LiteralType | ||
) -> Literal: | ||
if type(python_val) != FlyteError: | ||
raise TypeTransformerFailedError( | ||
f"Expected value of type {FlyteError} but got '{python_val}' of type {type(python_val)}" | ||
) | ||
return Literal(scalar=Scalar(error=Error(message=python_val.message, failed_node_id=python_val.failed_node_id))) | ||
|
||
def to_python_value(self, ctx: FlyteContext, lv: Literal, expected_python_type: Type[T]) -> T: | ||
if not (lv and lv.scalar and lv.scalar.error is not None): | ||
raise TypeTransformerFailedError("Can only convert a generic literal to FlyteError") | ||
return FlyteError(message=lv.scalar.error.message, failed_node_id=lv.scalar.error.failed_node_id) | ||
|
||
def guess_python_type(self, literal_type: LiteralType) -> Type[FlyteError]: | ||
if literal_type.simple and literal_type.simple == _type_models.SimpleType.ERROR: | ||
return FlyteError | ||
|
||
raise ValueError(f"Transformer {self} cannot reverse {literal_type}") | ||
|
||
|
||
TypeEngine.register(ErrorTransformer()) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i do not think we need this right, though lets keep it