Skip to main content

ebrains-bucket-sync

Sync a local folder to an EBRAINS Data Proxy bucket, or a bucket to a local folder, the way rsync does: only new and changed files are transferred, so a sync that is interrupted picks up where it stopped when run again. A folder can also stand for a bucket with an empty placeholder for each file not downloaded yet, and be browsed in a window that fetches files one by one.

The sync rules are shared with the ebrains.bucket.sync functions of the EBRAINS MATLAB toolbox. Both follow the contract in spec/README.md and pass the same fixtures in spec/fixtures, so a plan is the same whichever tool makes it, and a folder synced or browsed with one can be synced or browsed with the other. This version of the package and version 0.12.0 of the toolbox follow the same contract.

Install

pipx install ebrains-bucket-sync

No pipx, or using the package from Python? See Installing ebrains-bucket-sync.

The changes of each release are in CHANGELOG.md.

Use

Log in once. A link opens the EBRAINS login in the browser, and the login is kept for later runs:

ebrains-bucket-sync login

See what a sync would do, then run it:

ebrains-bucket-sync push results my-bucket --prefix results --dry-run
ebrains-bucket-sync push results my-bucket --prefix results

Object names are the paths relative to the local folder. Files the bucket already has, with the same size and uploaded after the local file was last changed, are not sent again. --comparison Size ignores the times, and --comparison Checksum compares the MD5 of every file of the same size.

--delete also deletes the objects that the local folder does not have, which makes the bucket (or the folder of it) an exact mirror. A sync refuses to empty a bucket from an empty folder, and --max-delete N stops it before it deletes more than N objects. Nothing is deleted after an upload failed. On a file system that ignores the case of names, as the default ones of macOS and Windows do, an object whose name differs only in case from a local file is not deleted, with a warning: the folder cannot hold the two apart, so a pull keeps only one of them, and the object may be the only copy of its data.

--exclude PATTERN leaves out paths that match a wildcard pattern: *.tmp in every folder, .git/ for that folder wherever it is, raw/scratch for that path from the root. Excluded paths are neither uploaded nor deleted, so excluding a path does not remove it from the bucket. The .ebrains folder of a virtual bucket and the files of interrupted transfers, whose names end in .sync-part or .multipart_manifest.json, are never synced. The patterns look like those of a .gitignore file but follow simpler rules, listed in spec/README.md; for example, a pattern cannot re-include paths with !.

--exclude-from FILE reads patterns from a file, one per line, with # for comments. templates/dataset.ignore leaves out the files that do not belong in a published dataset, such as .git/, .DS_Store and __pycache__/. Copy it next to your data, add what else to leave out, and pass it to each sync:

ebrains-bucket-sync push my-dataset my-bucket --exclude-from dataset.ignore

--plan-file plan.json writes the plan and the outcome as JSON. --workers N transfers N files at the same time, 4 by default, and --quiet prints only failures.

An upload that fails does not stop the sync. The other files are uploaded, nothing is deleted, the command exits with status 1, and running it again retries the failed files. A sync that stops before changing anything, because the planned deletions look like a mistake or the folder stands for another bucket, exits with status 2.

Pull

pull makes a local folder match a bucket, or a folder of it, with the same options as push read the other way: --delete deletes the local files the bucket does not have, and --exclude leaves local files and objects alike out of the sync.

ebrains-bucket-sync pull my-bucket data --prefix results --dry-run
ebrains-bucket-sync pull my-bucket data --prefix results

The folder is created if it does not exist. Each object is downloaded into a temporary file next to its target, which replaces the target only once the download is complete and has the size of the object, and the file gets the modification time of its object, so a later sync in either direction finds it unchanged. A local file changed after its object was uploaded is kept, as with push the other way.

On a file system that ignores the case of names, as the default ones of macOS and Windows do, an object and a local file whose names differ only in case are one file, and objects whose names differ from each other only in case are left out with a warning. A download is refused, as a failed row, when its local path is a folder, lies below a folder that is a symbolic link, or holds something the listing of the folder did not find. A folder that is a symbolic link, or that cannot be read, also holds back all deletions, as a failed download does.

Virtual buckets

A virtual bucket is a local folder that stands for a bucket, or a folder of one, and holds an empty placeholder file for each object that is not downloaded. The .ebrains folder at its root says which bucket it stands for and records what the bucket held when it was last listed. browse opens one in a window, where files can be downloaded and made online only again:

ebrains-bucket-sync browse my-dataset --bucket my-bucket --prefix results

