Marwan Sarieddine
02/02/2021, 11:25 PM_validate_run_signature
tries to unwrap the function provided to get to the underlying function but it does so by accessing ___wrapped___
instead of using something like`inspect.unwrap` that would traverse the ___wrapped___
chain …def simple_dec(func):
@functools.wraps(func)
def wrapped(*args, **kwargs):
return func(*args, **kwargs)
return wrapped
would work fine when chained with a task decorator - i.e.
@task
@simple_dec
def test(a: int, b:int) -> int:
return a + b
@task
@simple_dec
@simple_dec
def test(a: int, b:int) -> int:
return a + b
Traceback (most recent call last):
File "./_tmp/r.py", line 16, in <module>
def test(a: int, b: int) -> int:
File "/Users/marwansarieddine/.pyenv/versions/3.8.5/envs/pyinfima/lib/python3.8/site-packages/prefect/utilities/tasks.py", line 408, in task
return prefect.tasks.core.function.FunctionTask(fn=fn, **task_init_kwargs)
File "/Users/marwansarieddine/.pyenv/versions/3.8.5/envs/pyinfima/lib/python3.8/site-packages/prefect/core/task.py", line 158, in init
old_init(self, *args, **kwargs)
File "/Users/marwansarieddine/.pyenv/versions/3.8.5/envs/pyinfima/lib/python3.8/site-packages/prefect/tasks/core/function.py", line 60, in __init__
prefect.core.task._validate_run_signature(fn) # type: ignore
File "/Users/marwansarieddine/.pyenv/versions/3.8.5/envs/pyinfima/lib/python3.8/site-packages/prefect/core/task.py", line 66, in _validate_run_signature
raise ValueError(
ValueError: Tasks with variable positional arguments (*args) are not supported, because all Prefect arguments are stored as keywords. As a workaround, consider modifying the run() method to accept **kwargs and feeding the values to *args.
Chris White