jsoncache
Python cache control for cloud storage models
This library exposes a multithreaded JSON object loader that support Amazon S3 and Google Cloud Storage.
Why do I care?
Because loading JSON files from the cloud is more annoying than you realize.
- Sometimes you're gonna get errors - log those errors.
- Sometimes you're going to have compressed JSON blobs because Google Cloud Storage has unmanageable timeouts for uploads (https://github.com/googleapis/python-storage/issues/74)
- You want your application to behave as if read errors from the cloud weren't a problem, but you want those errors to show up in logging.
Quick Start
- Import the ThreadedObjectCache class.
- Instantiate it passing in the cloud type, bucket, path and time to live in seconds.
- Call
.get()on the ThreadedObjectCache instace.
You can optionally pass in a custom implementation of the time
module to override how time.time() works.
You can optionally pass in a custom callable transformer that will
apply the transformer function to the data before it's returned.
Typical use cases might involve initializing a sklearn model.
You can optionally pass in block_until_cached=True so that the
constructor will block until a model is loaded successfully from the
network.
All background threads are marked as daemon threads so using this code won't cause your application to wait for thread death.
Python 3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:37:09)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.17.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from jsoncache import *
In [2]: t = ThreadedObjectCache('s3', 'telemetry-parquet', 'taar/similarity/lr_curves.json', 10)
In [3]: 2020-08-05 16:07:14,369 - botocore.credentials - INFO - Found credentials in environment variables.
In [3]:
In [3]: t.get()
Out[3]:
[[0.0, [0.029045735469752962, 0.02468400347868071]],
[0.005000778819764661, [0.029530930135620918, 0.025088940785616222]],
...
Metadata
Release files for mozilla-jsoncache 0.1.7
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 | |
|---|---|---|---|---|
| mozilla-jsoncache-0.1.7.tar.gz | 7.9 kB | Without provenance | Details |
Release files / mozilla-jsoncache-0.1.7.tar.gz
| Download URL | mozilla-jsoncache-0.1.7.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7ec7dfdb43ed0bb7312bed414199a8265ffdbc355ab7ee5248645a267931b98
|
|
BLAKE2b-256 checksum How to use checksums |
727a881640be10888832826c1ff08ce736742f6ac78d0aa3eaeb3b545f9f26f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1.post20200802 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8
|
Security for mozilla-jsoncache 0.1.7
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.