pydrobert.param.serialization

Utilities for (de)serializing Parameterized objects

pydrobert.param.serialization.DEFAULT_BACKUP_SERIALIZER

JSON string serializers by param type

Used as defaults when writing an INI file

See also

serialize_to_ini

How these are used

pydrobert.param.serialization.DEFAULT_DESERIALIZER_DICT

Default deserializer that is not type specific

See also

deserialize_from_dict

How this is used

pydrobert.param.serialization.DEFAULT_SERIALIZER_DICT

Default serializer to use when not type specific

See also

serialize_to_dict

How this is used

class pydrobert.param.serialization.DefaultArrayDeserializer(**kwargs)[source]

Bases: ParamConfigDeserializer

Default deserializer for numpy arrays

Keyword arguments can be passed to referenced methods by initializing this deserializer with those keyword arguments.

The process:

  1. None check

  2. If already a numpy.ndarray, set it

  3. If a string ending with '.npy', load it as a file path (numpy.load() with kwargs)

  4. If bytes, load it with numpy.frombuffer() and kwargs

  5. If a string, load it with numpy.fromstring() and kwargs

  6. Try initializing to array with numpy.array() and kwargs

class pydrobert.param.serialization.DefaultArraySerializer[source]

Bases: ParamConfigSerializer

Default numpy array serializer

The process: 1. If None, return 2. Call value’s tolist() method

class pydrobert.param.serialization.DefaultBooleanDeserializer[source]

Bases: ParamConfigDeserializer

Default deserializer for booleans

The process:

  1. None check

  2. If block is in TRUE_VALUES, set as True

  3. If block is in FALSE_VALUES, set as False

  4. If block is already a bool, use verbatim

FALSE_VALUES = {0, '0', 'OFF', 'f', 'false', 'F', 'FALSE', 'off', 'False', 'NO', 'no'}
TRUE_VALUES = {1, 'True', '1', 'TRUE', 'ON', 'true', 'yes', 'YES', 'T', 'on', 't'}
class pydrobert.param.serialization.DefaultClassSelectorDeserializer(*args, **kwargs)[source]

Bases: ParamConfigDeserializer

Default ClassSelector deserializer

The process:

  1. None check

  2. If the parameter’s is_instance attribute is True:

    1. If block is an instance of the parameter’s class_ attribute, set it

    2. Try instantiating the class with block as the first argument, with additional arguments and keyword arguments passed to the deserializer passed allong to the constructor.

  3. Look for the block or the block name in the selector’s param.ClassSelector.get_range dictionary

class pydrobert.param.serialization.DefaultClassSelectorSerializer[source]

Bases: ParamConfigSerializer

Default ClassSelector serializer

The process:

  1. If None, return

  2. If parameter’s is_instance attribute is True, return value verbatim

  3. Search for the corresponding name in the selector’s param.ClassSelector.get_range() dictionary and return that name, if possible

  4. Return the value

class pydrobert.param.serialization.DefaultDataFrameDeserializer(*args, **kwargs)[source]

Bases: ParamConfigDeserializer

Default pandas.DataFrame deserializer

Keyword arguments and positional arguments can be passed to referenced methods by initializing this deserializer with those keyword arguments.

The process:

  1. None check

  2. If block is a data frame, set it

  3. If block is a string that ends with one of a number of file suffixes, e.g. ".csv", ".json", ".html", ".xls", use the associated pandas.read_* method with block as the first argument plus the deserializer’s extra args and kwargs

  4. If block is a string, try pandas.read_table()

  5. Try initializing a pandas.DataFrame with block as the first argument plus the deserializer’s extra args and kwargs

class pydrobert.param.serialization.DefaultDataFrameSerializer[source]

Bases: ParamConfigSerializer

Default pandas.DataFrame serializer

The process:

  1. If None, return

  2. Call tolist() on the values property of the parameter’s value and return

class pydrobert.param.serialization.DefaultDateDeserializer(format=('%Y-%m-%dT%H:%M:%S.%f', '%Y-%m-%dT%H:%M:%S', '%Y-%m-%d'))[source]

Bases: ParamConfigDeserializer

Default datetime.datetime deserializer

