climate_ref_core.serialisation
#
JSON wire format for the objects that cross a process boundary.
An executor may run a diagnostic in another process or on another node, which means the execution definition and its result have to be encoded.
JSON cannot represent everything these objects hold,
and values with no JSON equivalent are written as tagged objects carrying a __ref_type__ key.
The types that need this are paths, cftime dates and the pandas frame of selected datasets.
TAG = '__ref_type__'
module-attribute
#
Key marking an object as a tagged value rather than a plain mapping.
from_wire(value)
#
Rebuild a value encoded by to_wire
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
JSON structure to decode. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the structure carries a tag this version does not understand. |
Returns:
| Type | Description |
|---|---|
Any
|
The decoded value. |
Source code in packages/climate-ref-core/src/climate_ref_core/serialisation.py
to_wire(value)
#
Convert a value into its JSON representation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Value to encode. Containers are walked recursively. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the value has no JSON representation. |
Returns:
| Type | Description |
|---|---|
Any
|
A structure built only from types that |