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] Type transformer fails on local runs when list is composed within the workflow definition #3342

Closed
2 tasks done
bstadlbauer opened this issue Feb 14, 2023 · 2 comments
Closed
2 tasks done
Assignees
Labels
bug Something isn't working flytekit FlyteKit Python related issue good first issue Good for newcomers

Comments

@bstadlbauer
Copy link
Member

Describe the bug

The following example serializes, registers and runs fine remotely. However, when trying to run it locally it fails:

from typing import List

from flytekit import task, workflow


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


@task
def my_task_2(integers: List[int]) -> int:
    return sum(integers)


@workflow
def subworkflow(integers: List[int]) -> int:
    return my_task_2(integers=integers)


@workflow
def my_workflow() -> int:
    result = my_task_1()
    return subworkflow(integers=[result])


if __name__ == "__main__":
    print(f"Running {__file__} main...")
    print(my_workflow())

with:

Traceback (most recent call last):
  File "/Users/bstadlbauer/workspace/pachama/protocol-baseline/flyte/baseline/demo.py", line 29, in <module>
    print(my_workflow())
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/workflow.py", line 258, in __call__
    return flyte_entity_call_handler(self, *args, **input_kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/promise.py", line 1050, in flyte_entity_call_handler
    result = cast(LocallyExecutable, entity).local_execute(child_ctx, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/workflow.py", line 273, in local_execute
    function_outputs = self.execute(**kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/workflow.py", line 708, in execute
    return exception_scopes.user_entry_point(self._workflow_function)(**kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/exceptions/scopes.py", line 198, in user_entry_point
    return wrapped(*args, **kwargs)
  File "/Users/bstadlbauer/workspace/pachama/protocol-baseline/flyte/baseline/demo.py", line 24, in my_workflow
    return subworkflow(integers=[result])
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/workflow.py", line 258, in __call__
    return flyte_entity_call_handler(self, *args, **input_kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/promise.py", line 1042, in flyte_entity_call_handler
    return cast(LocallyExecutable, entity).local_execute(ctx, **kwargs)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/workflow.py", line 269, in local_execute
    kwargs[k] = Promise(var=k, val=TypeEngine.to_literal(ctx, v, t, self.interface.inputs[k].type))
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/type_engine.py", line 767, in to_literal
    lv = transformer.to_literal(ctx, python_val, python_type, expected)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/type_engine.py", line 924, in to_literal
    lit_list = [TypeEngine.to_literal(ctx, x, t, expected.collection_type) for x in python_val]  # type: ignore
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/type_engine.py", line 924, in <listcomp>
    lit_list = [TypeEngine.to_literal(ctx, x, t, expected.collection_type) for x in python_val]  # type: ignore
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/type_engine.py", line 751, in to_literal
    transformer.assert_type(python_type, python_val)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/baseline-dev/lib/python3.8/site-packages/flytekit/core/type_engine.py", line 90, in assert_type
    raise TypeTransformerFailedError(f"Type of Val '{v}' is not an instance of {t}")
flytekit.core.type_engine.TypeTransformerFailedError: Type of Val 'Resolved(o0=scalar {
  primitive {
    integer: 1
  }
}
)' is not an instance of <class 'int'>

Expected behavior

The workflow should succeed locally.

Additional context to reproduce

No response

Screenshots

No response

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

  • Yes

Have you read the Code of Conduct?

  • Yes
@bstadlbauer bstadlbauer added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Feb 14, 2023
@pingsutw pingsutw added good first issue Good for newcomers flytekit FlyteKit Python related issue and removed untriaged This issues has not yet been looked at by the Maintainers labels Dec 22, 2023
@troychiu troychiu self-assigned this Dec 23, 2023
@troychiu
Copy link
Member

Hi @bstadlbauer , when I tried to reproduce this issue, it ran well. Could you try to rerun this workflow on your side to see if this issue has been resolved?

@troychiu
Copy link
Member

The workflow runs well in master, so I will close it. If this issue is still there, we can reopen it again.

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 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants