# Result Serializers


# Serializer

class

prefect.engine.serializers.Serializer

()[source]

Serializers are used by Results to handle the transformation of Python objects to and from bytes.

Subclasses should implement serialize and deserialize.

methods:                                                                                                                                                       

prefect.engine.serializers.Serializer.deserialize

(value)[source]

Deserialize an object from bytes.

Args:

  • value (bytes): the value to deserialize
Returns:
  • Any: the deserialized value

prefect.engine.serializers.Serializer.serialize

(value)[source]

Serialize an object to bytes.

Args:

  • value (Any): the value to serialize
Returns:
  • bytes: the serialized value



# PickleSerializer

class

prefect.engine.serializers.PickleSerializer

()[source]

A Serializer that uses cloudpickle to serialize Python objects.

methods:                                                                                                                                                       

prefect.engine.serializers.PickleSerializer.deserialize

(value)[source]

Deserialize an object from bytes using cloudpickle.

Args:

  • value (bytes): the value to deserialize
Returns:
  • Any: the deserialized value

prefect.engine.serializers.PickleSerializer.serialize

(value)[source]

Serialize an object to bytes using cloudpickle.

Args:

  • value (Any): the value to serialize
Returns:
  • bytes: the serialized value



# JSONSerializer

class

prefect.engine.serializers.JSONSerializer

()[source]

A Serializer that uses JSON to serialize objects

methods:                                                                                                                                                       

prefect.engine.serializers.JSONSerializer.deserialize

(value)[source]

Deserialize an object from JSON

Args:

  • value (bytes): the value to deserialize
Returns:
  • Any: the deserialized value

prefect.engine.serializers.JSONSerializer.serialize

(value)[source]

Serialize an object to JSON

Args:

  • value (Any): the value to serialize
Returns:
  • bytes: the serialized value



# DateTimeSerializer

class

prefect.engine.serializers.DateTimeSerializer

()[source]

A Serializer for working with human-readable datetimes

methods:                                                                                                                                                       

prefect.engine.serializers.DateTimeSerializer.deserialize

(value)[source]

Deserialize an datetime from human-readable bytes

Args:

  • value (bytes): the value to deserialize
Returns:
  • Any: the deserialized value

prefect.engine.serializers.DateTimeSerializer.serialize

(value)[source]

Serialize a datetime to human-readable bytes

Args:

  • value (Any): the value to serialize
Returns:
  • bytes: the serialized value



# PandasSerializer

class

prefect.engine.serializers.PandasSerializer

(file_type, deserialize_kwargs=None, serialize_kwargs=None)[source]

A Serializer for Pandas DataFrames.

Args:

  • file_type (str): The type you want the resulting file to be saved as, e.g. "csv" or "parquet". Must match a type used in a DataFrame.to_ method and a pd.read_ function.
  • deserialize_kwargs (dict, optional): Keyword arguments to pass to the serialization method.
  • serialize_kwargs (dict, optional): Keyword arguments to pass to the deserialization method.

methods:                                                                                                                                                       

prefect.engine.serializers.PandasSerializer.deserialize

(value)[source]

Deserialize an object to a Pandas DataFrame

Args:

  • value (bytes): the value to deserialize
Returns:
  • DataFrame: the deserialized DataFrame

prefect.engine.serializers.PandasSerializer.serialize

(value)[source]

Serialize a Pandas DataFrame to bytes.

Args:

  • value (DataFrame): the DataFrame to serialize
Returns:
  • bytes: the serialized value



# CompressedSerializer

class

prefect.engine.serializers.CompressedSerializer

(serializer, format=None, compress=None, decompress=None, compress_kwargs=None, decompress_kwargs=None)[source]

A Serializer that wraps another Serializer and a compression function to serialize Python objects with compression.

Args:

  • serializer (Serializer): the serializer that this serializer wraps
  • format (str): name of the compression format library. Typically one of the python standard compression libraries: bz2, gzip, lzma, or zlib. Attempts to import the given format's module and retrieves the compress/decompress functions.
  • compress (Callable[..., bytes]): the custom compression function
  • decompress (Callable[..., bytes]): the custom decompression function
  • compress_kwargs (Dict[str, Any]): keyword arguments to be passed to the compression function
  • decompress_kwargs (Dict[str, Any]): keyword arguments to be passed to the decompression function

methods:                                                                                                                                                       

prefect.engine.serializers.CompressedSerializer.compression_from_lib

(compression_format)[source]

Attempt to pull a compression format from a library. Typically one of "lzma", "gzip", "zlib", "bz2"

Args:

  • compression_format: The compression format/library to load
Returns: A tuple of functions for compression and decompression

prefect.engine.serializers.CompressedSerializer.deserialize

(value)[source]

Deserialize an object from compressed bytes.

Args:

  • value (bytes): the compressed value to deserialize
Returns:
  • Any: the deserialized value

prefect.engine.serializers.CompressedSerializer.serialize

(value)[source]

Serialize an object to compressed bytes.

Args:

  • value (Any): the value to serialize
Returns:
  • bytes: the compressed serialized value



This documentation was auto-generated from commit n/a
on July 1, 2021 at 18:35 UTC