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

[BUG] TypeTransformerFailedError when using empty dict #5804

Closed
2 tasks done
linhai-fn opened this issue Oct 3, 2024 · 3 comments
Closed
2 tasks done

[BUG] TypeTransformerFailedError when using empty dict #5804

linhai-fn opened this issue Oct 3, 2024 · 3 comments
Assignees
Labels
bug Something isn't working flytekit FlyteKit Python related issue

Comments

@linhai-fn
Copy link

Describe the bug

Before flyteorg/flytekit#2743 introduced in 1.13.6, the workflow/task like below can handle empty dict.

from flytekit import task, workflow

@task
def print_dict(x: dict[str, str]) -> None:
    for k, v in x.items():
        print(f"{k}: {v}")

@workflow
def print_workflow() -> None:
    print_dict(x={})


if __name__ == "__main__":
    print(f"Running print_workflow() {print_workflow()}")

With >=1.13.6, the flyte will throw a TypeTransformerFailedError error:

% pyflyte run workflow.py print_workflow
Running Execution on local.
TypeTransformerFailedError: Failed to convert inputs of task 'workflow.print_dict':
  Failed argument 'x': Not all values in '{}' are of type <class 'str'>

Expected behavior

The workflow/task should be able to accept empty dict like they used to in <1.13.6. Unless this breaking change is intentional?

Additional context to reproduce

The cause of the error is due to this part of the code. Similar error will raise for empty list/tuple/set due to similar logic.

Screenshots

No response

Are you sure this issue hasn't been raised already?

  • Yes

Have you read the Code of Conduct?

  • Yes
@linhai-fn linhai-fn added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Oct 3, 2024
Copy link

welcome bot commented Oct 3, 2024

Thank you for opening your first issue here! 🛠

@charliemoriarty
Copy link

We are also encountering this issue, and it has broken several of our tasks and unit tests. As a temporary workaround, we've switched to using the deprecated typing.List and typing.Dict types for lists/dicts that need support for being empty, but this feels quite messy..

@wild-endeavor wild-endeavor added the flytekit FlyteKit Python related issue label Oct 10, 2024
@wild-endeavor wild-endeavor self-assigned this Oct 10, 2024
@wild-endeavor wild-endeavor removed the untriaged This issues has not yet been looked at by the Maintainers label Oct 10, 2024
@wild-endeavor
Copy link
Contributor

will be in v1.13.9 and later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working flytekit FlyteKit Python related issue
Projects
Status: Done
Development

No branches or pull requests

3 participants