Example datasets API reference#
cytearc.datasets lists and downloads the public example datasets that the CyteArc tutorials
use. They live in top-level repositories of the public Nygen/cytebase Hugging Face bucket, such
as cytearc_docs for the documentation datasets. Downloads need network access but no
credentials. A repository names each dataset by its directory.
import cytearc
repository = cytearc.datasets.connect("cytearc_docs")
repository.list_datasets()
# Download and extract a prepared CyteArc store, then open it read-only.
path = repository.download_dataset(
"tenx_5K_pbmc_rnaseq", destination="cytearc_datasets", zarr=True
)
ds = cytearc.DataStore(f"{path}/data.zarr", zarr_mode="r")
download_dataset(name, zarr=True) downloads the dataset’s data.zarr.tar.gz archive and extracts it to data.zarr in the returned directory, keeping the archive beside it. Without zarr=True, it downloads the dataset’s other files, such as its source count files, and skips the store: its archive and the files under data.zarr/ that some datasets also list unpacked for remote reads.
A later call into the same destination reuses what is already there. A file is not downloaded again while the bucket lists it with the size and Xet hash recorded when it was downloaded, and its local copy has that size. An existing data.zarr is returned with the results saved in it, and is never replaced without overwrite=True. The call raises FileExistsError instead when:
the bucket now lists another archive than the one
data.zarrwas extracted from, a newer version of the dataset;data.zarrwas made from another source, such as a copy from a local catalog;nothing records what
data.zarrwas made from, and the archive beside it is missing or has another size than the bucket’s, as for a store from an earlier CyteArc whose archive was deleted;data.zarris not a directory;another call placed
data.zarrwhile this one was downloading or extracting it, and has not recorded it as current. A call that has recorded it makes this one return the store instead.
A directory extracted from any other archive that a dataset lists follows the same rules. overwrite=True downloads the current version, deleting anything saved in data.zarr.
download(path) downloads one file, or every file under a directory, on every call, and keeps its path within the repository.
- cytearc.datasets.list_repositories()#
Return the top-level example repositories in the public bucket.
- Return type:
list[str]
- cytearc.datasets.connect(repository)#
Connect to a public example repository, such as
cytearc_docs.- Return type:
- class cytearc.datasets.Repository(name)#
Read files from one top-level example repository.
- download(path, destination='.')#
Download a file or directory while preserving its repository path.
- Return type:
list[Path]
- download_dataset(name, destination='.', *, zarr=False, overwrite=False)#
Download one dataset into
destination/nameand return that directory.Without
zarr, the call downloads the dataset’s files other than its Zarr store, such as its source count files. It skips the store’s archive and the files under the store’s directory, which some datasets also list unpacked for remote reads. Withzarr=True, it downloads the dataset’sdata.zarr.tar.gzarchive and extracts it todata.zarr, keeping the archive beside it.A later call reuses what an earlier call placed in
destination. Each call records the bucket’s listing of each file it placed, its path, size and Xet hash, in.cytebase-sources.jsonin the returned directory, together with the archive that each extracted directory came from. A file is not downloaded again while the bucket’s listing of it equals the recorded one and the local copy has the listed size. An existingdata.zarris returned untouched, with everything saved in it, while the record says that it was extracted from the archive that the bucket lists now; its archive is not needed for that. Adata.zarrextracted before CyteArc kept this record is reused when the archive beside it has the size of the bucket’s archive; no bytes are compared.- Parameters:
name (
str) – The dataset’s directory in the repository.destination (
str|Path) – The directory that receives the dataset’s directory.zarr (
bool) – Download and extract the dataset’s Zarr archive instead of its other files.overwrite (
bool) – Download the selected files again and replace their local copies. Withzarr=True, the extracteddata.zarrreplaces the existing one, deleting anything saved in it. Withoutoverwrite, an existingdata.zarris never replaced, even one that another call places while this one runs.
- Raises:
TypeError – If
zarroroverwriteis not a boolean.KeyError – If the repository holds no such dataset.
FileNotFoundError – If
zarris set and the dataset has no Zarr archive, or if it is not set and the dataset lists no files besides its Zarr store.FileExistsError – If
overwriteis not set anddata.zarrexists but the record does not say that it was extracted from the archive that the bucket lists now, or if another call placesdata.zarrwhile this one runs and has not recorded it as current.ValueError – If
.cytebase-sources.jsonis not a record that CyteArc wrote, or if the archive kept beside a deleteddata.zarrcannot be extracted.
- Return type:
Path
- list_datasets()#
Return immediate dataset directories in this repository.
- Return type:
list[str]
CyteBase catalog#
The CyteBase catalog of public datasets stored as cloud-hosted CyteArc DataStores is the
separate cytebase package, which CyteArc does not install. CyteArc opens CyteBase datasets by
their hf:// URIs, as https://docs.nygen.io/CyteArc/tutorials/cytebase-datasets shows. To
search the catalog, install and import the package:
# Install the catalog client first: pip install cytebase
import cytebase
catalog = cytebase.Catalog()
See the CyteBase documentation at https://docs.nygen.io/CyteBase/ for its API and tutorials.
cytearc.cytebase keeps the earlier names of the example downloads through CyteArc 1.x:
Repository, connect, and list_repositories are the cytearc.datasets objects. The catalog
names it once exported, such as Catalog, releases, and embedding, moved to the cytebase
package, and reading one from cytearc.cytebase raises an AttributeError that says so. The
catalog build pipeline moved to the CyteBase repository at
NygenAnalytics/CyteBase.