# Serialization


# JSONCompatible

class

prefect.utilities.serialization.JSONCompatible

(*args, **kwargs)[source]

Field that ensures its values are JSON-compatible during serialization and deserialization

Args:

  • *args (Any): the arguments accepted by marshmallow.Field
  • **kwargs (Any): the keyword arguments accepted by marshmallow.Field



# Nested

class

prefect.utilities.serialization.Nested

(nested, value_selection_fn, **kwargs)[source]

An extension of the Marshmallow Nested field that allows the value to be selected via a value_selection_fn.

Note that because the value_selection_fn is always called, users must return marshmallow.missing if they don't want this field included in the resulting serialized object.

Args:

  • nested (type): the nested schema class
  • value_selection_fn (Callable): a function that is called whenever the object is serialized, to retrieve the object (if not available as a simple attribute of the parent schema)
  • **kwargs (Any): the keyword arguments accepted by marshmallow.Field



# Bytes

class

prefect.utilities.serialization.Bytes

(*args, **kwargs)[source]

A Marshmallow Field that serializes bytes to a base64-encoded string, and deserializes a base64-encoded string to bytes.

Args:

  • *args (Any): the arguments accepted by marshmallow.Field
  • **kwargs (Any): the keyword arguments accepted by marshmallow.Field



# UUID

class

prefect.utilities.serialization.UUID

(*args, **kwargs)[source]

Replacement for fields.UUID that performs validation but returns string objects, not UUIDs

Args:

  • *args (Any): the arguments accepted by marshmallow.Field
  • **kwargs (Any): the keyword arguments accepted by marshmallow.Field



# FunctionReference

class

prefect.utilities.serialization.FunctionReference

(valid_functions, reject_invalid=True, **kwargs)[source]

Field that stores a reference to a function as a string and reloads it when deserialized.

Args:

  • valid_functions (List[Callable]): a list of functions that will be serialized as string references
  • reject_invalid (bool): if True, functions not in valid_functions will be rejected. If False, any value will be allowed, but only functions in valid_functions will be deserialized.
  • **kwargs (Any): the keyword arguments accepted by marshmallow.Field



# Functions

top-level functions:                                                                                                                                                       

prefect.utilities.serialization.to_qualified_name

(obj)[source]

Given an object, returns its fully-qualified name, meaning a string that represents its Python import path

Args:

  • obj (Any): an importable Python object
Returns:
  • str: the qualified name

prefect.utilities.serialization.from_qualified_name

(obj_str)[source]

Retrives an object from a fully qualified string path. The object must be imported in advance.

Args:

  • obj_str (str): the qualified path of the object
Returns:
  • Any: the object retrieved from the qualified path
Raises:
  • ValueError: if the object could not be loaded from the supplied path. Note that this function will not import objects; they must be imported in advance.

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