class flytekit.types.structured.StructuredDatasetEncoder(python_type, protocol=None, supported_format=None)[source]#


  • python_type (Type[T]) –

  • protocol (Optional[str]) –

  • supported_format (Optional[str]) –

abstract encode(ctx, structured_dataset, structured_dataset_type)[source]#

Even if the user code returns a plain dataframe instance, the dataset transformer engine will wrap the incoming dataframe with defaults set for that dataframe type. This simplifies this function’s interface as a lot of data that could be specified by the user using the # TODO: Do we need to add a flag to indicate if it was wrapped by the transformer or by the user?

  • ctx (flytekit.core.context_manager.FlyteContext) –

  • structured_dataset (flytekit.types.structured.structured_dataset.StructuredDataset) – This is a StructuredDataset wrapper object. See more info above.

  • structured_dataset_type (flytekit.models.types.StructuredDatasetType) – This the StructuredDatasetType, as found in the LiteralType of the interface of the task that invoked this encoding call. It is passed along to encoders so that authors of encoders can include it in the returned literals.StructuredDataset. See the IDL for more information on why this literal in particular carries the type information along with it. If the encoder doesn’t supply it, it will also be filled in after the encoder runs by the transformer engine.


This function should return a StructuredDataset literal object. Do not confuse this with the StructuredDataset wrapper class used as input to this function - that is the user facing Python class. This function needs to return the IDL StructuredDataset.

Return type