The process:

  1. None check

  2. If block is a datetime.datetime, set it

  3. If the deserializer’s format argument is not None and block is a string:

    1. If format is a string, try to convert block to a datetime using datetime.datetime.strptime()

    2. If format is list-like, parse a datetime.datetime object with datetime.datetime.strptime(element, format). If the parse is successful, use that parsed datetime.

  4. Try casting block to a float

    1. If the float has a remainder or the value exceeds the maximum ordinal value, treat as a UTC timestamp

    2. Otherwise, treat as a Gregorian ordinal time

  5. Try instantiating a datetime with block as an argument to the constructor.

  6. If numpy can be imported, try instantiating a numpy.datetime64 with block as an argument to the constructor.

class pydrobert.param.serialization.DefaultDateRangeDeserializer(format=('%Y-%m-%dT%H:%M:%S.%f', '%Y-%m-%dT%H:%M:%S', '%Y-%m-%d'))[source]

Bases: ParamConfigDeserializer

Default date range deserializer

Similar to deserializing a single datetime.datetime, but applied to each element separately. Cast to a tuple.

class pydrobert.param.serialization.DefaultDateRangeSerializer(format=('%Y-%m-%d', '%Y-%m-%dT%H:%M:%S', '%Y-%m-%dT%H:%M:%S.%f'))[source]

Bases: ParamConfigSerializer

Default date range serializer

Similar to serializing a single datetime.datetime, but applied to each element separately. Also cast to a list

class pydrobert.param.serialization.DefaultDateSerializer(format=('%Y-%m-%d', '%Y-%m-%dT%H:%M:%S', '%Y-%m-%dT%H:%M:%S.%f'))[source]

Bases: ParamConfigSerializer

Default datetime.datetime serializer

The process:

  1. If None, return

  2. If a datetime.datetime instance

    1. If the format keyword argument of the serializer is not None:

      1. If format is a string, return the result of the value’s strftime(format) call

      2. If format is list-like, iterate through it, formatting with strftime(element). Whichever string which, when deserialized with strptime(element), produces an equivalent :class`datetime.datetime` object as the value is returned. If no such string exists, the last string is returned.

    2. Return the result of the value’s timestamp() call

  3. If a numpy.datetime64 instance, return the value cast to a string

class pydrobert.param.serialization.DefaultDeserializer[source]

Bases: ParamConfigDeserializer

Catch-all deserializer

This serializer performs a none check, then tries to set the parameter with the value of block verbatim.

class pydrobert.param.serialization.DefaultIntegerDeserializer(*args, **kwargs)[source]

Bases: _CastDeserializer

Default int deserializer

The process:

  1. None check

  2. If block is a(n) int, set it

  3. Initialize a(n) int instance with block as the first argument plus any extra positional or keyword arguments passed to the deserializer on initialization

class_

alias of int

class pydrobert.param.serialization.DefaultListDeserializer(*args, **kwargs)[source]

Bases: ParamConfigDeserializer

Default list deserializer

The process:

  1. None check

  2. If the parameter’s class_ attribute has been set, for each element in block (we always assume block is iterable):

    1. If the element is an instance of the class, leave it alone

    2. Try instantiating a class_ object using the element as the first argument plus any arguments or keyword arguments passed to the deserializer on initialization.

  3. Cast to a list and set

class pydrobert.param.serialization.DefaultListSelectorDeserializer[source]

Bases: ParamConfigDeserializer

Default ListSelector deserializer

For each element in block (we assume block is iterable), match a value or name in the selector’s param.ListSelector.get_range() method

class pydrobert.param.serialization.DefaultListSelectorSerializer[source]

Bases: ParamConfigSerializer

Default ListSelector serializer

For each element in the value:

  1. Search for its name in the selector’s param.ListSelector.get_range() dict and swap if for the name, if possible

  2. Otherwise, use that element verbatim

class pydrobert.param.serialization.DefaultNumberDeserializer(*args, **kwargs)[source]

Bases: _CastDeserializer

Default float deserializer

The process:

  1. None check

  2. If block is a(n) float, set it

  3. Initialize a(n) float instance with block as the first argument plus any extra positional or keyword arguments passed to the deserializer on initialization

class_

alias of float

class pydrobert.param.serialization.DefaultNumericTupleDeserializer[source]

Bases: ParamConfigDeserializer

Default numeric tuple deserializer

The process: 1. None check 2. Cast each element of block to a float 3. Cast block to a tuple

class pydrobert.param.serialization.DefaultObjectSelectorDeserializer[source]

Bases: ParamConfigDeserializer

Default param.ObjectSelector deserializer

