Skip to content

Commit

Permalink
update comments in _make_dataclass_serializable
Browse files Browse the repository at this point in the history
Signed-off-by: mao3267 <[email protected]>
  • Loading branch information
mao3267 committed Oct 24, 2024
1 parent f79f51d commit a0f8401
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions flytekit/core/type_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,18 @@ def _fix_structured_dataset_type(self, python_type: Type[T], python_val: typing.
def _make_dataclass_serializable(self, python_val: T, python_type: Type[T]) -> typing.Any:
"""
If any field inside the dataclass is flyte type, we should use flyte type transformer for that field.
Since other types are already serializable, this function is intended for using strings instead of directly creating Flyte files and directories in the dataclass.
An example shows the lifecycle:
@dataclass
class DC:
ff: FlyteFile
@task
def t1() -> DC:
return DC(ff="s3://path")
Lifecycle: DC(ff="s3://path") -> to_literal() -> DC(ff=FlyteFile(path="s3://path")) -> msgpack -> to_python_value() -> DC(ff=FlyteFile(path="s3://path"))
"""
from flytekit.types.directory import FlyteDirectory
from flytekit.types.file import FlyteFile
Expand Down

0 comments on commit a0f8401

Please sign in to comment.