A simple fsspec driver for SquashFS files
Project description
SquashFSSpec
A simple fsspec driver for reading SquashFS files.
SquashFSSpec allows you to treat a SquashFS image as a filesystem, enabling seamless integration with tools like xarray, dask, and zarr without needing to mount the image.
Installation
You can install squashfsspec via pip from GitHub:
pip install squashfsspec
Or using pixi:
pixi add squashfsspec --git https://github.com/observingClouds/squashfsspec.git
Usage
Basic Usage with fsspec
import fsspec
squashfs_path = "path/to/your.squash"
# Open a SquashFS file
fs = fsspec.filesystem("squashfs", fo=squashfs_path)
# List files
print(fs.ls("/"))
# Open and read a file
with fs.open("some/file.txt", "rb") as f:
print(f.read().decode())
Working with Xarray and Zarr
If you have a Zarr store inside a SquashFS image, you can open it directly with xarray:
import xarray as xr
squashfs_path = "path/to/data.squash"
# Open a Zarr store inside a SquashFS file
ds = xr.open_dataset(
"squashfs:///",
engine="zarr",
consolidated=False, # Set to True if your Zarr store is consolidated
backend_kwargs={
"storage_options": {"fo": squashfs_path}
},
)
print(ds)
Accessing Multiple Datasets
If your SquashFS image contains multiple Zarr stores or datasets, you can access them by specifying the internal path:
import xarray as xr
squashfs_path = "path/to/multidata.squash"
dataset_path = "path/in/squashfs/file/to/dataset.zarr"
# Open a specific dataset inside a SquashFS file containing multiple datasets
ds = xr.open_dataset(
f"squashfs:///{dataset_path}::{squashfs_path}",
engine="zarr",
consolidated=True,
)
print(ds)
Development
This project uses pixi for dependency management and development workflows.
Setup
# Install dependencies and setup the dev environment
pixi install -e dev
Running Tests
pixi run -e dev pytest
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file squashfsspec-0.1.4.tar.gz.
File metadata
- Download URL: squashfsspec-0.1.4.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.26.8 CPython/3.13.13 Linux/6.17.0-1010-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d99e7da98aba51de4ce521b3f3d76bf2ed372cdd9a21bd6a73a44b594efc7e0
|
|
| MD5 |
ee4e58f26e3ba25b3605d1d4f5aae8a2
|
|
| BLAKE2b-256 |
4499d7730586f030eec10250780821763c79d31f34e611a32dd20fdbcf152e3b
|
File details
Details for the file squashfsspec-0.1.4-py3-none-any.whl.
File metadata
- Download URL: squashfsspec-0.1.4-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.26.8 CPython/3.13.13 Linux/6.17.0-1010-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d53e6cb27d3fb6dc7e97b5726b0f8b1b1ad4f94770113ad7bd520a741fc7316
|
|
| MD5 |
d1f6c52a5216527b3e26b213399a38cc
|
|
| BLAKE2b-256 |
c5df98e885f6ea3f3b33e24ffa3aa63da438a3021e796f52950e1ca96deb50d1
|