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 *


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

# 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)

# 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
# Or list dirs in a 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)))
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.

Files for ossTools, version 0.1.16
Filename, size File type Python version Upload date Hashes
Filename, size ossTools-0.1.16-py3-none-any.whl (8.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ossTools-0.1.16.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page