# flyte.types

# Flyte Type System

The Flyte type system provides a way to define, transform, and manipulate types in Flyte workflows.
Since the data flowing through Flyte has to often cross process, container and langauge boundaries, the type system
is designed to be serializable to a universal format that can be understood across different environments. This
universal format is based on Protocol Buffers. The types are called LiteralTypes and the runtime
representation of data is called Literals.

The type system includes:
- **TypeEngine**: The core engine that manages type transformations and serialization. This is the main entry point for
  for all the internal type transformations and serialization logic.
- **TypeTransformer**: A class that defines how to transform one type to another. This is extensible
    allowing users to define custom types and transformations.
- **Renderable**: An interface for types that can be rendered as HTML, that can be outputted to a flyte.report.

It is always possible to bypass the type system and use the `FlytePickle` type to serialize any python object
 into a pickle format. The pickle format is not human-readable, but can be passed between flyte tasks that are
 written in python. The Pickled objects cannot be represented in the UI, and may be in-efficient for large datasets.
## Directory

### Classes

| Class | Description |
|-|-|
| [`FlytePickle`](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/flytepickle/page.md) | This type is only used by flytekit internally. |
| [`TypeEngine`](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/typeengine/page.md) | Core Extensible TypeEngine of Flytekit. |
| [`TypeTransformer`](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/typetransformer/page.md) | Base transformer type that should be implemented for every python native type that can be handled by flytekit. |

### Protocols

| Protocol | Description |
|-|-|
| [`Renderable`](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/renderable/page.md) |  |

### Errors

| Exception | Description |
|-|-|
| [`TypeTransformerFailedError`](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/typetransformerfailederror/page.md) |  |

### Methods

| Method | Description |
|-|-|
| [`guess_interface()`](#guess_interface) | Returns the interface of the task with guessed types, as types may not be present in current env. |
| [`literal_string_repr()`](#literal_string_repr) | This method is used to convert a literal map to a string representation. |

## Methods

#### guess_interface()

```python
def guess_interface(
    interface: flyteidl2.core.interface_pb2.TypedInterface,
    default_inputs: typing.Optional[typing.Iterable[flyteidl2.task.common_pb2.NamedParameter]],
) -> flyte.models.NativeInterface
```
Returns the interface of the task with guessed types, as types may not be present in current env.

| Parameter | Type | Description |
|-|-|-|
| `interface` | `flyteidl2.core.interface_pb2.TypedInterface` | |
| `default_inputs` | `typing.Optional[typing.Iterable[flyteidl2.task.common_pb2.NamedParameter]]` | |

#### literal_string_repr()

```python
def literal_string_repr(
    lm: typing.Union[flyteidl2.core.literals_pb2.Literal, flyteidl2.task.common_pb2.NamedLiteral, flyteidl2.task.common_pb2.Inputs, flyteidl2.task.common_pb2.Outputs, flyteidl2.core.literals_pb2.LiteralMap, typing.Dict[str, flyteidl2.core.literals_pb2.Literal]],
) -> typing.Dict[str, typing.Any]
```
This method is used to convert a literal map to a string representation.

| Parameter | Type | Description |
|-|-|-|
| `lm` | `typing.Union[flyteidl2.core.literals_pb2.Literal, flyteidl2.task.common_pb2.NamedLiteral, flyteidl2.task.common_pb2.Inputs, flyteidl2.task.common_pb2.Outputs, flyteidl2.core.literals_pb2.LiteralMap, typing.Dict[str, flyteidl2.core.literals_pb2.Literal]]` | |

## Subpages

- [FlytePickle](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/flytepickle/page.md)
  - Methods
  - from_pickle()
  - python_type()
  - to_pickle()
- [Renderable](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/renderable/page.md)
  - Methods
  - to_html()
- [TypeEngine](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/typeengine/page.md)
  - Methods
  - dict_to_literal_map()
  - get_available_transformers()
  - get_transformer()
  - guess_python_type()
  - guess_python_types()
  - lazy_import_transformers()
  - literal_map_to_kwargs()
  - named_tuple_to_variable_map()
  - register()
  - register_additional_type()
  - register_restricted_type()
  - to_html()
  - to_literal()
  - to_literal_checks()
  - to_literal_type()
  - to_python_value()
  - unwrap_offloaded_literal()
- [TypeTransformer](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/typetransformer/page.md)
  - Parameters
  - Properties
  - Methods
  - assert_type()
  - from_binary_idl()
  - get_literal_type()
  - guess_python_type()
  - isinstance_generic()
  - schema_match()
  - to_html()
  - to_literal()
  - to_python_value()
- [TypeTransformerFailedError](https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/typetransformerfailederror/page.md)

---
**Source**: https://github.com/unionai/unionai-docs/blob/main/content/api-reference/flyte-sdk/packages/flyte.types/_index.md
**HTML**: https://www.union.ai/docs/v2/union/api-reference/flyte-sdk/packages/flyte.types/
