tosfsspec fully implements the fsspec specification. It can be used directly in Python and integrated with major data analysis and AI frameworks, including Pandas, Dask, Ray, PyArrow, and PyTorch.
tip
Before passing constructor parameters, you must configure long-term access credentials. For instructions, see Steps. Using tosfsspec with fsspec
warning
Instead of using the tos:// protocol scheme, you must use the tos-new:// protocol scheme. tos:// is currently occupied by an unofficial, third-party tosfs package that has already been registered with fsspec. You can access TOS resources directly using fsspec.open(). Use "tos-new://" in URLs and pass the required constructor parameters via storage_options.
When using fsspec.register_implementation, fsspec automatically selects TosFileSystem as the underlying file system implementation.
Using tosfsspec in Python
You can use tosfsspec's common APIs to read from and write to TOS in Python, similar to how you would work with a local file system.
Using tosfsspec in a multi-process scenario
tosfsspec works well in multiple processes. However, we recommend using the spawn mode to start child processes.
Integrating tosfsspec with Pandas
Since tosfsspec follows the fsspec specification, Pandas can use tosfsspec to read from or write to TOS in formats like CSV and Parquet without downloading the data locally.
- Reading a CSV file from TOS
- Writing a Pandas DataFrame to TOS as a Parquet file
Integrating tosfsspec with Dask
Dask is a flexible parallel computing library that natively supports fsspec‑compatible file systems. With tosfsspec, you can use dask.dataframe to read multiple CSV files from TOS in parallel and create a distributed DataFrame.
- Suppose your TOS bucket contains several CSV files structured as follows:
- You can load all of them at once using Dask:
Integrating tosfsspec with Ray (distributed computing)
Ray can leverage tosfsspec to directly read and process data stored in TOS in a distributed manner.
Integrating tosfsspec with PyArrow
PyArrow can leverage tosfsspec via the filesystem parameter to efficiently read from and write to TOS.
Integrating tosfsspec with PyTorch
PyTorch can be integrated with tosfsspec for tasks such as loading datasets and reading and writing checkpoints.