<#5956 [BUG] Attribute Access Structured Dataset f...
# flytekit
c
#5956 [BUG] Attribute Access Structured Dataset from Dataclass and return it will fail Issue created by Future-Outlier Describe the bug example code: from dataclasses import dataclass, field from flytekit.types.structured import StructuredDataset from flytekit import task, workflow, ImageSpec flytekit_hash = "6e4e53bb89debbeef764d3a0a16e499e0bcd18e2" # from master branch flytekit = f"git+https://github.com/flyteorg/flytekit.git@{flytekit_hash}" image = ImageSpec( packages=[flytekit, "pandas", "pyarrow"], apt_packages=["git"], registry="localhost:30000", ) @dataclass class DC: sd: StructuredDataset = field(default_factory=lambda: StructuredDataset(uri="s3://my-s3-bucket/s3_flyte_dir/df.parquet", file_format="parquet")) @task(container_image=image) def t_sd_attr(sd: StructuredDataset) -> StructuredDataset: return sd @workflow def wf(dc: DC): t_sd_attr(sd=dc.sd) if name == "__main__": from flytekit.clis.sdk_in_container import pyflyte from click.testing import CliRunner import os input_val = '{"dc": {"sd": {"uri": "s3://my-s3-bucket/s3_flyte_dir/df.parquet", "file_format": "parquet"}}}' runner = CliRunner() path = os.path.realpath(file) result = runner.invoke(pyflyte.main, ["run", "--remote", path, "wf", "--dc", input_val]) print("Remote Execution: ", result.output) error message:
Copy code
[ak8chhw7598h6x695dvg-n0-0] terminated with exit code (1). Reason [Error]. Message: 
^^^^^^^^^^^^^^^^^
  File "/opt/micromamba/envs/runtime/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/micromamba/envs/runtime/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/micromamba/envs/runtime/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/micromamba/envs/runtime/lib/python3.12/site-packages/flytekit/bin/entrypoint.py", line 579, in execute_task_cmd
    _execute_task(
  File "/opt/micromamba/envs/runtime/lib/python3.12/site-packages/flytekit/bin/entrypoint.py", line 454, in _execute_task
    _dispatch_execute(ctx, load_task, inputs, output_prefix)
  File "/opt/micromamba/envs/runtime/lib/python3.12/site-packages/flytekit/bin/entrypoint.py", line 216, in _dispatch_execute
    utils.write_proto_to_file(v.to_flyte_idl(), os.path.join(ctx.execution_state.engine_dir, k))
                              ^^^^^^^^^^^^^^^^
  File "/opt/micromamba/envs/runtime/lib/python3.12/site-packages/flytekit/models/literals.py", line 693, in to_flyte_idl
    return _literals_pb2.LiteralMap(literals={k: v.to_flyte_idl() for k, v in self.literals.items()})
                                                 ^^^^^^^^^^^^^^^^
  File "/opt/micromamba/envs/runtime/lib/python3.12/site-packages/flytekit/models/literals.py", line 989, in to_flyte_idl
    scalar=self.scalar.to_flyte_idl() if self.scalar is not None else None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/micromamba/envs/runtime/lib/python3.12/site-packages/flytekit/models/literals.py", line 831, in to_flyte_idl
    structured_dataset=self.structured_dataset.to_flyte_idl() if self.structured_dataset is not None else None,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'StructuredDataset' object has no attribute 'to_flyte_idl'
Expected behavior This should work. The bug might relate to this place. The
_literal_sd
should be
literals.StructuredDataset
, but it is a
StructuredDataset
. https://github.com/flyteorg/flytekit/blob/master/flytekit/types/structured/structured_dataset.py#L672-L679 Additional context to reproduce No response Screenshots No response Are you sure this issue hasn't been raised already? • Yes Have you read the Code of Conduct? • Yes flyteorg/flyte