Skip to main content

tosfs is a Pythonic file-system interface for TOS(Tinder Object Storage).

Project description

tosfs

PyPI version Status Python Version License pre-commit Black Doc Status Build

TOSFS builds on Volcengine TOS Python SDK to provide a convenient Python filesystem interface for TOS(Tinder Object Storage).

Features

  • Excellent read/write performance (optimized by multi-threading and multi-disk staging).
  • Solid stability (fine-grained judgment on response codes for TOS services).
  • Outstanding compatibility (cross-validation completed on the version matrix of four Python versions and two fsspec versions).
  • TOS HNS (Hierarchical NameSpace) Bucket support (in adaptation and verification).
  • Native append API support.

Installation

You can install tosfs via pip from PyPI:

$ pip install tosfs

Quick Start

Init FileSystem

  • Init via ak/sk
from tosfs.core import TosFileSystem

tosfs = TosFileSystem(
    key='ak',
    secret='sk',
    endpoint_url='http://tos-cn-beijing.volces.com',
    region='cn-beijing',
)
  • Init via system env

make sure these envs take effect:

export TOS_ACCESS_KEY=' your ak here '
export TOS_SECRET_KEY=' your sk here '
export TOS_ENDPOINT='http://tos-cn-beijing.volces.com'
export TOS_REGION='cn-beijing'

then init TosFileSystem by setting credentials_provider to EnvCredentialsProvider

import os
from tosfs.core import TosFileSystem
from tos import EnvCredentialsProvider

tosfs = TosFileSystem(
    endpoint_url=os.environ.get("TOS_ENDPOINT"),
    region=os.environ.get("TOS_REGION"),
    credentials_provider=EnvCredentialsProvider, # must
)

Access FS and file operation APIs

After getting the instance of TosFileSystem by following the above guidance, now we can access fs and file operation apis, e.g.

# list
tosfs.ls("")
tosfs.ls("mybucket", detail=False)
tosfs.ls("mybucket/rootpath/", detail=False)

# file read/write
with tosfs.open('bucket/root/text.txt', mode='wb') as f:
    f.write('hello tosfs!')
    
with tosfs.open('bucket/root/text.txt', mode='rb') as f:
    content = f.read()
    print(content)

integration usages

For more usage in ray, pyspark, pytorch and so on, please refer to the examples dir.

Compatibility

The tosfs package is compatible with the following Python and fsspec versions:

  • Python
Version Supported
3.9
3.10
3.11
3.12
  • fsspec
Version Supported
2023.5.0
2024.9.0

Contributing

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

License

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

Issues

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

Privacy Statement

Welcome to use our open-source project tosfs. We highly value your privacy and are committed to protecting your information. This privacy statement aims to inform you about how we collect, use, store, and protect your information within the project (we believe you have the right to know).

Information Collection: 
  We may collect the names of the buckets you access in the TOS service 
  (and only the names of the buckets you access). 
  You can opt out of this collection by setting the environment variable 
  "TOS_BUCKET_TAG_ENABLE" to "false", and we will respect your decision.

Information Usage: 
  We will only use the collected information to tag the source of access 
  and commit that this information will solely be used for the purpose of 
  tagging the source of access.

Information Storage: 
  We will take reasonable security measures to protect the information 
  we collect from unauthorized access, disclosure, use, or destruction. 
  We commit that this information will not be stored on third-party service 
  providers' servers. Additionally, we will comply with applicable laws, 
  regulations, and security standards.

Information Sharing: 
  We will not sell, rent, or share the collected information with any third parties.

If you need any further adjustments or additional details, feel free to let us know!

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

tosfs-2024.10.1.tar.gz (46.7 kB view details)

Uploaded Source

Built Distribution

tosfs-2024.10.1-py3-none-any.whl (54.4 kB view details)

Uploaded Python 3

File details

Details for the file tosfs-2024.10.1.tar.gz.

File metadata

  • Download URL: tosfs-2024.10.1.tar.gz
  • Upload date:
  • Size: 46.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for tosfs-2024.10.1.tar.gz
Algorithm Hash digest
SHA256 fdcbcc7a67b7e38cb9760d988450493229f737303d21330f7269f565f7bea238
MD5 85afc2de23af45c81668b420d437b4a8
BLAKE2b-256 ffad16150ce3665153f1b7f46f3c5be4fb04e4224498c7a1583cce67c5e5c8c2

See more details on using hashes here.

File details

Details for the file tosfs-2024.10.1-py3-none-any.whl.

File metadata

  • Download URL: tosfs-2024.10.1-py3-none-any.whl
  • Upload date:
  • Size: 54.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for tosfs-2024.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 77f8f14f06be12010ba420bc554c424c9fb9167abfd658110b86678c5871f351
MD5 750bfac708f799d40412f1804fd64fa1
BLAKE2b-256 6117afbd024e98fb9a36c5da9eb9a0dc2129d689cc606381f261eaee89769cc8

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