safestructures
What is safestructures?
safestructures is a Python package based on safetensors to serialize general data structures. It uses safetensors to store tensors and uses its metadata to store the schema of the original data structure as well as other basic data types.
safetensors can be more preferred than pickle when saving tensors, especially for safety reasons. See huggingface/safetensors for more details.
safetensors only stores tensors. safestructures extends safetensors by storing information of the original data structure containing tensors as well as other data types. It utilizes a plugin architecture so that projects that contain custom types can serialize and deserialize their custom data.
Why safestructures?
ML models in practice deal with more than just tensors. Tensors can be passed between layers or outputted using data containers. Other data types are used as well to modify layer behavior.
To have better reproducibility and tracking, we may need to store and load model inputs and outputs, as well as intermediate layer inputs and output in a safe manner. safetensors greatly helps on the tensor side, while safestructures helps with the rest.
Installation and requirements
safestructures requires Python 3.10 and above.
To install, simply run
pip install safestructures
This will also install the minimum dependencies, namely safetensors and numpy.
As for ML / tensor frameworks, safestructures expects numpy at minimum. To use safestructures's PyTorch, TensorFlow, and JAX capabilities, the respective framework must be installed separately.
Usage and plugins
See the usage and plugins guide readmes, or refer to the docs
Support
Currently, safestructures supports out of the box:
- All of Python's built-in data containers and data types.
dataclasses.dataclassobjects.- PyTorch tensors via
safetensors. - TensorFlow 2 tensors via
safetensors. - JAX tensors via
safetensors.
For maximum compatibility with NumPy, all float tensors are stored in FP32.
safestructures aims to cover the same frameworks as safetensors, but for initial release it does not support:
collections- Please comment on this issue to request support.- PaddlePaddle - Please comment on this issue to request support.
- MLX - Please comment on this issue to request support.
However, safestructures supports plugins in case there is a type it does not support.
Metadata
Release files for safestructures 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| safestructures-1.0.0.tar.gz | 27.7 kB | Without provenance | Details for safestructures-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| safestructures-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for safestructures-1.0.0-py3-none-any.whl |
Total release size: 48.0 kB
Release files / safestructures-1.0.0.tar.gz
| Download URL | safestructures-1.0.0.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da6d5e5f6004800d7a475ca005dc78c63fa8d7fc602ec22c1a62cf664910ddf0
|
|
BLAKE2b-256 checksum How to use checksums |
31c93f6820a82ca807009a620d021837237d509a4dacd604c5252573454a8634
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / safestructures-1.0.0-py3-none-any.whl
| Download URL | safestructures-1.0.0-py3-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cfbe357602a997f97cf79d7e9138c2625efad08e7c2a3218192c0d989fbc4d83
|
|
BLAKE2b-256 checksum How to use checksums |
2eb3f6bc453d10dc015c6c0ec623526a15ffdecb395ce104d63d571fc19e95d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Security for safestructures 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.