cuddly-jelly-27016
08/15/2025, 9:17 AMpydantic.Basemodel and dataclass should work to annotate the output.
### Additional context to reproduce
One can test with these tasks.
import flytekit as fl
import numpy as np
import pandas as pd
# Does not work (empty dict as output)
@fl.task
def return_basemodel_two() -> BaseModelTwo:
return BaseModelTwo(
foo=fl.StructuredDataset(dataframe=pd.DataFrame(np.random.rand(3, 3))),
bar=fl.StructuredDataset(dataframe=pd.DataFrame(np.random.rand(3, 3))),
)
# Works (returns populated dataclass as expected)
@fl.task
def return_dataclass_two() -> DataClassTwo:
return DataClassTwo(
foo=fl.StructuredDataset(dataframe=pd.DataFrame(np.random.rand(3, 3))),
bar=fl.StructuredDataset(dataframe=pd.DataFrame(np.random.rand(3, 3))),
)
### Screenshots
No response
### Are you sure this issue hasn't been raised already?
• Yes
### Have you read the Code of Conduct?
• Yes
flyteorg/flyte