The process:

  1. None check

  2. Match block to a value or name in the selector’s param.ObjectSelector.get_range() method

class pydrobert.param.serialization.DefaultObjectSelectorSerializer[source]

Bases: ParamConfigSerializer

Default ObjectSelector serializer

The process:

  1. If None, return

  2. Search for the name of the value in the selector’s param.ObjectSelector.get_range() dictionary and return, if possible

  3. Return value verbatim

class pydrobert.param.serialization.DefaultSerializer[source]

Bases: ParamConfigSerializer

Default catch-all serializer. Returns value verbatim

class pydrobert.param.serialization.DefaultSeriesSerializer[source]

Bases: ParamConfigSerializer

Default pandas.Series serializer

The process:

  1. If None, return

  2. Call tolist() on the values property of the parameter’s value and return

class pydrobert.param.serialization.DefaultStringDeserializer(*args, **kwargs)[source]

Bases: _CastDeserializer

Default str deserializer

The process:

  1. None check

  2. If block is a(n) str, set it

  3. Initialize a(n) str instance with block as the first argument plus any extra positional or keyword arguments passed to the deserializer on initialization

class_

alias of str

class pydrobert.param.serialization.DefaultTupleSerializer[source]

Bases: ParamConfigSerializer

Default tuple serializer

The process: 1. If None, return 2. Casts the value to a list

class pydrobert.param.serialization.JsonStringArrayDeserializer(**kwargs)[source]

Bases: DefaultArrayDeserializer

Parses a block as JSON before converting it into a numpy array

The default deserializer used in INI files. Input is always assumed to be a string or None. If None, a none check is performed. Otherwise, it parses the value as JSON, then does the same as DefaultArrayDeserializer. However, if the input ends in the file suffix ".npy", the input will be immediately passed to DefaultArrayDeserializer

See also

deserialize_from_json

To deserialize JSON into param.parameterized.Parameterized instances

class pydrobert.param.serialization.JsonStringDataFrameDeserializer(*args, **kwargs)[source]

Bases: DefaultDataFrameDeserializer

Parses block as JSON before converting to pandas.DataFrame

The default deserializer used in INI files. Input is always assumed to be a string or None. If None, a none check is performed. Otherwise, it parses the value as JSON, then does the same as DefaultDataFrameSerializer. However, if the input ends in a file suffix like ".csv", ".xls", etc., the input will be immediately passed to DefaultDataFrameSerializer

See also

deserialize_from_json

To deserialize JSON into param.parameterized.Parameterized instances

file_suffixes = {'csv', 'dta', 'feather', 'h5', 'html', 'json', 'parquet', 'pkl', 'sas7bdat', 'xls'}
pydrobert.param.serialization.JsonStringTupleDeserializer

Default deserializers by parameter type

See also

deserialize_from_dict

How these are used

pydrobert.param.serialization.JsonStringTupleSerializer

Default serializers by param type

See also

serialize_to_dict

How these are used

class pydrobert.param.serialization.ParamConfigDeserializer[source]

Bases: object

Deserialize part of a configuration into a parameterized object

Subclasses of ParamConfigDeserializer are expected to implement deserialize(). Instances of the subclass can be passed into deserialize_from_dict(). The goal of a deserializer is to convert data into the value of a parameter in a param.parameterized.Parameterized object. The format of the incoming data is specific to where the dict-like input came from. For example, a JSON parser converts numeric strings to floats, and the contents of square braces ([]) as lists. In pydrobert.param.serialization, there are a number of default deserializers (matching the pattern Default*Deserializer) that are best guesses on how to deserialize data from a variety of sources

static check_if_allow_none_and_set(name, block, parameterized)[source]

Check if block can be made none and set it if allowed

Many param.Param parameters allow None as a value. This is a convenience method that deserializers can use to quickly check for a None value and set it in that case. This method sets the parameter and returns True in the following conditions

  1. The parameter allows None values (the allow_None attribute is True)

  2. block is None

If one of these conditions wasn’t met, the parameter remains unset and the method returns False.

In Default*Deseriazer documentation, a call to this method is referred to as a “none check”.

abstract deserialize(name, block, parameterized)[source]

Deserialize data and store it in a parameterized object

Parameters
  • name (str) – The name of the parameter in parameterized to store the value under

  • block (Any) – The data to deserialize into the parameter value

  • parameterized (Parameterized) – The parameterized instance containing a parameter with the name name. On completion of this method, that parameter will be set with the deserialized contents of block