A folder that is not a virtual bucket becomes one of --bucket, and a folder that does not exist is created and filled with placeholders from a listing of the bucket. createVirtualBucket and the virtual bucket browser of the MATLAB toolbox make and open the same folders.

browse without a folder opens the list of your virtual buckets: the folders directly below the root folder and the folders opened before, with a filter, pinned folders first, and a label for each bucket in place of its name, which is often a UUID. From the list a virtual bucket is opened, or a new one made from the name of its bucket alone once a root folder is set. The buckets commands manage the same list from the command line:

ebrains-bucket-sync buckets root ~/EBRAINS-buckets
ebrains-bucket-sync buckets label d-4f3a2b1c-5d6e-4f70-8a9b-0c1d2e3f4a5b "Mouse V1 recordings"
ebrains-bucket-sync buckets pin ~/EBRAINS-buckets/d-4f3a2b1c-5d6e-4f70-8a9b-0c1d2e3f4a5b
ebrains-bucket-sync buckets list

The list is virtual-buckets.json in the configuration folder (see Authentication), which the MATLAB toolbox reads and writes too, as spec/README.md describes.

A push of a virtual bucket is refused unless the bucket and --prefix are the ones it stands for, leaves the placeholders alone, and never syncs the .ebrains folder. A pull deletes the placeholders of objects removed from the bucket. After either, the manifest in .ebrains records what the bucket holds.

From Python

from ebrains_bucket_sync import (
    DeviceFlowAuthenticator,
    EbrainsDriveStorage,
    SyncOptions,
    sync_from_bucket,
    sync_to_bucket,
)

storage = EbrainsDriveStorage(DeviceFlowAuthenticator())
results = sync_to_bucket(
    "results", "my-bucket", storage, SyncOptions(prefix="results", delete=True)
)
for result in results:
    print(result.path, result.action, result.reason, result.status)

results = sync_from_bucket("my-bucket", "data", storage, SyncOptions(prefix="results"))

Authentication

ebrains-bucket-sync login logs in, login --force logs in again even when a valid login is stored, and ebrains-bucket-sync logout forgets the stored login.

The login uses the OAuth device flow with the same OIDC client as the MATLAB toolbox, so both tools show up as one application in your EBRAINS account. The tokens are kept in the configuration folder of the user, ~/Library/Application Support/ebrains-bucket-sync on macOS, %LOCALAPPDATA%\ebrains-bucket-sync on Windows and ~/.config/ebrains-bucket-sync elsewhere, as spec/README.md defines it, in a file only the user can read, and the access token is renewed from the refresh token without a new login for as long as the refresh token lasts. In CI, set EBRAINS_BUCKET_SYNC_TOKEN to an access token instead. EBRAINS_BUCKET_SYNC_CONFIG_DIR names another configuration folder.

Development

git clone https://github.com/ehennestad/ebrains-bucket-sync
cd ebrains-bucket-sync
uv sync --dev
uv run pytest

The live tests in tests/live run against a real bucket and are skipped unless EBRAINS_BUCKET_SYNC_TEST_BUCKET names one. The Live tests workflow runs them once a week as a service account, and on demand. Everything else runs offline against an in-memory bucket.

Metadata

Release files for ebrains-bucket-sync 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 ebrains-bucket-sync 0.2.0
File Size Uploaded Provenance Actions
ebrains_bucket_sync-0.2.0.tar.gz 224.0 kB With provenance Details for ebrains_bucket_sync-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ebrains-bucket-sync 0.2.0
File Interpreter ABI Platform Actions
ebrains_bucket_sync-0.2.0-py3-none-any.whl Python 3 none any Details for ebrains_bucket_sync-0.2.0-py3-none-any.whl

Total release size: 317.6 kB

Release files / ebrains_bucket_sync-0.2.0.tar.gz

Download URL ebrains_bucket_sync-0.2.0.tar.gz
Size 224.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0615c8e9a0753bdea93684530ec6ce78d53fc592209293bc87d075153be10b4f
BLAKE2b-256 checksum
How to use checksums
abdca4f9ceee1f5a375990ff96d43aefeb0345c6ba8b440747c355810bc7b2f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

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

Download URL ebrains_bucket_sync-0.2.0-py3-none-any.whl
Size 93.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4fbc7c2a18a2995d98d8fb387791275318767b9cb2763aed31f1076fed65651a
BLAKE2b-256 checksum
How to use checksums
b83f57ac099a3aee3d462ca15697503f7cdaf243025913041aaef82e527d0cda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for ebrains-bucket-sync 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ebrains_bucket_sync-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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