autora.serializer
A submodule which handles importing supported serializers.
SupportedSerializer
Bases: str, Enum
Listing of allowed serializers.
Source code in temp_dir/core/src/autora/serializer/__init__.py
29 30 31 32 33 34 | |
dump_state(state_, path, dumper=default_serializer)
Write a State object to a path.
Source code in temp_dir/core/src/autora/serializer/__init__.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
load_serializer(serializer=default_serializer)
Load a serializer, returning an object which includes data on the file mode it expects (regular or binary).
Examples:
The default serializer is pickle:
>>> load_serializer()
LOADED_SERIALIZER(module=<module 'pickle' from '...'>, file_mode='b')
All supported serializers can be loaded explictly:
>>> p_ = load_serializer("pickle")
>>> p_
LOADED_SERIALIZER(module=<module 'pickle' from '...'>, file_mode='b')
>>> d_ = load_serializer("dill")
>>> d_
LOADED_SERIALIZER(module=<module 'dill' from '...'>, file_mode='b')
>>> y_ = load_serializer("yaml")
>>> y_
LOADED_SERIALIZER(module=<module 'autora.serializer.yaml_' from '...'>, file_mode='')
Note that the yaml serializer is a wrapped version of the pyyaml package,
which conforms to the same interface as pickle.
This function loads the modules lazily and caches them, and returns the same object if the same serializer is loaded more than once.
>>> p_ is load_serializer("pickle")
True
>>> d_ is load_serializer("dill")
True
>>> y_ is load_serializer("yaml")
True
The Serializer can be specified by the SerializersSupported enum:
>>> load_serializer(SupportedSerializer.pickle)
LOADED_SERIALIZER(module=<module 'pickle'...
>>> load_serializer(SupportedSerializer.dill)
LOADED_SERIALIZER(module=<module 'dill'...
>>> load_serializer(SupportedSerializer.yaml)
LOADED_SERIALIZER(module=<module 'autora.serializer.yaml_'...
Source code in temp_dir/core/src/autora/serializer/__init__.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
load_state(path, loader=default_serializer)
Load a State object from a path.
Source code in temp_dir/core/src/autora/serializer/__init__.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |