Skip to main content

Mara Storage

mara-storage PyPI - License PyPI version Slack Status

Mini package for configuring and accessing multiple storages in a single project. Decouples the use of storages and their configuration by using "aliases" for storages.

The file mara_storage/storages.py contains abstract storage configurations for local disk and cloud storages. The storage connections of a project are configured by overwriting the storages function in mara_storage/config.py:

import pathlib
import mara_storage.config
import mara_storage.storages

## configure storage connections for different aliases
mara_storage.config.storages = lambda: {
    'data': mara_storage.storages.LocalStorage(base_path=pathlib.Path('data')),
    'gcs-bucket-1': mara_storage.storages.GoogleCloudStorage(bucket_name='my_data_lake_bucket_1', project_id='my_awesome_project')
}

## access individual storage configurations with `storages.storage`:
print(mara_storage.storages.storage('data'))
# -> <LocalStorage: base_path=data>

This packages gives the possibility to configure, manage and access multile storages in mara.

 

Batch processing: Accessing storages with shell commands

The file mara_storage/shell.py contains functions that create commands for accessing storage files via their command line clients.

For example, the read_file_command function creates a shell command that reads a file from a storage and returns its content to stdout:

import mara_storage.shell

file = 'my_domain.com/logs/2020/11/15/nginx.node-1.error.log'

print(mara_storage.shell.read_file_command('data', file_name=file))
# -> cat /mara/data/my_domain.com/logs/2020/11/15/nginx.node-1.error.log

print(mara_storage.shell.read_file_command('gcs-bucket-1', file_name=file))
# -> gsutil cat gs://my_data_lake_bucket_1/my_domain.com/logs/2020/11/15/nginx.node-1.error.log

The function write_file_command creates a shell command that receives a data on stdin and writes it to the storage:

import mara_storage.shell

command = 'echo "Hello World!"'
command += ' | '
command += mara_storage.shell.write_file_command('data', file_name='hello-world.txt')

print(command)
# -> echo "Hello World!" | cat - > /mara/data/hello-world.txt

Finally, delete_file_command creates a shell command that deletes a file from the local storage:

import mara_storage.shell

print(mara_storage.shell.delete_file_command('data', file_name='hello-world.txt'))
# -> rm -f /mara/data/hello-world.txt

 

The following command line clients are used to access the various databases:

Storage Client binary Comments
Local storage unix shell Included in standard distributions.
SFTP storage sftp, curl
Google Cloud Storage gsutil From https://cloud.google.com/storage/docs/gsutil_install.
Azure Storage azcopy, curl From https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10

 

Installation

To use the library directly, use pip:

pip install mara-storage

or

pip install git+https://github.com/mara/mara-storage.git

Links

Metadata

Release files for mara-storage 1.1.1

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

Source distribution (sdist)

Source distribution for mara-storage 1.1.1
File Size Uploaded
mara-storage-1.1.1.tar.gz 15.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mara-storage 1.1.1
File Interpreter ABI Platform
mara_storage-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.7 kB

Release files / mara-storage-1.1.1.tar.gz

Download URL mara-storage-1.1.1.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dca16af1191af38aecb09583bf8aeb1d6dba81c1f83b27e0f350c9084d30d9ef
BLAKE2b-256 checksum
How to use checksums
3b9308b67ae765927c8ff09c56045122dd9b1f240878dd80351446433528c548
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / mara_storage-1.1.1-py3-none-any.whl

Download URL mara_storage-1.1.1-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
885411cdab26a3602fecf4a6ee31251b6143dc8acd221a1e1bd2031ec4160745
BLAKE2b-256 checksum
How to use checksums
5216aee7dcee659238c9afc4f45b95ca455c8e38f76cd0c05db6a14c1fb79de9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.9.4

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