Raises

ParamConfigTypeError – If deserialization could not be performed

class pydrobert.param.serialization.ParamConfigSerializer[source]

Bases: object

Serialize a parameter value from a Parameterized object

Subclasses of ParamConfigSerializer are expected to implement serialize(). Instances of the subclass can be passed into serialize_to_dict(). The goal of a serializer is to convert a parameter value from a param.parameterized.Parameterized object into something that can be handled by a dict-like data store. The format of the outgoing data should reflect where the dict-like data are going. For example, a JSON serializer can handle lists, but not an INI serializer. In pydrobert.param.serialization, there are a number of default serializers (matching the pattern Default*Serializer) that are best guesses on how to serialize data from a variety of sources

help_string(name, parameterized)[source]

A string that helps explain this serialization

The return string will be included in the second element of the pair returned by serialize_to_dict(). Helps explain the serialized value to the user.

abstract serialize(name, parameterized)[source]

Serialize data from a parameterized object and return it

Parameters
  • name (str) – The name of the parameter in parameterized to retrieve the value from

  • parameterized (Parameterized) – The parameterized instance containing a parameter with the name name

Returns

val (obj) – The serialized value of the parameter

Raises

ParamConfigTypeError – If serialization could not be performed

exception pydrobert.param.serialization.ParamConfigTypeError(parameterized, name, message='')[source]

Bases: TypeError

Raised when failed to (de)serialize Parameterized object

pydrobert.param.serialization.deserialize_from_dict(dict_, parameterized, deserializer_name_dict=None, deserializer_type_dict=None, on_missing='warn')[source]

Deserialize a dictionary into a parameterized object

This function is suitable for deserializing the results of parsing a data storage file such as a YAML, JSON, or a section of an INI file (using the yaml, json, and configparser python modules, resp.) into a param.parameterized.Parameterized object. Each key in dict_ should match the name of a parameter in parameterized. The parameter will be deserialized into parameterized using a ParamConfigDeserializer object matched with the following precedent:

  1. If deserializer_name_dict is specified and contains the same key, the value of the item in deserializer_name_dict will be used.

  2. If deserializer_type_dict and the type of the parameter in question exactly matches a key in deserializer_type_dict, the value of the item in deserializer_type_dict will be used.

  3. If the type of the parameter in question exactly matches a key in DEFAULT_DESERIALIZER_DICT, the value of the item in DEFAULT_DESERIALIZER_DICT will be used.

  4. DEFAULT_BACKUP_DESERIALIZER will be used.

It is possible to pass a dictionary as parameterized instead of a param.parameterized.Parameterized instance to this function. This is “hierarchical mode”. The values of parameterized can be param.parameterized.Parameterized objects or nested dictionaries. In this case, dict_ and deserializer_name_dict are expected to be dictionaries with the same hierarchical structure (though the latter can still be None). deserializer_type_dict can be a flat dictionary of types to be applied to all nodes, or a hierarchical dictionary of strings like dict_, or some combination. The leaves of dict_ deserialize into the leaves of parameterized. If no leaf of dict_ exists for a given parameterized leaf, that parameterized object will not be updated.

Default deserializers are likely appropriate for basic types like strings, ints, bools, floats, and numeric tuples. For more complex data types, including recursive param.parameterized.Parameterized instances, custom deserializers are recommended.

Parameters
  • dict

  • parameterized (Union[Parameterized, dict]) –

  • deserializer_name_dict (Optional[dict]) –

  • deserializer_type_dict (Optional[dict]) –

  • on_missing (Literal[‘ignore’, ‘warn’, ‘raise’]) – What to do if the parameterized instance does not have a parameter listed in dict_, or, in the case of “hierarchical mode”, if dict_ contains a key with no matching parameterized object to populate

Raises

ParamConfigTypeError – If deserialization of a value fails

pydrobert.param.serialization.deserialize_from_ini(file, parameterized, deserializer_name_dict=None, deserializer_type_dict=None, on_missing='warn', defaults=None, comment_prefixes=('#', ';'), inline_comment_prefixes=(';',), one_param_section=None)[source]

Deserialize an INI (config) file into a parameterized instance

.INI syntax, extended with configparser. configparser extends the INI syntax with value interpolation. Further, keys missing a value will be interpreted as having the value None. This function converts an INI file to a dictionary, then populates parameterized with the contents of this dictionary.

