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

Improve error message in ListTransformer when not passing a list #1882

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

fg91
Copy link
Member

@fg91 fg91 commented Oct 9, 2023

TL;DR

Improve error message in ListTransformer in a way that would have saved us time debugging a failing workflow.

Type

Neither of the following, just adding a meaningful error message.

  • 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 workflow ...

from flytekit import task, workflow

@task
def foo() -> int:
    return 1

@task
def bar(inp: list[int]):
    print(inp)

@workflow
def wf():
    bar(inp=foo())


if __name__ == "__main__":
    wf()

... fails with:

Traceback (most recent call last):
  File ".../test.py", line 17, in <module>
    wf()
  File ".../flytekit/flytekit/core/workflow.py", line 279, in __call__
    raise exc
  File ".../flytekit/flytekit/core/workflow.py", line 276, in __call__
    return flyte_entity_call_handler(self, *args, **input_kwargs)
  File ".../flytekit/flytekit/core/promise.py", line 1051, in flyte_entity_call_handler
    result = cast(LocallyExecutable, entity).local_execute(child_ctx, **kwargs)
  File ".../flytekit/flytekit/core/workflow.py", line 298, in local_execute
    function_outputs = self.execute(**kwargs_literals)
  File ".../flytekit/flytekit/core/workflow.py", line 746, in execute
    return exception_scopes.user_entry_point(self._workflow_function)(**kwargs)
  File ".../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
flytekit.core.type_engine.TypeTransformerFailedError: Encountered error while executing workflow 'wf':
  Error encountered while executing 'wf':
  Failed to convert inputs of task 'test.bar':
  Error converting input 'inp' at position 0:  # <- No meaningful error comes after this colon

In this minimal example, the error is quickly apparent but one of our engineers struggled to find the issue in a large training workflow.
A hint that a list/collection is expected but not provided (as here in the respective to_literal method) would have greatly simplified the search:

flytekit.core.type_engine.TypeTransformerFailedError: Encountered error while executing workflow 'wf':
  Error encountered while executing 'wf':
  Failed to convert inputs of task 'test.bar':
  Error converting input 'inp' at position 0:
  The expected python type is 'list[int]' but the received Flyte literal value is not a collection (Flyte's representation of Python lists).

Tracking Issue

NA

Follow-up issue

NA

@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (1f0d120) 51.27% compared to head (b1c0de7) 95.12%.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1882       +/-   ##
===========================================
+ Coverage   51.27%   95.12%   +43.84%     
===========================================
  Files         255      131      -124     
  Lines       20283     5984    -14299     
  Branches     3357        0     -3357     
===========================================
- Hits        10400     5692     -4708     
+ Misses       9720      292     -9428     
+ Partials      163        0      -163     

see 208 files with indirect coverage changes

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

@pingsutw pingsutw merged commit 3afcbb4 into master Oct 10, 2023
68 checks passed
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