<#1582 Feature/3506: Improve Type Conversion error...
# flyte-github
a
#1582 Feature/3506: Improve Type Conversion errors, use rich to prettify error messages Pull request opened by cosmicBboy TL;DR This PR makes input/output type conversion error messages a lot more useful by providing more context to the user. 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 This PR makes input/output type conversion error messages a lot more actionable by: • providing context on what workflow and task was executing when the error was raised • providing context on the input name / output name and positional index that raised the error • modifying the string representation of flyte literal types to be more explicit • pretty-printing errors using
rich
Appearance Changes Given the following script:
Copy code
import random
from flytekit import task, workflow

@task
def add_rand(n: int) -> float:
    return float(n + random.randint(-1000, 1000))

@task
def bad_types(a: int) -> float:
    return str(a)

@workflow
def wf(a: int):
    bad_types(a=add_rand(n=a))

@workflow
def wf_bad_output(a: int) -> int:
    return good_types(a=add_rand(n=a))
Running
wf(a=1)
(incorrect type in intermediate task)
Before:

image

After:

image

Running
wf(a=1.0)
(incorrect input type to workflow)
Before:

image

After:

image

Running
wf_bad_output(a=1)
(incorrect workflow output)
Before:

image

After:

image

Running
bad_types(a=1)
(incorrect task output)
Before:

image

After:

image

Running
bad_types(a=1)
(incorrect task output)
Before:

image

After:

image

Running
bad_types(a=str(1))
(incorrect task input)
Before:

image

After:

image

Logging Json format:

image

Text format:

image

Tracking Issue flyteorg/flyte#3506 Follow-up issue NA flyteorg/flytekit All checks have passed 30/30 successful checks