serialzy


Nameserialzy JSON
Version 1.5.2 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-04-15 18:42:55
maintainerNone
docs_urlNone
authorʎzy developers
requires_python>=3.7
licenseLICENSE
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Pypi version](https://img.shields.io/pypi/v/serialzy)](https://pypi.org/project/serialzy/)
[![Tests](https://github.com/lambdazy/serialzy/actions/workflows/tests.yaml/badge.svg)](https://github.com/lambda-zy/lzy/actions/workflows/tests.yaml)
[![Python tests coverage](https://gist.githubusercontent.com/mrMakaronka/74a3e00f914bb55c0f3582a7d48e3bcd/raw/main-coverage.svg)](https://github.com/lambdazy/lzy/tree/master/pylzy/tests)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/serialzy.svg)](https://pypi.org/project/serialzy/)

# serialzy

Serialzy is a library for python objects serialization into portable and interoperable data formats (if possible).

### Example

Suppose you have a catboost model:

```python
from catboost import CatBoostClassifier

model = CatBoostClassifier()
model.fit(...)
```

Firstly you should find a proper serializer for the catboost model type or the corresponding data format:

```python
from serialzy.registry import DefaultSerializerRegistry

registry = DefaultSerializerRegistry()
serializer = registry.find_serializer_by_type(type(model)) # registry.find_serializer_by_data_format("cbm")
```

Serializers have several properties:

```python
serializer.available()      # can be used in the current environment
serializer.requirements()   # libraries needed to be installed to use this serializer
serializer.stable()         # has portable data format
```

Serializers can provide data format and schema for a type:

```python
serializer.data_format()
serializer.schema(type(model))
```

Serialization:

```python
with open('model.cbm', 'wb') as file:
    serializer.serialize(model, file)
```

Deserialization:

```python
with open('result', 'rb') as file:
    deserialized_obj = serializer.deserialize(file)
```

### List of supported libraries for stable serialization:

| Library                                     | Types                                                                                                                                                                                                                                                                                                                | Data format                                                                                                   | 
|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| Python std lib                              | int, str, float, bool, None                                                                                                                                                                                                                                                                                          | [string representation](https://github.com/lambdazy/serialzy/blob/main/serialzy/serializers/primitive.py)     |
| Python std lib                              | List, Tuple                                                                                                                                                                                                                                                                                                          | [custom format](https://github.com/lambdazy/serialzy/blob/main/serialzy/serializers/sequence.py)              |
| [CatBoost](https://catboost.ai)             | [CatBoostRegressor](https://catboost.ai/en/docs/concepts/python-reference_catboostregressor), [CatBoostClassifier](https://catboost.ai/en/docs/concepts/python-reference_catboostclassifier), [CatBoostRanker](https://catboost.ai/en/docs/concepts/python-reference_catboostranker)                                 | [cbm](https://catboost.ai/en/docs/concepts/python-reference_catboost_save_model)                              |
| [CatBoost](https://catboost.ai)             | [Pool](https://catboost.ai/en/docs/concepts/python-reference_pool)                                                                                                                                                                                                                                                   | [quantized pool](https://catboost.ai/en/docs/concepts/python-reference_pool_save)                             |
| [Tensorflow.Keras](https://keras.io)        | [Sequential](https://keras.io/guides/sequential_model/), [Model](https://keras.io/api/models/model/) with subclasses                                                                                                                                                                                                 | [tf_keras](https://keras.io/api/models/model_saving_apis/)                                                    |
| [Tensorflow](https://www.tensorflow.org)    | [Checkpoint](https://www.tensorflow.org/api_docs/python/tf/train/Checkpoint), [Module](https://www.tensorflow.org/api_docs/python/tf/Module) with subclasses                                                                                                                                                         | [tf_pure](https://www.tensorflow.org/api_docs/python/tf/saved_model)                                          |
| [LightGBM](https://lightgbm.readthedocs.io) | [LGBMClassifier](https://lightgbm.readthedocs.io/en/v3.3.2/pythonapi/lightgbm.LGBMClassifier.html), [LGBMRegressor](https://lightgbm.readthedocs.io/en/v3.3.2/pythonapi/lightgbm.LGBMRegressor.html), [LGBMRanker](https://lightgbm.readthedocs.io/en/v3.3.2/pythonapi/lightgbm.LGBMRanker.html)                     | [lgbm](https://lightgbm.readthedocs.io/en/v3.3.2/pythonapi/lightgbm.Booster.html#lightgbm.Booster.save_model) |
| [XGBoost](https://lightgbm.readthedocs.io)  | [XGBClassifier](https://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn), [XGBRegressor](https://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn), [XGBRanker](https://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn) | [xgb](https://xgboost.readthedocs.io/en/latest/python/python_intro.html#training)                             |
| [Torch](https://pytorch.org)                | [Module](https://pytorch.org/docs/stable/notes/modules.html) with subclasses                                                                                                                                                                                                                                         | [pt](https://pytorch.org/docs/stable/generated/torch.jit.save.html#torch.jit.save)                            |
| [ONNX](https://onnx.ai/)                    | [ModelProto](https://onnx.ai/onnx/api/classes.html#onnx.ModelProto)                                                                                                                                                                                                                                                  | [onnx](https://github.com/onnx/onnx/blob/main/docs/PythonAPIOverview.md)                                      |

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "serialzy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "\u028ezy developers",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/ca/1a/aeee7b3da43d309c3beb7534a7f74d2af09539709110e5229058a80797ac/serialzy-1.5.2.tar.gz",
    "platform": null,
    "description": "[![Pypi version](https://img.shields.io/pypi/v/serialzy)](https://pypi.org/project/serialzy/)\n[![Tests](https://github.com/lambdazy/serialzy/actions/workflows/tests.yaml/badge.svg)](https://github.com/lambda-zy/lzy/actions/workflows/tests.yaml)\n[![Python tests coverage](https://gist.githubusercontent.com/mrMakaronka/74a3e00f914bb55c0f3582a7d48e3bcd/raw/main-coverage.svg)](https://github.com/lambdazy/lzy/tree/master/pylzy/tests)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/serialzy.svg)](https://pypi.org/project/serialzy/)\n\n# serialzy\n\nSerialzy is a library for python objects serialization into portable and interoperable data formats (if possible).\n\n### Example\n\nSuppose you have a catboost model:\n\n```python\nfrom catboost import CatBoostClassifier\n\nmodel = CatBoostClassifier()\nmodel.fit(...)\n```\n\nFirstly you should find a proper serializer for the catboost model type or the corresponding data format:\n\n```python\nfrom serialzy.registry import DefaultSerializerRegistry\n\nregistry = DefaultSerializerRegistry()\nserializer = registry.find_serializer_by_type(type(model)) # registry.find_serializer_by_data_format(\"cbm\")\n```\n\nSerializers have several properties:\n\n```python\nserializer.available()      # can be used in the current environment\nserializer.requirements()   # libraries needed to be installed to use this serializer\nserializer.stable()         # has portable data format\n```\n\nSerializers can provide data format and schema for a type:\n\n```python\nserializer.data_format()\nserializer.schema(type(model))\n```\n\nSerialization:\n\n```python\nwith open('model.cbm', 'wb') as file:\n    serializer.serialize(model, file)\n```\n\nDeserialization:\n\n```python\nwith open('result', 'rb') as file:\n    deserialized_obj = serializer.deserialize(file)\n```\n\n### List of supported libraries for stable serialization:\n\n| Library                                     | Types                                                                                                                                                                                                                                                                                                                | Data format                                                                                                   | \n|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|\n| Python std lib                              | int, str, float, bool, None                                                                                                                                                                                                                                                                                          | [string representation](https://github.com/lambdazy/serialzy/blob/main/serialzy/serializers/primitive.py)     |\n| Python std lib                              | List, Tuple                                                                                                                                                                                                                                                                                                          | [custom format](https://github.com/lambdazy/serialzy/blob/main/serialzy/serializers/sequence.py)              |\n| [CatBoost](https://catboost.ai)             | [CatBoostRegressor](https://catboost.ai/en/docs/concepts/python-reference_catboostregressor), [CatBoostClassifier](https://catboost.ai/en/docs/concepts/python-reference_catboostclassifier), [CatBoostRanker](https://catboost.ai/en/docs/concepts/python-reference_catboostranker)                                 | [cbm](https://catboost.ai/en/docs/concepts/python-reference_catboost_save_model)                              |\n| [CatBoost](https://catboost.ai)             | [Pool](https://catboost.ai/en/docs/concepts/python-reference_pool)                                                                                                                                                                                                                                                   | [quantized pool](https://catboost.ai/en/docs/concepts/python-reference_pool_save)                             |\n| [Tensorflow.Keras](https://keras.io)        | [Sequential](https://keras.io/guides/sequential_model/), [Model](https://keras.io/api/models/model/) with subclasses                                                                                                                                                                                                 | [tf_keras](https://keras.io/api/models/model_saving_apis/)                                                    |\n| [Tensorflow](https://www.tensorflow.org)    | [Checkpoint](https://www.tensorflow.org/api_docs/python/tf/train/Checkpoint), [Module](https://www.tensorflow.org/api_docs/python/tf/Module) with subclasses                                                                                                                                                         | [tf_pure](https://www.tensorflow.org/api_docs/python/tf/saved_model)                                          |\n| [LightGBM](https://lightgbm.readthedocs.io) | [LGBMClassifier](https://lightgbm.readthedocs.io/en/v3.3.2/pythonapi/lightgbm.LGBMClassifier.html), [LGBMRegressor](https://lightgbm.readthedocs.io/en/v3.3.2/pythonapi/lightgbm.LGBMRegressor.html), [LGBMRanker](https://lightgbm.readthedocs.io/en/v3.3.2/pythonapi/lightgbm.LGBMRanker.html)                     | [lgbm](https://lightgbm.readthedocs.io/en/v3.3.2/pythonapi/lightgbm.Booster.html#lightgbm.Booster.save_model) |\n| [XGBoost](https://lightgbm.readthedocs.io)  | [XGBClassifier](https://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn), [XGBRegressor](https://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn), [XGBRanker](https://xgboost.readthedocs.io/en/latest/python/python_api.html#module-xgboost.sklearn) | [xgb](https://xgboost.readthedocs.io/en/latest/python/python_intro.html#training)                             |\n| [Torch](https://pytorch.org)                | [Module](https://pytorch.org/docs/stable/notes/modules.html) with subclasses                                                                                                                                                                                                                                         | [pt](https://pytorch.org/docs/stable/generated/torch.jit.save.html#torch.jit.save)                            |\n| [ONNX](https://onnx.ai/)                    | [ModelProto](https://onnx.ai/onnx/api/classes.html#onnx.ModelProto)                                                                                                                                                                                                                                                  | [onnx](https://github.com/onnx/onnx/blob/main/docs/PythonAPIOverview.md)                                      |\n",
    "bugtrack_url": null,
    "license": "LICENSE",
    "summary": null,
    "version": "1.5.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "20eef33a6406916fa7b8b4a202045790d476226b5dcb73941edd8c7c9e72fb6d",
                "md5": "7a63a5e486a7b8afa86782af73f2e003",
                "sha256": "c89bfbbeeb7b71dbdbafd94d3ae6b8318e19d3dacc1b9f250e8946c8af28f4a5"
            },
            "downloads": -1,
            "filename": "serialzy-1.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7a63a5e486a7b8afa86782af73f2e003",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 28092,
            "upload_time": "2024-04-15T18:42:52",
            "upload_time_iso_8601": "2024-04-15T18:42:52.785683Z",
            "url": "https://files.pythonhosted.org/packages/20/ee/f33a6406916fa7b8b4a202045790d476226b5dcb73941edd8c7c9e72fb6d/serialzy-1.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca1aaeee7b3da43d309c3beb7534a7f74d2af09539709110e5229058a80797ac",
                "md5": "60454508394b4762adc061bec4a6e0d2",
                "sha256": "6f927b238f0765d95124f2ba526cdb6fcb3ec9c5cff93ccdd29b3ec229857df6"
            },
            "downloads": -1,
            "filename": "serialzy-1.5.2.tar.gz",
            "has_sig": false,
            "md5_digest": "60454508394b4762adc061bec4a6e0d2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 19045,
            "upload_time": "2024-04-15T18:42:55",
            "upload_time_iso_8601": "2024-04-15T18:42:55.161699Z",
            "url": "https://files.pythonhosted.org/packages/ca/1a/aeee7b3da43d309c3beb7534a7f74d2af09539709110e5229058a80797ac/serialzy-1.5.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-15 18:42:55",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "serialzy"
}
        
Elapsed time: 0.32811s