Coretex
coretex.codable.codable.Codable Class Reference
Inheritance diagram for coretex.codable.codable.Codable:
coretex.entities.annotation.image.bbox.BBox coretex.entities.annotation.image.classes_format.ImageDatasetClass coretex.entities.annotation.image.coretex_format.CoretexImageAnnotation coretex.entities.annotation.image.coretex_format.CoretexSegmentationInstance coretex.entities.task_run.artifact.Artifact coretex.networking.network_object.NetworkObject coretex.entities.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 30 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 239 of file codable.py.

239  def decode(cls, encodedObject: Dict[str, Any]) -> Self:
240  """
241  Decodes the json object into a python object
242 
243  Parameters
244  ----------
245  encodedObject : Dict[str, Any]
246  json encoded object
247 
248  Returns
249  -------
250  Self -> Decoded python object
251  """
252  obj = cls()
253 
254  obj._updateFields(encodedObject)
255  obj.onDecode()
256 
257  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 123 of file codable.py.

123  def encode(self) -> Dict[str, Any]:
124  """
125  Encodes python object into dictionary which contains
126  only values representable by standard python library/types
127 
128  Returns
129  -------
130  Dict[str, Any] -> encoded object which can be serialized into json string
131  """
132 
133  encodedObject: Dict[str, Any] = {}
134 
135  for key, value in self.__dict__.items():
136  descriptor = self.__class__.__keyDescriptorByPythonName(key)
137 
138  # skip ignored fields for encoding
139  if descriptor is not None and not descriptor.isEncodable:
140  # print(f">> [Coretex] Skipping encoding for field: {key}")
141  continue
142 
143  encodedKey = self.__encodeKey(key)
144  encodedValue = self._encodeValue(key, value)
145 
146  encodedObject[encodedKey] = encodedValue
147 
148  return encodedObject
149 

◆ onDecode()

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

Definition at line 231 of file codable.py.

231  def onDecode(self) -> None:
232  """
233  Callback which is called once the object has been decoded
234  """
235 
236  pass
237 

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