# BaFileSystem

## Filesystem API

The `BaFileSystem` class provides a pythonic file interface to the BOINC AI Hub based on [`fssepc`](https://filesystem-spec.readthedocs.io/en/latest/).

### BaFileSystem

`BaFileSystem` is based on [fsspec](https://filesystem-spec.readthedocs.io/en/latest/), so it is compatible with most of the APIs that it offers. For more details, check out [our guide](https://huggingface.co/docs/huggingface_hub/guides/hf_file_system) and the fsspec’s [API Reference](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem).

#### class boincai\_hub.BaFileSystem

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/hf_file_system.py#L54)

( \*args\*\*kwargs )

Parameters

* **endpoint** (`str`, _optional_) — The endpoint to use. If not provided, the default one ([https://boincai.com](https://huggingface.co/)) is used.
* **token** (`str`, _optional_) — Authentication token, obtained with `BaApi.login` method. Will default to the stored token.

Access a remote BOINC AI Hub repository as if were a local file system.



Usage:

Copied

```
>>> from boincai_hub import BaFileSystem

>>> fs = BaFileSystem()

>>> # List files
>>> fs.glob("my-username/my-model/*.bin")
['my-username/my-model/pytorch_model.bin']
>>> fs.ls("datasets/my-username/my-dataset", detail=False)
['datasets/my-username/my-dataset/.gitattributes', 'datasets/my-username/my-dataset/README.md', 'datasets/my-username/my-dataset/data.json']

>>> # Read/write files
>>> with fs.open("my-username/my-model/pytorch_model.bin") as f:
...     data = f.read()
>>> with fs.open("my-username/my-model/pytorch_model.bin", "wb") as f:
...     f.write(data)
```

**\_\_init\_\_**

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/hf_file_system.py#L88)

( \*argsendpoint: typing.Optional\[str] = Nonetoken: typing.Optional\[str] = None\*\*storage\_options )

**resolve\_path**

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/hf_file_system.py#L141)

( path: strrevision: typing.Optional\[str] = None )

**ls**

[\<source>](https://github.com/huggingface/huggingface_hub/blob/v0.18.0.rc0/src/huggingface_hub/hf_file_system.py#L278)

( path: strdetail: bool = Truerefresh: bool = Falserevision: typing.Optional\[str] = None\*\*kwargs )

List the contents of a directory.