INI files are broken up into sections; all key-value pairs must belong to a section. If parameterized is a param.parameterized.Parameterized instance (rather than a hierarchical dictionary of them), the action will try to deserialize the section specified by one_param_section keyword argument.

Because the INI syntax does not support standard containers like dicts or lists out-of-the-box, this function uses the JsonString*Deserializer to read container values to JSON strings before trying the standard method of deserialization. This solution was proposed here. Defaults from DEFAULT_DESERIALIZER_DICT are clobbered by those from JSON_STRING_DESERIALIZER_DICT. You can get the original defaults back by including them in deserializer_type_dict

Parameters
  • file (Union[TextIO, str]) – The INI file to deserialize from. Can be a pointer or a path

  • parameterized (Union[Parameterized, dict]) –

  • deserializer_name_dict (Optional[dict]) –

  • deserializer_type_dict (Optional[dict]) –

  • on_missing (Literal[‘ignore’, ‘warn’, ‘raise’]) –

  • defaults (Optional[dict]) – Default key-values used in interpolation (substitution). Terms such as (key)%s (like a python 2.7 format string) are substituted with these values

  • comment_prefixes (Sequence[str]) – A sequence of characters that indicate a full-line comment in the INI file

  • inline_comment_prefixes (Sequence[str]) – A sequence of characters that indicate an inline (including full-line) comment in the INI file

  • one_param_section (Optional[str]) – If parameterized refers to a single param.parameterized.Parameterized instance, this keyword is used to indicate which section of the INI file will be deserialized. If unspecified, will default to the name attribute of parameterized

See also

deserialize_from_dict

A description of the deserialization process and the parameters to this function

pydrobert.param.serialization.deserialize_from_json(file, parameterized, deserializer_name_dict=None, deserializer_type_dict=None, on_missing='warn')[source]

Deserialize a YAML file into a parameterized instance

JSON syntax. This function converts a JSON file to a dictionary, then populates parameterized with the contents of this dictionary

Parameters

See also

deserialize_from_dict

A description of the deserialization process and the parameters to this function

pydrobert.param.serialization.deserialize_from_yaml(file, parameterized, deserializer_name_dict=None, deserializer_type_dict=None, on_missing='warn')[source]

Deserialize a YAML file into a parameterized instance

YAML syntax. This function converts a YAML file to a dictionary, then populates parameterized with the contents of this dictionary

Parameters

See also

deserialize_from_dict

A description of the deserialization process and the parameters to this function

Notes

This function tries to use the YAML (de)serialization module to load the YAML file in the order listed in YAML_MODULE_PRIORITIES, falling back on the next if there’s an ImportError.

pydrobert.param.serialization.serialize_to_dict(parameterized, only=None, serializer_name_dict=None, serializer_type_dict=None, on_missing='raise', include_help=False)[source]

Serialize a parameterized object into a dictionary

This function serializes data into a dictionary format, suitable for storage in a dict-like file format such as YAML or JSON. Each parameter will be serialized into the dictionary using a ParamConfigSerializer object, matched with the following precedent:

  1. If serializer_name_dict is specified and contains the parameter name as a key, the value will be used.

  2. If serializer_type_dict and the type of the parameter in question exactly matches a key in serializer_type_dict, the value of the item in serializer_type_dict will be used.

  3. If the type of the parameter in question exactly matches a key in DEFAULT_SERIALIZER_DICT, the value of the item in DEFAULT_SERIALIZER_DICT will be used.

  4. DEFAULT_BACKUP_SERIALIZER will be used.

Default serializers are likely appropriate for basic types like strings, ints, bools, floats, and numeric tuples. For more complex data types, including recursive param.parameterized.Parameterized instances, custom serializers are recommended.

It is possible to pass a dictionary as parameterized instead of a param.parameterized.Parameterized instance to this function. This is “hierarchical mode”. The values of parameterized can be param.parameterized.Parameterized objects or nested dictionaries. The returned dictionary will have the same hierarchical dictionary structure as parameterized, but with the param.parameterized.Parameterized values replaced with serialized dictionaries. In this case, only and serializer_name_dict are expected to be dictionaries with the same hierarchical structure (though they can still be None, which propagates to children), whose leaves correspond to the arguments used to serialize the leaves of parameterized. serializer_type_dict can also be hierarchical, can be flat, or be some combination.

