Skip to main content

🍱 fsspec interface for Weights & Biases (wandb)

Quoting Weights and Biases (wandb), "Weights & Biases is the machine learning platform for developers to build better models faster. Use W&B's lightweight, interoperable tools to quickly track experiments, version and iterate on datasets, evaluate model performance, reproduce models, visualize results and spot regressions, and share findings with colleagues.". Reference at https://docs.wandb.ai/

So you may be thinking, what does wandb have to do with anything close to a File System? Well, it's not but it actually provides a way to upload/download files and store them in a remote, which makes it somehow a File System. Also, wandb provides an API that lets you interact with that "File System", so this is why wandbfsspec makes sense, in order to ease that interface between wandb's File System and anyone willing to use it.

Besides the W&B File System, also an Artifact Store is provided, so that wandbfsspec supports both "file-systems", as for the Artifact Store also an API is provided so as to easily interact with the artifacts uploaded to W&B.

The wandbfsspec implementation is based on https://github.com/fsspec/filesystem_spec.

🚸 Usage

Here's an example on how to locate and open a file from the File System:

>>> from wandbfsspec.spec import WandbFileSystem
>>> fs = WandbFileSystem(api_key="YOUR_API_KEY")
>>> fs.ls("alvarobartt/wandbfsspec-tests/3s6km7mp")
['alvarobartt/wandbfsspec-tests/3s6km7mp/config.yaml', 'alvarobartt/wandbfsspec-tests/3s6km7mp/file.yaml', 'alvarobartt/wandbfsspec-tests/3s6km7mp/files', 'alvarobartt/wandbfsspec-tests/3s6km7mp/output.log', 'alvarobartt/wandbfsspec-tests/3s6km7mp/requirements.txt', 'alvarobartt/wandbfsspec-tests/3s6km7mp/wandb-metadata.json', 'alvarobartt/wandbfsspec-tests/3s6km7mp/wandb-summary.json']
>>> with fs.open("alvarobartt/wandbfsspec-tests/3s6km7mp/file.yaml", "rb") as f:
...     print(f.read())
b'some: data\nfor: testing'

Which is similar to how to locate and open a file from the Artifact Storage (just changing the class and the path):

>>> from wandbfsspec.spec import WandbArtifactStore
>>> fs = WandbArtifactStore(api_key="YOUR_API_KEY")
>>> fs.ls("wandb/yolo-chess/model/run_1dnrszzr_model/v8")
['wandb/yolo-chess/model/run_1dnrszzr_model/v8/last.pt']
>>> with fs.open("wandb/yolo-chess/model/run_1dnrszzr_model/v8/last.pt", "rb") as f:
...     print(f.read())

📌 Note that it can also be done through fsspec as long as wandbfsspec is installed:

>>> import fsspec
>>> fs = fsspec.filesystem("wandbfs") # OR fs = fsspec.filesystem("wandbas")
>>> fs.ls("alvarobartt/wandbfsspec-tests/3s6km7mp")
['alvarobartt/wandbfsspec-tests/3s6km7mp/config.yaml', 'alvarobartt/wandbfsspec-tests/3s6km7mp/file.yaml', 'alvarobartt/wandbfsspec-tests/3s6km7mp/files', 'alvarobartt/wandbfsspec-tests/3s6km7mp/output.log', 'alvarobartt/wandbfsspec-tests/3s6km7mp/requirements.txt', 'alvarobartt/wandbfsspec-tests/3s6km7mp/wandb-metadata.json', 'alvarobartt/wandbfsspec-tests/3s6km7mp/wandb-summary.json']
>>> with fs.open("alvarobartt/wandbfsspec-tests/3s6km7mp/file.yaml", "rb") as f:
...     print(f.read())
b'some: data\nfor: testing'

📝 Documentation

Coming soon... (https://github.com/mkdocs/mkdocs)

🧪 How to test it

In order to test it, you should first set the following environment variables so as to use wandb as a file system for the tests.

WANDB_ENTITY = ""
WANDB_PROJECT = ""
WANDB_API_KEY = ""

Both entity and project values can be found in your https://wandb.ai/ account, as the entity name is your account name, and the project name can either be already created or you can just specify it and it'll be created during pytest init. Then, regarding the API Key, you just need to go to https://wandb.ai/settings, scroll down to Danger Zone -> API Keys, and copy your personal API Key from there.

⚠️ Make sure that you don't publish your API Key anywhere, that's why we're defining it as an environment value, so as to avoid potential issues on commiting code with the actual API Key value.

Then, in order to actually run the tests you can either run:

  • poetry run pytest
  • poetry run make tests

Or, if you're not using poetry, you can just run both those commands without it.

Metadata

Release files for wandbfsspec 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wandbfsspec 0.2.0
File Size Uploaded
wandbfsspec-0.2.0.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wandbfsspec 0.2.0
File Interpreter ABI Platform
wandbfsspec-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.1 kB

Release files / wandbfsspec-0.2.0.tar.gz

Download URL wandbfsspec-0.2.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8e4132f35c2facb5743d3cab9bf636c8009834bb3bb843c3e7ff9c759d95050d
BLAKE2b-256 checksum
How to use checksums
6a3134ad93b1ad8196ebed5eb3474a35aa00dd547cf5741b7c4674c066abaec3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.15 CPython/3.9.14 Linux/5.15.0-1021-azure

Release files / wandbfsspec-0.2.0-py3-none-any.whl

Download URL wandbfsspec-0.2.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6def3d4bcbc866559b209938ef8338b8d0a077a5ad8e14b68991e772a4af9086
BLAKE2b-256 checksum
How to use checksums
58cedae06ce9e38c630c09d9f47cd9d4fa908f5110298ae2ff8a46d5fb57a928
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.15 CPython/3.9.14 Linux/5.15.0-1021-azure

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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