declearn.utils.serialize_object
Return a ObjectConfig serialization of an object.
This function is the counterpart to declearn.utils.deserialize_object
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
SupportsConfig
|
Object that needs serialization. To be valid, the object must:
- implement the |
required |
group |
Optional[str]
|
Optional name of the group under which the object's type was registered. If None, the type will be looked for in each and every exiting group, and the first match will be used. |
None
|
allow_unregistered |
bool
|
Whether to allow serializing objects that do not belong to a
registered type. If true, a mapping between the type's name
and its class will need to be passed as part of |
False
|
Returns:
Name | Type | Description |
---|---|---|
config |
ObjectConfig
|
A JSON-serializable dataclass wrapper containing all required information to recreate the object, e.g. from a config file. |
Raises:
Type | Description |
---|---|
KeyError
|
If |
Source code in declearn/utils/_serialize.py
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|