Rahul Mehta
11/08/2022, 2:41 PMKetan (kumare3)
11/08/2022, 3:03 PMRahul Mehta
11/08/2022, 11:50 PMEduardo Apolinario (eapolinario)
11/10/2022, 6:58 PMreveal_type
say?Rahul Mehta
11/10/2022, 7:13 PMreveal_type
on which object/function?@flytekit.task()
def compute_stats(data: List[int]) -> Result:
"""Compute summary stats"""
return Result(
mean=statistics.mean(data),
median=statistics.median(data),
stdev=statistics.stdev(data),
)
@flytekit.task()
def generate_data(n_elements: int, random_min: int, random_max: int) -> List[int]:
"""Generate dummy data"""
return [random.randint(random_min, random_max) for _ in range(n_elements)]
@flytekit.workflow()
def simple_workflow(n_elements: float = 100, random_min: int = 0, random_max: int = 10) -> Result:
"""Generate random data & compute basic summary statistics"""
data = generate_data(n_elements=n_elements, random_min=random_min, random_max=random_max)
return compute_stats(data=data)
Where the n_elements
arg in generate_data
expects an int
, but we're passing in a float
. Mypy passes on this, and fails when I remove the `@task`/`@workflow` decorators@task
or @dynamic
-- type errors inside task implementations are caught as expectedEduardo Apolinario (eapolinario)
11/10/2022, 7:43 PMimport typing
from typing_extensions import reveal_type
from flytekit import task, workflow
@task
def t(n: int) -> int:
return n
@workflow
def wf(n: float = 100) -> int:
return t(n=n)
Rahul Mehta
11/10/2022, 9:14 PMEduardo Apolinario (eapolinario)
11/10/2022, 9:34 PMRahul Mehta
11/10/2022, 9:35 PM@dynamic
workflows is that this would only get surfaced at runtime / not during serialization, but if mypy type checking worked that'd help us ease the friction of working w/ dynamic workflows a ton