Rahul Mehta
01/17/2023, 6:27 AMSamhita Alla
Rahul Mehta
01/17/2023, 1:53 PMYee
Rahul Mehta
01/17/2023, 5:36 PM@task
& @task()
are both valid usages is where the trickiness comes in I believe. If we'd be willing to relax that and enforce @task()
as the correct usage, I think this is achievable
Also not sure about the best way to wire the `P.args`/`P.kwargs` stuff into PythonFunctionTask
(PythonFunctionTask
itself doesn't even appear to be callable/I think there are some other things that aren't quite right in the typing)from flytekit.core.task import task
from flytekit.core.workflow import workflow
@task()
def test_task(a: int, b: float) -> float:
return a + b
@workflow()
def test_wf() -> float:
return test_task(a=1.0, b="foo")
Eduardo Apolinario (eapolinario)
01/17/2023, 6:35 PM@task
, etc), but it's a start: https://github.com/flyteorg/flytekit/pull/1372/.
I double-checked that this is supported in typing_extensions
(which also works in python 3.7 as per https://github.com/python/typing_extensions/commit/b697a12f2793655db99dde660bb47458ad36aa55), although I haven't pushed a commit that imports from there instead of typing
.Rahul Mehta
01/17/2023, 6:37 PMEduardo Apolinario (eapolinario)
01/17/2023, 6:58 PM❯ mypy workflows/example2.py
workflows/example2.py:5: error: Missing positional argument "_task_function" in call to "task" [call-arg]
workflows/example2.py:5: error: Argument 1 has incompatible type "Callable[[int, float], float]"; expected <nothing> [arg-type]
Found 2 errors in 1 file (checked 1 source file)
Rahul Mehta
01/17/2023, 6:59 PMEduardo Apolinario (eapolinario)
01/17/2023, 7:01 PMRahul Mehta
01/17/2023, 7:01 PMYee
Rahul Mehta
01/17/2023, 7:06 PMYee
Rahul Mehta
01/17/2023, 7:43 PMParamSpec
and add that to the discussion on @Eduardo Apolinario (eapolinario)’s PR. We're internally pushing to improve a lot of our typing (and where possible upstream improvements to 3rd-party libs) since it's better for the iteration loop to be able to catch these obvious issues at build time