Skip to main content

anystore on pypi Python test and package pre-commit Coverage Status GPL-3.0 License

anystore

Store anything anywhere. A wrapper around wrappers to avoid boilerplate code (because we are lazy).

anystore helps you to transfer data from and to a various range of sources (local filesystem, http, s3, redis, sql, ...) with a unified high-level interface. It's main use case is to store data pipeline outcomes in a distributed cache, so that different programs or coworkers can access intermediate results based on different settings (e.g. testing: use local cache store, production: cache to s3 bucket)

Why?

In our several data engineering projects we always wrote boilerplate code that handles the featureset of anystore but not in a reusable way.

This library shall be a thin and stable foundation for data wrangling related python programs.

Overview

anystore is built on top of fsspec and provides an easy wrapper for reading and writing content from and to arbitrary locations:

command line

anystore -i ./local/foo.txt -o s3://mybucket/other.txt

echo "hello" | anystore -o sftp://user:password@host:/tmp/world.txt

anystore -i https://investigativedata.io > index.html

python

from anystore.io import smart_read, smart_write

data = smart_read("s3://mybucket/data.txt")
smart_write(".local/data", data)

Simple key/value store

anystore can use a configurable store:

command line

anystore --store .cache put foo "bar"

anystore --store .cache get foo
# "bar"

python

from anystore import Store

# pass through `fsspec` configuration for specific storage backend:
store = Store(uri="s3://mybucket/data", backend_config={"client_kwargs":{
    "aws_access_key_id": "my-key",
    "aws_secret_access_key": "***",
    "endpoint_url": "https://s3.local"
}})

store.get("/2023/1.txt")
store.put("/2023/2.txt", my_data)

Decorate your functions

When working on scripts, one sometimes wants just a simple cache setup. Maybe it should be persistent, maybe even somewhere in the cloud so that another coworker can take over. Maybe we want a different storage during testing our scripts... everything easily handled by anystore:

from anystore import anycache

# use decorator
@anycache(uri="s3://mybucket/cache")
def download_file(url):
    # a very time consuming task
    return result

# 1. time: slow
res = download_file("https://example.com/foo.txt")

# 2. time: fast, as now cached
res = download_file("https://example.com/foo.txt")

Install

pip install anystore

development

This package is using poetry for packaging and dependencies management, so first install it.

Clone this repository to a local destination.

Within the root directory, run

poetry install --with dev

This installs a few development dependencies, including pre-commit which needs to be registered:

poetry run pre-commit install

Before creating a commit, this checks for correct code formatting (isort, black) and some other useful stuff (see: .pre-commit-config.yaml)

test

make test

Download files

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

Source Distribution

anystore-0.1.0.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

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

anystore-0.1.0-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file anystore-0.1.0.tar.gz.

File metadata

  • Download URL: anystore-0.1.0.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.8 Linux/6.6.15-amd64

File hashes

Hashes for anystore-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b5787df7b21f68535c81ab90d8265932e19a4dd7b27d9a59300b138a8fd2037b
MD5 a4aae11707cf5e186438ea21f8489f18
BLAKE2b-256 1bf22a4eccf2e7e335ba0b77bb2034810dd80d46dc694f4835a602f8a72bb76c

See more details on using hashes here.

File details

Details for the file anystore-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: anystore-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.8 Linux/6.6.15-amd64

File hashes

Hashes for anystore-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ffb88a727e9053c9f43667f90692058ab290ae44c859f334f05258bfb911a8f
MD5 6bfe985481cef7c8a876f071ef612cf1
BLAKE2b-256 3c59fa6041dbf010c9f7e65b6fdbf14c91c2b86d5a9a05ad417393766addcdf5

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 Sentry Error logging StatusPage Status page