Skip to main content

fsspec filesystem for OSS

Project description

PyPI Status Python Version License

Tests Codecov pre-commit Black

OSSFS is a Python-based interface for file systems that enables interaction with OSS (Object Storage Service). Through OSSFS, users can utilize fsspec’s standard API to operate on OSS objects

Installation

You can install OSSFS via pip from PyPI:

$ pip install ossfs

Up-to-date package also provided through conda-forge distribution:

$ conda install -c conda-forge ossfs

Quick Start

Here is a simple example of locating and reading an object in OSS.

import ossfs
fs = ossfs.OSSFileSystem(endpoint='http://oss-cn-hangzhou.aliyuncs.com')
fs.ls('/dvc-test-anonymous/LICENSE')
[{'name': '/dvc-test-anonymous/LICENSE',
  'Key': '/dvc-test-anonymous/LICENSE',
  'type': 'file',
  'size': 11357,
  'Size': 11357,
  'StorageClass': 'OBJECT',
  'LastModified': 1622761222}]
with fs.open('/dvc-test-anonymous/LICENSE') as f:
...     print(f.readline())
b'                                 Apache License\n'

For more use case and apis please refer to the documentation of fsspec

Async OSSFS

Async OSSFS is a variant of ossfs that utilizes the third-party async OSS backend aiooss2, rather than the official sync one, oss2. Async OSSFS allows for concurrent calls within bulk operations, such as cat, put, and get etc even from normal code, and enables the direct use of fsspec in async code without blocking. The usage of async OSSFS is similar to the synchronous variant; one simply needs to replace OSSFileSystem with AioOSSFileSystem need to do is replacing the OSSFileSystem with the AioOSSFileSystem

import ossfs
fs = ossfs.AioOSSFileSystem(endpoint='http://oss-cn-hangzhou.aliyuncs.com')
print(fs.cat('/dvc-test-anonymous/LICENSE'))
b'                                 Apache License\n'
...

Although aiooss2 is not officially supported, there are still some features that are currently lacking. However, in tests involving the put/get of 1200 small files, the async version of ossfs ran ten times faster than the synchronous variant (depending on the pool size of the concurrency).

Task

time cost in (seconds)

put 1200 small files via OSSFileSystem

35.2688 (13.53)

put 1200 small files via AioOSSFileSystem

2.6060 (1.0)

get 1200 small files via OSSFileSystem

32.9096 (12.63)

get 1200 small files via AioOSSFileSystem

3.3497 (1.29)

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the Apache 2.0 license, Ossfs is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

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

ossfs-2023.12.0.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

ossfs-2023.12.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file ossfs-2023.12.0.tar.gz.

File metadata

  • Download URL: ossfs-2023.12.0.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for ossfs-2023.12.0.tar.gz
Algorithm Hash digest
SHA256 f99eb2d74717d22551b1f32ec9434587962627a816a64536dc47d68470536110
MD5 3155aeee96450328bbf6cbf358db8d20
BLAKE2b-256 d2424cdce6e1ff4ce53c33cdc0dc1d212207181af3037d0a3a789367da42a266

See more details on using hashes here.

File details

Details for the file ossfs-2023.12.0-py3-none-any.whl.

File metadata

  • Download URL: ossfs-2023.12.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for ossfs-2023.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1c5bbd24e7c0b3badd47d9c659bfdfac96d148b7e5d1f88ccdaf26403e893ab
MD5 70c091de7ca42e1fac6aeb2e3cdc9607
BLAKE2b-256 83c0121c6ae711376258a3e786d6afc991d022e3a74884ef4e6caa80b9c141a0

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