Skip to main content

python binding for using s5cmd to download and upload files to s3 efficiently

Project description

s5cmd-python

python binding for using s5cmd to download and upload files to s3 efficiently

The S5CmdRunner class provides a Python interface for interacting with s5cmd, a command-line tool designed for efficient data transfer to and from Amazon S3.

For more information about s5cmd, please refer to the original s5cmd repository.

Features

  • Check for the presence of s5cmd and download it if necessary.
  • Execute s5cmd commands cp, mv, and run.
  • Handle file downloads from URLs and S3 URIs.
  • Generate command files for batch operations with s5cmd.
  • Simplify operations like copying and moving files between local paths and S3 URIs.

Installation

To use S5CmdRunner, ensure that Python 3.10 or higher is installed. The project itself can be installed from pip:

pip install s5cmdpy

or from source:

git clone https://github.com/troph-team/s5cmd-python
cd s5cmd-python
pip install -e .

Usage

Here are some examples of how to use the S5CmdRunner class:

Initialize S5CmdRunner

from s5cmdpy import S5CmdRunner
runner = S5CmdRunner()

Run s5cmd with a Local Command File

# local_txt: `cp s3://dataset-artstation-uw2/artists/__andrey__/1841730##GZGgW.json .`
local_txt_path = "s5cmd_test.txt"
runner.run(local_txt_path)

Run s5cmd with a Command File from S3

# Useful in environments like SageMaker or for reproducibility; 
# Extends `s5cmd run something.txt` to support command files stored in S3
txt_s3_uri = "s3://dataset-artstation-uw2/s5cmd_test.txt"
runner.run(txt_s3_uri)

Download Multiple Files from S3

# Input a series of S3 URIs to create the necessary commands.txt for `s5cmd run`, 
# then execute `s5cmd run <commands.txt>`

s3_uris = [
    's3://dataset-artstation-uw2/artists/__andrey__/1841730##GZGgW.json', 
    's3://dataset-artstation-uw2/artists/__andrey__/2249992##q5Y22.json'
]
destination_dir = '/home/ubuntu/datasets/s5cmd_test'
runner.download_from_s3_list(s3_uris, destination_dir)

License

S5cmd itself is MIT licensed. This project is also MIT licensed.

Project details


Download files

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

Source Distribution

s5cmdpy-0.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

s5cmdpy-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: s5cmdpy-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for s5cmdpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2f32f3439c400eeec4a55898555ca1f129ec7d76d62cf042060b0bb7f2201409
MD5 fb0e0b141ca2971760dad7e5a575740c
BLAKE2b-256 97791744189e518ebf8e40074039521d94042279f3c54d6ec4f6e74f47901ab3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: s5cmdpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for s5cmdpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 605f047736a8c2bf502250fdc75b98021c152c2c9d0e7ca387be4ce6a77b3067
MD5 15061dade85c2512a822f70ebb53c00b
BLAKE2b-256 a84c1c74b4d683d41e2dbafef9c19e536ddb95578a411f1f61b2941b8bec552b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page