Coretex
coretex.codable.codable.Codable Class Reference
Inheritance diagram for coretex.codable.codable.Codable:
coretex.coretex.annotation.image.bbox.BBox coretex.coretex.annotation.image.classes_format.ImageDatasetClass coretex.coretex.annotation.image.coretex_format.CoretexImageAnnotation coretex.coretex.annotation.image.coretex_format.CoretexSegmentationInstance coretex.coretex.experiment.artifact.Artifact coretex.logging.log.Log coretex.networking.network_object.NetworkObject coretex.coretex.annotation.image.classes_format.ImageDatasetClasses

Public Member Functions

Dict[str, Any] encode (self)
 
None onDecode (self)
 
Self decode (cls, Dict[str, Any] encodedObject)
 

Detailed Description

    Class whose subclasses can be serialized/deserialized into/from a JSON format object

Definition at line 54 of file codable.py.

Member Function Documentation

◆ decode()

Self coretex.codable.codable.Codable.decode (   cls,
Dict[str, Any]  encodedObject 
)
    Decodes the json object into a python object

    Parameters
    ----------
    encodedObject : Dict[str, Any]
json encoded object

    Returns
    -------
    Self -> Decoded python object

Definition at line 263 of file codable.py.

263  def decode(cls, encodedObject: Dict[str, Any]) -> Self:
264  """
265  Decodes the json object into a python object
266 
267  Parameters
268  ----------
269  encodedObject : Dict[str, Any]
270  json encoded object
271 
272  Returns
273  -------
274  Self -> Decoded python object
275  """
276  obj = cls()
277 
278  obj._updateFields(encodedObject)
279  obj.onDecode()
280 
281  return obj

◆ encode()

Dict[str, Any] coretex.codable.codable.Codable.encode (   self)
    Encodes python object into dictionary which contains
    only values representable by standard python library/types

    Returns
    -------
    Dict[str, Any] -> encoded object which can be serialized into json string

Definition at line 147 of file codable.py.

147  def encode(self) -> Dict[str, Any]:
148  """
149  Encodes python object into dictionary which contains
150  only values representable by standard python library/types
151 
152  Returns
153  -------
154  Dict[str, Any] -> encoded object which can be serialized into json string
155  """
156 
157  encodedObject: Dict[str, Any] = {}
158 
159  for key, value in self.__dict__.items():
160  descriptor = self.__class__.__keyDescriptorByPythonName(key)
161 
162  # skip ignored fields for encoding
163  if descriptor is not None and not descriptor.isEncodable:
164  # print(f">> [Coretex] Skipping encoding for field: {key}")
165  continue
166 
167  encodedKey = self.__encodeKey(key)
168  encodedValue = self._encodeValue(key, value)
169 
170  encodedObject[encodedKey] = encodedValue
171 
172  return encodedObject
173 

◆ onDecode()

None coretex.codable.codable.Codable.onDecode (   self)
    Callback which is called once the object has been decoded

Definition at line 255 of file codable.py.

255  def onDecode(self) -> None:
256  """
257  Callback which is called once the object has been decoded
258  """
259 
260  pass
261 

The documentation for this class was generated from the following file: