Skip to main content

Storage tools

The goal of this project is to make it easy to work with local or cloud storage as part of a data science workflow.

Key Features

You can access a dataset with a single command ...

e.g. download_dataset azure_demo mnist/hand_drawn_digits

... or a few lines of python

Just import the storage tools core module, create a client and download your dataset.

You don't put secret keys in your code

Secret keys live in their own files and storage tools knows how to find them.

Datasets are version controlled

Storage tools makes it easy to

  • manage multiple versions of a dataset and
  • know which version of the dataset you are working with locally.

Install

pip install storage_tools

Storage tools conventions

We recommend that you ...

Use forward slashes on all platforms

Use forward slashes when specifying files, paths and dataset names.

Avoid whitespace and special characters in file and path names

Use folders for secrets and data

project_root
  ∟ data
  ∟ secrets
    ∟ settings.ini

Add the following to .gitignore

secrets/
data/

Add the following to settings.ini

[DEFAULT]
local_path=data

Running storage_client from your project root will read project_root/secrets/settings.ini and save all local data to project_root/data

How to use azure storage

If we follow the above conventions and have a project folder containing

project_root
  ∟ data
    ∟ mnist
      ∟ hand_drawn_digits
        ∟ digit0.png
        ∟ digit1.png
        ∟ ...
  ∟ secrets
    ∟ settings.ini
∟ main.py

where settings.ini contains

[DEFAULT]
local_path=data

[azure_demo]
storage_client=storage_tools.core.AzureStorageClient
conn_str=<A connection string to an Azure Storage account without credential>
credential=<The credentials with which to authenticate>
container=<The name of a storage container>

We can use main.py to

Create a new storage_client

storage_client=new_storage_client('azure_demo')

List files in the azure container (remote)

storage_client.ls()

List files in data (local)

storage_client.ls('local_path')

Create a new version of a dataset

storage_client.upload_dataset('mnist/hand_drawn_digits','major')

Note: If you run storage_client.ls() again, you'll see the new file in the azure container.

Download the latest version of a dataset

Feel free to delete your local copy of this dataset (from data) to download from azure storage.

storage_client.download_dataset('mnist/hand_drawn_digits')

Note: If you run storage_client.ls('local_path') again, you'll see the dataset in data.

See BlobServiceClient docs for more details on the settings used in settings.ini

  • from_connection_string (conn_str and credential)
  • get_container_client (container)

How to use AWS storage

It's the same as Azure except settings.ini contains

[DEFAULT]
local_path=data

[aws_demo]
storage_client=storage_tools.core.AwsStorageClient
service_name=s3
aws_access_key_id=<An AWS access key ID>
aws_secret_access_key=<An AWS access key>
bucket=<The name of an AWS bucket that the access key is allowed to read from and write to>

Developers

git config --global core.autocrlf input
conda create -n storage_tools python==3.8 -y
conda activate storage_tools
pip install fastcore nbdev jupyter
pip install boto3 azure-storage-blob

Type checking with mypy

!pip install mypy

Then from the storage_tools project folder

nbdev_build_lib
mypy storage_tools/core.py --ignore-missing-imports

For now, I'm ignoring the "Skipping analyzing 'azure': found module but no type hints or library stubs" error

Metadata

Release files for storage-tools 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for storage-tools 0.0.5
File Size Uploaded
storage_tools-0.0.5.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for storage-tools 0.0.5
File Interpreter ABI Platform
storage_tools-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 29.9 kB

Release files / storage_tools-0.0.5.tar.gz

Download URL storage_tools-0.0.5.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a88ce3164cbe52b1097c1f2e33bcd9493e4a4b077a0c6dfccc1a392de349b426
BLAKE2b-256 checksum
How to use checksums
333d6c1a68f4c5c132e64f4e4d3086dfefd4bdf670274feee235ebf58b58a9d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / storage_tools-0.0.5-py3-none-any.whl

Download URL storage_tools-0.0.5-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac14f48d7d1da2c53d90f64573518d08c01f9f17e615f7d8c08a27865a7f2383
BLAKE2b-256 checksum
How to use checksums
947da99c43e562177d46b85d213c85fd03de4365e3ab0b62119985bbebeb7775
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page