DataStack
a stream-based file storage solution for machine learning datasets.
Today, machine learning datasets are abundantly availabe on the internet, while coming in a variety of formats( e.g., pandas dataframes, CSV files, numpy arrays, excel sheets, h5py and many more), which makes generic dataset processing complex. Luckily, almost all recent libraries provide a file-like interface for loading and storing datasets as binary streams, which is also the common ground DataStack builds upon. In DataStack datasets are stored as plain binary streams and loaded via custom iterator implementations specific for each file type. Thereby, the storage itself is completely independent from the file-type. The binary streams can be even lazyily loaded, given that the iterator supports it. The H5Py file format for instance supports this out of the box.
Another important feature of DataStack is its ability to stack iterators. Having a dataset iterator as the foundation, custom higher level iterators like iterator views that allow for arbitrary dataset splits and combined iterators that join dataset splits, can be stacked on top. Higher order iterators in other research projects adopting DataStack already comprise more sophisticated iterators like feature encoding iterators and target class mapping iterators.
So how does DataStack fit into the machine learning engineering work flow? While access to training data is not a limit anymore, integrating datasets into machine learning work flows still requires time-consuming manual preparation. Switching from one project or research paper to another, machine learning engineers and researchers often start from scratch integrating the same datasets over and over again. DataStack offers a solution for integrating these datasets by providing stable interfaces for data access that machine learning algorithms can work against. Having those interfaces in place, allows to reuse datasets and replicate results more easily.
DataStack offers the following key modules:
-
Dataset Retrieval: Datasets can be retrieved via the
HTTPRetriever. If a custom retriever is needed, e.g., for a custom database, only the Retriever interface needs to be implemented. -
Dataset Storage: DataStack comes with a
FileStorageConnectorfor storing and loading datasets from disk using a predefined dataset identifier. By implementing theStorageConnectorinterface, any other custom storage solution, e.g. a MongoDB, can be supported. Notably, every dataset is stored as aStreamedResource, which is a wrapper around the Python's IOBase. Therefore, the respectiveDatasetStoragedoes not require any knowledge of the encoded data. This is why, the storage is not limited to any specific file-type. Additionally, when accessing the file storage, only a file descriptor to that file is created, offering lazy loading for iterators. -
Iterator: Datastack provides an iterator interface and a few implementations to iterate through datasets. An iterator takes a
StreamedResourcecontaining a binarized dataset and provides an iteration routine, customized to to the original filetype of the dataset. For instance, a binary Pytorch Tensor stream needs a different iteration implemenation than a CSV stream. Note, that theStreamedResourceonly provides a file descriptor to the stream. If this stream is stored on disk, theStreamedResourcedoes not automatically load the stream into memory. This gives the opportunity to lazily load samples with e.g., h5py file streams.
Install
There are two options to install DataStack, the easiest way is to install it from the pip repository:
pip install datastack
For the latest version, one can directly install it from source by cd into the root folder and then running
pip install src/
Usage
NOTE: This library is still under heavy development. It's most likely not free of bugs and interfaces can still change.
To implement a new dataset, one has to implement 3 classes:
- DatasetFactory: Retrieves, prepares, stores and loads the dataset using a
RetrieverandPreprocessorimplementation and aStorageConnector. - Preprocessing: Datasets often come compressed, split up over many files or in who knows what structure. Therefore, for each dataset we need a Preprocessing class that transforms the datasets into a
StreamedResource. - Iterator: Provides the iteration implementation on top of the binary stream
StreamedResource
DataStack provides a examplary MNIST implementation.
Copyright
Copyright (c) 2020 Max Lübbering For license see: https://github.com/le1nux/datastack/blob/master/LICENSE
Metadata
Release files for datastack 0.0.13
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 | |
|---|---|---|---|---|
| datastack-0.0.13.tar.gz | 15.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| datastack-0.0.13-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.7 kB
Release files / datastack-0.0.13.tar.gz
| Download URL | datastack-0.0.13.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d52d832b64d64e5fec965769f0ca141d143e948a7c9f268338a80b305ce934a
|
|
BLAKE2b-256 checksum How to use checksums |
acdcdc2098c3fe36de90244167e041a9184aaa07a3338985023828ff7073d1e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / datastack-0.0.13-py3-none-any.whl
| Download URL | datastack-0.0.13-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a35fde800bc87de0df19845cbb133f22bd03152954270b16f08fdc82373787d8
|
|
BLAKE2b-256 checksum How to use checksums |
4332f80ff5cdd207b8184b3f19d6a0ba6b1f8b3b6979aead5705f47a16f0aa17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Security for datastack 0.0.13
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.