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

Preserve stacktrace #2056

Merged
merged 1 commit into from
Dec 15, 2023
Merged

Preserve stacktrace #2056

merged 1 commit into from
Dec 15, 2023

Conversation

RRap0so
Copy link
Contributor

@RRap0so RRap0so commented Dec 15, 2023

TL;DR

Giving a try on printing Traceback when errors are raised in pyflyte

Note:

Only included printing tracebacks when it's not FlyteException or grpc 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

How did you fix the bug, make the feature etc. Link to any design docs etc

Tracking Issue

flyteorg/flyte#4248

Stacktrace error example


 Usage: pyflyte run workflow.py [OPTIONS] COMMAND [ARGS]...

 Run a [workflow|task] from workflow.py

╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help      Show this message and exit.                                                                                                                                                                         │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Failed with Unknown Exception <class 'NameError'> Reason: Error encountered while executing 'my_workflow':
  name 'thiswillfail' is not defined
Traceback:
  File "/Users/rafaelraposo/development/oss/flytekit/flytekit/clis/sdk_in_container/utils.py", line 138, in invoke
    return super().invoke(ctx)

  File "/Users/rafaelraposo/.pyenv/versions/3.8.18/lib/python3.8/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/Users/rafaelraposo/.pyenv/versions/3.8.18/lib/python3.8/site-packages/click/core.py", line 1686, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)

  File "/Users/rafaelraposo/.pyenv/versions/3.8.18/lib/python3.8/site-packages/click/core.py", line 943, in make_context
    self.parse_args(ctx, args)

  File "/Users/rafaelraposo/.pyenv/versions/3.8.18/lib/python3.8/site-packages/click/core.py", line 1641, in parse_args
    echo(ctx.get_help(), color=ctx.color)

  File "/Users/rafaelraposo/.pyenv/versions/3.8.18/lib/python3.8/site-packages/click/core.py", line 704, in get_help
    return self.command.get_help(self)

  File "/Users/rafaelraposo/.pyenv/versions/3.8.18/lib/python3.8/site-packages/click/core.py", line 1325, in get_help
    self.format_help(ctx, formatter)

  File "/Users/rafaelraposo/.pyenv/versions/3.8.18/lib/python3.8/site-packages/rich_click/rich_command.py", line 166, in format_help
    rich_format_help(self, ctx, formatter)

  File "/Users/rafaelraposo/.pyenv/versions/3.8.18/lib/python3.8/site-packages/rich_click/rich_click.py", line 653, in rich_format_help
    for command in obj.list_commands(ctx):

  File "/Users/rafaelraposo/development/oss/flytekit/flytekit/clis/sdk_in_container/run.py", line 652, in list_commands
    entities = get_entities_in_file(self._filename, self._should_delete)

  File "/Users/rafaelraposo/development/oss/flytekit/flytekit/clis/sdk_in_container/run.py", line 331, in get_entities_in_file
    importlib.import_module(module_name)

  File "/Users/rafaelraposo/.pyenv/versions/3.8.18/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)

  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import

  File "<frozen importlib._bootstrap>", line 991, in _find_and_load

  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked

  File "<frozen importlib._bootstrap_external>", line 843, in exec_module

  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

  File "/Users/rafaelraposo/development/oss/playground/flytekit-play/workflow.py", line 16, in <module>
    print(f"my_workflow output: {my_workflow(x=1, y=2)}")

  File "/Users/rafaelraposo/development/oss/flytekit/flytekit/core/workflow.py", line 274, in __call__
    self.compile()

  File "/Users/rafaelraposo/development/oss/flytekit/flytekit/core/workflow.py", line 674, in compile
    workflow_outputs = exception_scopes.user_entry_point(self._workflow_function)(**input_kwargs)

  File "/Users/rafaelraposo/development/oss/flytekit/flytekit/exceptions/scopes.py", line 203, in user_entry_point
    raise type(exc)(f"Error encountered while executing '{fn_name}':\n  {exc}") from exc

Error encountered while executing 'my_workflow':
  name 'thiswillfail' is not defined

A simple error were a variable is not defined.

Signed-off-by: Rafael Raposo <rafaelraposo@spotify.com>
Copy link

codecov bot commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (67470a3) 85.98% compared to head (6387090) 85.97%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2056      +/-   ##
==========================================
- Coverage   85.98%   85.97%   -0.01%     
==========================================
  Files         308      308              
  Lines       22997    22997              
  Branches     3474     3474              
==========================================
- Hits        19773    19771       -2     
- Misses       2620     2621       +1     
- Partials      604      605       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pingsutw pingsutw merged commit 2c71e4a into flyteorg:master Dec 15, 2023
74 of 75 checks passed
Copy link

welcome bot commented Dec 15, 2023

Congrats on merging your first pull request! 🎉

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