Skip to main content

tosfs

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

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

Features

  • Excellent read/write performance than s3fs (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(Beta).
  • Native append API support.
  • Extended features:
    • support assume role credentials;
    • batch list iterate;
    • multiple thread walk;
    • support special characters in local path;

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
)
  • Init via assume role(temporary ak/sk and session token).

make sure you have an assume role credential generator, then you can init the TosFileSystem like this:

from tosfs import TosFileSystem
from tosfs.certification import FileCredentialsProvider
fs = TosFileSystem(
    endpoint="http://tos-cn-beijing.volces.com",
    region="cn-beijing",
    credentials_provider=FileCredentialsProvider("/etc/secret/las"), # replace to real path
)

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='w') as f:
    f.write('hello tosfs!')
    
with tosfs.open('bucket/root/text.txt', mode='r') 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
2024.10.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!

Download files

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

Source Distribution

tosfs-2026.7.0.tar.gz (54.0 kB view details)

Uploaded Source

Built Distribution

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

tosfs-2026.7.0-py3-none-any.whl (64.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tosfs-2026.7.0.tar.gz
Algorithm Hash digest
SHA256 1549b2886baaf00ef1cf3b070b0e02c61d1a5df1fd74c8260da29f3eb7bf9974
MD5 6d9e2a302e357c3bdb0a627f05f0b311
BLAKE2b-256 247884436f58d0d39d117d635b170636b53b256db3fb45975e6e3dfe839da4bc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tosfs-2026.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 491942bd4a82cbfb96171b748fa219c57cf107652d77f3c311072c5bca3d1db9
MD5 b0b2cc472730835bce82294481b28b59
BLAKE2b-256 c4736b48076c86e27d412dbb2eb742190d04fe0c37f52da98039d9133385a047

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2026.7.0 This release

2 files

2026.3.1

2 files

2026.3.0

2 files

2025.6.0

2 files

2025.5.0

2 files

2025.4.1

2 files

2025.4.0

2 files

2025.2.0

2 files

2024.12.1

2 files

2024.12.0

2 files

2024.11.4

2 files

2024.11.3

2 files

2024.11.2

2 files

2024.11.1

2 files

2024.11.0

2 files

2024.10.1

2 files

2024.10.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page