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] Task fails if empty list is passed as argument #918

Closed
filippobrizzi opened this issue Apr 15, 2021 · 1 comment
Closed

[BUG] Task fails if empty list is passed as argument #918

filippobrizzi opened this issue Apr 15, 2021 · 1 comment
Labels
bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers

Comments

@filippobrizzi
Copy link

Describe the bug
Task fails to run if empty list is passed as argument.

Take this task

@flytekit.task
def test_empty_list(
    name: str,
    list_of_stuff: List[str],
) -> int:
    return len(list_of_stuff)

if executed on Flyte (not locally), by passing an empty list to list_of_stuff, it will fail with the following error:

[4/4] currentAttempt done. Last Error: USER::Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/flyte-workflows-104TnIye-py3.8/lib/python3.8/site-packages/flytekit/bin/entrypoint.py", line 94, in _dispatch_execute
    outputs = task_def.dispatch_execute(ctx, idl_input_literals)
  File "/root/.cache/pypoetry/virtualenvs/flyte-workflows-104TnIye-py3.8/lib/python3.8/site-packages/flytekit/core/base_task.py", line 402, in dispatch_execute
    native_inputs = TypeEngine.literal_map_to_kwargs(exec_ctx, input_literal_map, self.python_interface.inputs)
  File "/root/.cache/pypoetry/virtualenvs/flyte-workflows-104TnIye-py3.8/lib/python3.8/site-packages/flytekit/core/type_engine.py", line 297, in literal_map_to_kwargs
    return {k: TypeEngine.to_python_value(ctx, lm.literals[k], v) for k, v in python_types.items()}
  File "/root/.cache/pypoetry/virtualenvs/flyte-workflows-104TnIye-py3.8/lib/python3.8/site-packages/flytekit/core/type_engine.py", line 297, in <dictcomp>
    return {k: TypeEngine.to_python_value(ctx, lm.literals[k], v) for k, v in python_types.items()}
  File "/root/.cache/pypoetry/virtualenvs/flyte-workflows-104TnIye-py3.8/lib/python3.8/site-packages/flytekit/core/type_engine.py", line 275, in to_python_value
    return transformer.to_python_value(ctx, lv, expected_python_type)
  File "/root/.cache/pypoetry/virtualenvs/flyte-workflows-104TnIye-py3.8/lib/python3.8/site-packages/flytekit/core/type_engine.py", line 342, in to_python_value
    return [TypeEngine.to_python_value(ctx, x, st) for x in lv.collection.literals]
AttributeError: 'NoneType' object has no attribute 'literals'

Expected behavior
The task should return 0

Screenshots
image

@filippobrizzi filippobrizzi added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Apr 15, 2021
@fediazgon
Copy link

In the latest version is working with empty lists but not with empty dictionaries. I will take a look.

eapolinario added a commit to eapolinario/flyte that referenced this issue Dec 20, 2022
Signed-off-by: Eduardo Apolinario <[email protected]>

Signed-off-by: Eduardo Apolinario <[email protected]>
Co-authored-by: Eduardo Apolinario <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers
Projects
None yet
Development

No branches or pull requests

2 participants