Skip to content
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

Clean up scopes and exception handling for new tasks #543

Merged
merged 10 commits into from
Jul 12, 2021
Merged

Conversation

wild-endeavor
Copy link
Contributor

@wild-endeavor wild-endeavor commented Jul 7, 2021

TL;DR

This cleans up the exception handling of new tasks and workflows. Currently there is no differentiation of recoverable or non-recoverable errors and all errors were system errors.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

  • Remove six from the scopes handling, no Python 2 anymore. This makes the scopes code slightly easier to read.
  • Add in kind into the ExecutionError model.
  • Add in origin into the ContainerError.
  • Use the user scope decorator where user-code is invoked (see https://github.com/flyteorg/flytekit/pull/540/files which this PR originally came from).
  • Add the system scope decorator to _dispatch_execute in the entrypoint.py.

Signed-off-by: wild-endeavor <[email protected]>
Signed-off-by: wild-endeavor <[email protected]>
Signed-off-by: wild-endeavor <[email protected]>
Signed-off-by: wild-endeavor <[email protected]>
Signed-off-by: wild-endeavor <[email protected]>
@wild-endeavor wild-endeavor changed the title Scopes six Clean up scopes usage of six Jul 7, 2021
@codecov
Copy link

codecov bot commented Jul 7, 2021

Codecov Report

Merging #543 (5588c00) into master (54576b3) will increase coverage by 0.07%.
The diff coverage is 97.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #543      +/-   ##
==========================================
+ Coverage   85.37%   85.44%   +0.07%     
==========================================
  Files         371      371              
  Lines       28722    28857     +135     
  Branches     2310     2310              
==========================================
+ Hits        24520    24658     +138     
+ Misses       3563     3561       -2     
+ Partials      639      638       -1     
Impacted Files Coverage Δ
flytekit/core/resources.py 100.00% <ø> (ø)
flytekit/core/schedule.py 89.28% <ø> (ø)
flytekit/engines/flyte/engine.py 70.78% <ø> (ø)
flytekit/core/map_task.py 80.64% <66.66%> (+0.21%) ⬆️
flytekit/common/exceptions/scopes.py 88.28% <83.33%> (+0.68%) ⬆️
tests/flytekit/unit/bin/test_python_entrypoint.py 98.01% <99.13%> (+0.87%) ⬆️
flytekit/core/python_function_task.py 85.10% <100.00%> (+0.16%) ⬆️
flytekit/core/workflow.py 88.79% <100.00%> (+0.03%) ⬆️
flytekit/models/core/errors.py 100.00% <100.00%> (ø)
flytekit/models/core/execution.py 64.08% <100.00%> (+2.14%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54576b3...5588c00. Read the comment docs.

Signed-off-by: wild-endeavor <[email protected]>
Signed-off-by: wild-endeavor <[email protected]>
Signed-off-by: wild-endeavor <[email protected]>
@wild-endeavor wild-endeavor changed the title Clean up scopes usage of six Clean up scopes and exception handling for new tasks Jul 9, 2021
Signed-off-by: wild-endeavor <[email protected]>
outputs = task_def.dispatch_execute(ctx, idl_input_literals)
# Decorate the dispatch execute function before calling it, this wraps all exceptions into one
# of the FlyteScopedExceptions
outputs = _scoped_exceptions.system_entry_point(task_def.dispatch_execute)(ctx, idl_input_literals)
Copy link
Contributor

@kumare3 kumare3 Jul 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg, this is weird?
why not a simple

try:
   outputs = ....
except :
  ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is effectively what the decorator does. The reason the decorator exists is mostly for two reasons:

  1. We enter and leave user-code in multiple places,
  2. The excpetions that we, flytekit authors, throw do not conform to any hierarchy easily distinguishable from potential user exceptions. After we complete [Housekeeping] [flytekit] Exception cleanup flyte#1033, and all flytekit exceptions have a base class that users will never use, we can get rid of these scoped exceptions and just use a few try catches to distinguish things.

I think it's preferable to get rid of these scoped exceptions actually, I just don't want to go through everything and update them right now. Maybe at 1.0

the last case in the nested try/catch below.

Decorator for wrapping functions that enter a system context. This should decorate every method that may invoke some
user code later on down the line. This will allow us to add differentiation between what is a user error and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user code later on down the line. This will allow us to add differentiation between what is a
WHY not at the point where the user code is called? i.e. only the last parent of the user code function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above.

Copy link
Contributor

@kumare3 kumare3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just couple stylistic comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants