flytekit icon indicating copy to clipboard operation
flytekit copied to clipboard

Improve error when missing type annotations in task/workflow

Open pingsutw opened this issue 1 year ago • 1 comments

Tracking issue

NA

Why are the changes needed?

Error message is cryptic

What changes were proposed in this pull request?

  • Use the rich panel to print the source code
  • syntax highlight
  • Point out the error at the specific line
  • Remove unwanted traceback frames, such as click, rich.

How was this patch tested?

import os

from click.testing import CliRunner

from flytekit import task, workflow, ImageSpec
from flytekit.clis.sdk_in_container import pyflyte

default = ["pandas", "mypy"]

image = ImageSpec(registry="pingsutw", packages=[*default])


@task(container_image=image)
def t1() -> int:
    return 3 + 2


@task(container_image=os.getenv("IMAGE"))
def t2(a: int) -> int:
    return a + 3


@workflow(
    on_failure=t2,
)
def wf(a=int):
    t1()
    t2(a=a)


if __name__ == '__main__':
    runner = CliRunner()
    result = runner.invoke(
        pyflyte.main,
        [
            "-vv",
            "register",
            "/Users/kevin/git/flytekit/flyte-example/improve_image_spec.py",
        ]
    )
    print(result.stdout)

Screenshots

Before:

Screenshot 2024-07-02 at 11 24 03 AM

After: Screenshot 2024-07-02 at 1 11 31 PM Screenshot 2024-07-02 at 1 11 46 PM Screenshot 2024-07-02 at 1 29 43 PM

Check all the applicable boxes

  • [ ] I updated the documentation accordingly.
  • [ ] All new and existing tests passed.
  • [ ] All commits are signed-off.

Related PRs

Docs link

pingsutw avatar Jul 02 '24 20:07 pingsutw

This looks so cool.

troychiu avatar Jul 03 '24 22:07 troychiu

Codecov Report

Attention: Patch coverage is 67.64706% with 11 lines in your changes missing coverage. Please review.

Project coverage is 72.53%. Comparing base (bd01c3d) to head (8fe9d9f). Report is 18 commits behind head on master.

Files Patch % Lines
flytekit/exceptions/utils.py 62.06% 11 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2549      +/-   ##
==========================================
+ Coverage   71.98%   72.53%   +0.54%     
==========================================
  Files         183      184       +1     
  Lines       18712    18762      +50     
  Branches     3691     3701      +10     
==========================================
+ Hits        13470    13609     +139     
+ Misses       4591     4499      -92     
- Partials      651      654       +3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 09 '24 01:07 codecov[bot]