Parameters
  • parameterized (Union[Parameterized, dict]) –

  • only (Optional[Collection[str]]) – If specified, only the parameters with their names in this set will be serialized into the return dictionary. If unset, all parameters except name will be serialized.

  • serializer_name_dict (Optional[dict]) –

  • serializer_type_dict (Optional[dict]) –

  • on_missing (Literal[‘ignore’, ‘warn’, ‘raise’]) – What to do if the parameterized instance does not have a parameter listed in only

  • include_help (bool) – If True, the return value will be a pair of dictionaries instead of a single dictionary. This dictionary will contain any help strings any serializers make available through a call to help_string (or None if none is available).

Returns

collections.OrderedDict or tuple – A dictionary of serialized parameters or a pair of dictionaries if include_help was True (the latter is the help dictionary). If parameterized was an ordered dictionary, the returned serialized dictionary will have the same order. Parameters from a param.parameterized.Parameterized instance are sorted alphabeticallly

Raises

ParamConfigTypeError – If serialization of a value fails

pydrobert.param.serialization.serialize_to_ini(file, parameterized, only=None, serializer_name_dict=None, serializer_type_dict=None, on_missing='raise', include_help=True, help_prefix='#', one_param_section=None)[source]

Serialize a parameterized instance into an INI (config) file

.INI syntax, extended with configparser. configparser extends the INI syntax with value interpolation. Further, keys missing a value will be interpreted as having the value None. This function converts parameterized to a dictionary, then fills an INI file with the contents of this dictionary.

INI files are broken up into sections; all key-value pairs must belong to a section. If parameterized is a param.parameterized.Parameterized instance (rather than a hierarchical dictionary of them), the action will try to serialize parameterized into the section specified by the one_param_section keyword argument. If parameterized is a hierarchical dictionary, it can only have depth 1, with each leaf being a param.parameterized.Parameterized instance. In this case, each key corresponds to a section. If an ordered dictionary, sections will be written in the same order as they exist in parameterized.

Because the INI syntax does not support standard containers like dicts or lists out-of-the-box, this function uses the JsonString*Serializer to convert container values to JSON strings before writing them to the INI file. This solution was proposed here. Defaults from DEFAULT_SERIALIZER_DICT are clobbered by those from JSON_STRING_SERIALIZER_DICT. You can get the original defaults back by including them in serializer_type_dict

Parameters
  • file (Union[str, TextIO]) – The INI file to serialize to. Can be a pointer or a path

  • parameterized (Union[Parameterized, dict]) –

  • only (Optional[Collection[str]]) –

  • serializer_name_dict (Optional[dict]) –

  • serializer_type_dict (Optional[dict]) –

  • on_missing (Literal[‘ignore’, ‘warn’, ‘raise’]) –

  • include_help (bool) – If True, help documentation will be included at the top of the INI file for any parameters and/or serializers that support it

  • help_prefix (str) – The character prefix used at the start of each help line, usually indicating a comment

  • one_param_section (Optional[str]) – If parameterized refers to a single param.parameterized.Parameterized instance, this keyword is used to indicate which section of the INI file parameterized will be serialized to. If None, the name attribute of the parameterized instance will be the used

See also

serialize_to_dict

A description of the serialization process and the parameters to this function

pydrobert.param.serialization.serialize_to_json(file, parameterized, only=None, serializer_name_dict=None, serializer_type_dict=None, on_missing='raise', indent=2)[source]

Serialize a parameterized instance into a JSON file

JSON syntax. This function converts parameterized to a dictionary, then fills an JSON file with the contents of this dictionary.

Parameters

See also

serialize_to_dict

A description of the serialization process and the parameters to this function

Notes

JSON does not have standard “comments,” so this function does not write help strings as comments

pydrobert.param.serialization.serialize_to_yaml(file, parameterized, only=None, serializer_name_dict=None, serializer_type_dict=None, on_missing='raise', include_help=True)[source]

Serialize a parameterized instance into a YAML file

YAML syntax. This function converts parameterized to a dictionary, then fills a YAML file with the contents of this dictionary.

Parameters

See also

serialize_to_dict

A description of the serialization process and the parameters to this function

Notes

This function tries to use the YAML (de)serialization module to load the YAML file in the order listed in YAML_MODULE_PRIORITIES, falling back on the next if there’s an ImportError