Skip to main content

SciSave - Serialization for Scientific Data

Project description

SciSave - Serialization for Scientific Data

Summary

SciSave is a Python serialization/deserialization module:

  • Specially targeted for scientific applications.
  • Load and write JSON/MessagePack/Pickle data files.
  • Load JSON/YAML configuration files.
  • Validate data with JSON schemas.

For YAML files, the following custom extensions are used:

  • Parse relative paths with respect to the YAML file (!path).
  • Include other YAML files into the YAML file (!include).
  • Evaluate a Python literal using literal_eval (!eval).
  • Substitute YAML strings with values from environment variables (!env).
  • Substitute YAML strings with values from a provided dictionary (!sub).
  • Merge a list of dicts (!merge_dict).
  • Merge a list of lists (!merge_list).

For JSON files, the following custom extensions are used:

  • Allows the serialization/deserialization of complex numbers (__complex__).
  • Allows the serialization/deserialization of NumPy arrays (__numpy__).
  • Allows the serialization/deserialization as/from text and gzip files

For MessagePack files, the following custom extensions are used:

  • Allows the serialization/deserialization of complex numbers (__complex__).
  • Allows the serialization/deserialization of NumPy arrays (__numpy__).

For JSON schemas, the following custom extensions are used:

  • Handling NumPy types (integer, floating, and complex).
  • Handling NumPy multidimensional arrays.

The following file extensions are used:

  • .yaml, .yml - for YAML files
  • .json, .js - for JSON text files
  • .gz, .gzip - for JSON gzip files
  • .mpk, .msg", .msgpack - for MessagePack files
  • .pck, .pkl, .pickle - for Pickle files

The JSON/YAML/MessagePack files with the custom extensions are still valid files. Pickle/MessagePack is typically faster than JSON for very large data files.

SciSave is written in Python (NumPy, PyYAML, msgpack, and jsonschema are the only dependencies). SciSave is respecting semantic versioning (starting from version 1.4).

Warning

  • Pickling data is not secure.
  • Only load pickle files that you trust.

Example

An example is located in the example folder of the repository:

  • run_data.py contains an example file for the loader/dumper
  • run_bench.py contains a simple benchmark for the different formats
  • config_main.yaml YAML configuration file with custom extensions
  • config_include.yaml YAML configuration file for include extension
  • config_schema.yaml YAML file containing the JSON schema definition
  • dump.json JSON text file for testing data dumping/loading
  • dump.gz JSON gzip file for testing data dumping/loading
  • dump.pickle Pickle file for testing data dumping/loading

Project Links

Author

Copyright

(c) 2023 - Thomas Guillod

BSD 2-Clause "Simplified" License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scisave-1.6.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scisave-1.6.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file scisave-1.6.0.tar.gz.

File metadata

  • Download URL: scisave-1.6.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.11

File hashes

Hashes for scisave-1.6.0.tar.gz
Algorithm Hash digest
SHA256 cc417f1b4fbe27d343eca5698a7feee9328bc422f030f5ea3335d87852803983
MD5 f80e705cc87a7123d77ae42203d966a0
BLAKE2b-256 3d6a8752d8f04b817b476a553afe2267da14743e817bf60c5139d3309febf070

See more details on using hashes here.

File details

Details for the file scisave-1.6.0-py3-none-any.whl.

File metadata

  • Download URL: scisave-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.11

File hashes

Hashes for scisave-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb2b9a942ec8f356aee293cb9843383c5ceff04d3ec545a0f5efd2f0de0526af
MD5 c390cee8d013fb483888624d5ae2e013
BLAKE2b-256 a767e18d76c3325a2a609adec3cd5d4a17d7c344f3f4cd5f4f720bc64e2ef883

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page