Working with the `@task` decorators and wondering ...
# ask-the-community
r
Working with the
@task
decorators and wondering if there is a way to combine it with another decorator I am already using. Here is a simple toy example. Does anyone have any ideas why this doesn't work when uncommenting the flyte decorator? I get an error that it doesn't recognize the new argument (see below). Any help is appreciated!
Copy code
╭──────────────────────────── Traceback (most recent call last) ─────────────────────────────╮
│ /workspaces/workflow-orchestration-poc/test2.py:54 in <module>                             │
│                                                                                            │
│ ❱  54 print(fun1(b=3))  # 3 - 1 + 2 + 7 = 11                                               │
│                                                                                            │
│ /usr/local/lib/python3.9/site-packages/flytekit/core/base_task.py:304 in __call__          │
│                                                                                            │
│ ❱ 304 │   │   return flyte_entity_call_handler(self, *args, **kwargs)  # type: ignore      │
│                                                                                            │
│ /usr/local/lib/python3.9/site-packages/flytekit/core/promise.py:1086 in                    │
│ flyte_entity_call_handler                                                                  │
│                                                                                            │
│ ❱ 1086 │   │   │   raise ValueError(                                                       │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Received unexpected keyword argument 'b' in function 'fun1'
@jeev Any thoughts or do you know who might be able to help with this issue?
j
flytekit uses
inspect.signature(fun1)
under the hood. that returns
a
for some reason.
might be an issue with
functools.wraps
unfortunately i think its a constraint set by flytekit where it only works with nested functions that are wrapped, but wrapping basically throws off
inspect.signature
y
not sure about this particular use-case but here are a couple places to look https://github.com/unionai-oss/unionml/blob/main/unionml/utils.py
r
@jeev @Yee Thanks for following up! Let me dig into some of the references you cited. Seems like there is a good example there on how to workaround this.
148 Views