Skip to main content

Useful tools that simplify OSS file operation.

Project description

Useful tools for OSS

Makes your experience with OSS easier.

Quick start

pip install ossTools

Caution: Currently, only the following functions are tested:

  • ossInit
  • ossOpen
  • imRead
  • imWrite
  • ossListFile
  • ossListDir
  • ossIsFile
  • ossIsDir
  • ossDownloadFile
  • ossUploadFile

Please report any problems with other untested functions to me, thanks!

Email: Ziheng Zhang (Suyue)

from ossTools import *

ossInit(
        bucket='bucket-name',
        access_id='your-access-id',
        access_key='your-access-key',
        endpoint='oss-cn-hangzhou.aliyuncs.com',
)

# Read file, multiprocess safe!
with ossOpen("some/path/in/the/bucket", "r") as fp:
    print(fp.read())

# Write file, multiprocess safe!
with ossOpen("some/path/in/the/bucket", "w") as fp:
    # Python3
    print("Hello, world!", file=fp)
    # Python2
    fp.write("Hello, world!\n")

# Open and show an image with OpenCV
import cv2
# Use wrapped imRead/imWrite function in ossTools instead of cv2.imread
img = imRead("some/image.jpg", flags=cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)
cv2.imshow("img", img)
cv2.waitKey()

# Integrate with tensorboardX
import tensorboardX as tb
writter = tb.SummaryWriter(log_dir="oss://bucket/path/to/oss/dir")
writter.add_scalar("train/loss", some_loss, global_step=iters)

# File Utils
# Check file existence
assert ossIsFile("path/to/file"), "File {} does not exist!".format("path/to/file")
# List files in a dir
print(ossListFile("path/to/dir"))
# Or list dirs in a dir
print(ossListDir("path/to/dir"))

# Download/Upload/Delete/Copy
ossDownloadFile("remote/path", "local/path", progress_callback=lambda per: print("{}% downloaded.".format(per)))
ossUploadFile("remote/path", "local/path", overwrite=True, progress_callback=lambda per: print("{}% uploaded.".format(per)))
ossDeleteFile("path/to/file")
ossDeleteDir("path/to/dir", iterative=True)
ossCopyFile("source/file", "target/file")

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

ossTools-0.1.16.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

ossTools-0.1.16-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file ossTools-0.1.16.tar.gz.

File metadata

  • Download URL: ossTools-0.1.16.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for ossTools-0.1.16.tar.gz
Algorithm Hash digest
SHA256 4b23e1803685b4d2ea4483fd54a01ac164fea90cedf68373780a2cd75037ef26
MD5 10944d023881cf330b824792b7bcc2b3
BLAKE2b-256 03a18b7f30c415fb43a69acc2d3ed6e16cd49654367e6ca7972d67d6c6ad5c68

See more details on using hashes here.

File details

Details for the file ossTools-0.1.16-py3-none-any.whl.

File metadata

  • Download URL: ossTools-0.1.16-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for ossTools-0.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 f915f7bbf959de007a5ae587bc6042d5d0146b29b00ae2bd0ef4489ad63c7fcc
MD5 2e4da265cb0093e46c7bb2bedfcc55fd
BLAKE2b-256 9f096266976177da0f927ba150819374a040421745644070f1d2bab93276ed97

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