medcat.storage.serialisers ========================== .. py:module:: medcat.storage.serialisers Attributes ---------- .. autoapisummary:: medcat.storage.serialisers.DEFAULT_SCHEMA_FILE medcat.storage.serialisers.logger medcat.storage.serialisers.SER_TYPE_FILE medcat.storage.serialisers.MANUAL_SERIALISED_TAG medcat.storage.serialisers.MANUAL_SERIALISED_RE medcat.storage.serialisers._DEF_SER Exceptions ---------- .. autoapisummary:: medcat.storage.serialisers.IllegalSchemaException Classes ------- .. autoapisummary:: medcat.storage.serialisers.Serialisable medcat.storage.serialisers.ManualSerialisable medcat.storage.serialisers.RemappingUnpickler medcat.storage.serialisers.Serialiser medcat.storage.serialisers.AvailableSerialisers medcat.storage.serialisers.DillSerialiser Functions --------- .. autoapisummary:: medcat.storage.serialisers.get_all_serialisable_members medcat.storage.serialisers.load_schema medcat.storage.serialisers.save_schema medcat.storage.serialisers.fix_module_and_cls_name medcat.storage.serialisers.get_serialiser medcat.storage.serialisers.get_serialiser_type_from_folder medcat.storage.serialisers.get_serialiser_from_folder medcat.storage.serialisers.serialise medcat.storage.serialisers.deserialise Module Contents --------------- .. py:class:: Serialisable Bases: :py:obj:`Protocol` The base serialisable protocol. .. py:method:: get_strategy() Get the serialisation strategy. :Returns: **SerialisingStrategy** -- The strategy. .. py:method:: get_init_attrs() :classmethod: Get the names of the arguments needed for init upon deserialisation. :Returns: **list[str]** -- The list of init arguments' names. .. py:method:: ignore_attrs() :classmethod: Get the names of attributes not to serialise. :Returns: **list[str]** -- The attribute names that should not be serialised. .. py:method:: include_properties() :classmethod: .. py:attribute:: __slots__ :value: () .. py:attribute:: _is_protocol :value: True .. py:attribute:: _is_runtime_protocol :value: False .. py:method:: __init_subclass__(*args, **kwargs) :classmethod: .. py:method:: __class_getitem__(params) :classmethod: .. py:class:: ManualSerialisable Bases: :py:obj:`Serialisable`, :py:obj:`Protocol` The base serialisable protocol. .. py:method:: serialise_to(folder_path) Serialise to a folder. :param folder_path: The folder to serialise to. :type folder_path: str .. py:method:: deserialise_from(folder_path, **init_kwargs) :classmethod: Deserialise from a specifc path. The init keyword arguments are generally: - cnf: The config relevant to the components - tokenizer (BaseTokenizer): The base tokenizer for the model - cdb (CDB): The CDB for the model - vocab (Vocab): The Vocab for the model - model_load_path (Optional[str]): The model load path, but not the component load path :param folder_path: The path to deserialsie form. :type folder_path: str :Returns: **ManualSerialisable** -- The deserialised object. .. py:method:: get_strategy() Get the serialisation strategy. :Returns: **SerialisingStrategy** -- The strategy. .. py:method:: get_init_attrs() :classmethod: Get the names of the arguments needed for init upon deserialisation. :Returns: **list[str]** -- The list of init arguments' names. .. py:method:: ignore_attrs() :classmethod: Get the names of attributes not to serialise. :Returns: **list[str]** -- The attribute names that should not be serialised. .. py:method:: include_properties() :classmethod: .. py:attribute:: __slots__ :value: () .. py:attribute:: _is_protocol :value: True .. py:attribute:: _is_runtime_protocol :value: False .. py:method:: __init_subclass__(*args, **kwargs) :classmethod: .. py:method:: __class_getitem__(params) :classmethod: .. py:function:: get_all_serialisable_members(object) Gets all serialisable members of an object. This looks for public and protected members, but not private ones. It should also be able to return parts of lists and tuples. It also provides the name of each serialisable object. :param object: The target object. :type object: Any :Returns: **tuple[list[tuple[Serialisable, str]], dict[str, Any]]** -- list of serialisable objects along with their names .. py:function:: load_schema(file_name) Loads the schema for a folder of deserialisable files from the file. :param file_name: The schema file :type file_name: str :Returns: **tuple[str, list[str]]** -- The class package/name along with the parts needed for initialising. .. py:function:: save_schema(file_name, cls, init_parts) Saves the schema of a class to the specified file. :param file_name: The file to save to. :type file_name: str :param cls: The class in question :type cls: Type :param init_parts list[str]: The parts of the . .. py:data:: DEFAULT_SCHEMA_FILE :value: '.schema.json' .. py:exception:: IllegalSchemaException(*args) Bases: :py:obj:`ValueError` Inappropriate argument value (of correct type). .. py:method:: __init__(*args) Initialize self. See help(type(self)) for accurate signature. .. py:class:: __cause__ exception cause .. py:class:: __context__ exception context .. py:method:: __delattr__() Implement delattr(self, name). .. py:method:: __dir__() Default dir() implementation. .. py:method:: __eq__() Return self==value. .. py:method:: __format__() Default object formatter. .. py:method:: __ge__() Return self>=value. .. py:method:: __getattribute__() Return getattr(self, name). .. py:method:: __gt__() Return self>value. .. py:method:: __hash__() Return hash(self). .. py:method:: __le__() Return self<=value. .. py:method:: __lt__() Return self=value. .. py:method:: __getattribute__() Return getattr(self, name). .. py:method:: __gt__() Return self>value. .. py:method:: __hash__() Return hash(self). .. py:method:: __le__() Return self<=value. .. py:method:: __lt__() Return self