radiens_drive_catalog
radiens-drive-catalog
Programmatic catalog and sync tool for xdat neural datasets stored on Google Drive. Datasets are indexed by base_name and queryable by date folder, experiment, and sub-experiment.
Classes
AssetEntry
Bases: TypedDict
One non-xdat asset record stored in the catalog.
Represents a single file or folder found on Drive that is not an xdat
dataset — for example a logs/ directory, a PowerPoint, or a writeup.
Attributes:
| Name | Type | Description |
|---|---|---|
asset_name |
str
|
The file or folder name as it appears on Drive
(e.g. |
asset_type |
Literal['folder', 'file']
|
|
date_folder |
str | None
|
Name of the top-level date-prefixed folder (depth 1), or
|
experiment |
str | None
|
Name of the depth-2 subfolder, or |
drive_path |
str
|
Slash-joined path from the root folder to the parent
folder of this asset (e.g. |
drive_id |
str
|
Google Drive ID of this file or folder. |
mime_type |
str
|
MIME type as reported by the Drive API. |
local_path |
str | None
|
Absolute local path to the downloaded file or folder, or
|
Catalog
Main interface for radiens-drive-catalog.
Wraps Google Drive scanning, local JSON catalog management, dataset and asset querying, and file download behind a single object.
Example
from radiens_drive_catalog import Catalog, Config
config = Config.from_file("config.json")
catalog = Catalog(config)
catalog.scan() # build catalog from Drive
df = catalog.list(date="2026-02") # query datasets
adf = catalog.list_assets(experiment="reaching") # query assets
path = catalog.get_path("rat01_session3") # download dataset if needed
path = catalog.get_asset_path("2026-02-15/reaching", "logs") # download asset if needed
Attributes
assets_df
property
The full assets catalog as a pandas DataFrame. Columns: asset_name, asset_type, date_folder, experiment, drive_path, drive_id, mime_type, local_path
df
property
The full dataset catalog as a pandas DataFrame. Columns: base_name, date_folder, experiment, drive_path, drive_file_ids, local_path
Functions
__init__
Initialize a Catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
Package configuration (Drive credentials, folder ID, local paths). |
required |
download
Download the xdat files for a dataset to local_data_dir.
After a successful download, persists the local_path back to the
catalog JSON so it survives future sessions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_name
|
str
|
The dataset identifier (shared filename stem). |
required |
Returns:
| Type | Description |
|---|---|
str
|
The local directory path where the files were written. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
download_asset
Download an asset (file or folder) to the local assets directory.
Assets are stored under {local_data_dir}/assets/{drive_path}/{asset_name}.
For folder assets the entire subtree is downloaded recursively.
After a successful download, persists the local_path back to the
catalog JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_path
|
str
|
The slash-joined path to the asset's parent folder
(e.g. |
required |
asset_name
|
str
|
The file or folder name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The local path to the downloaded file or folder. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the asset is not found in the catalog. |
get_asset_path
Return the local path for an asset, downloading if needed.
If the asset has not been downloaded yet, or if the recorded
local_path no longer exists on disk, the download is triggered
automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drive_path
|
str
|
The slash-joined path to the asset's parent folder
(e.g. |
required |
asset_name
|
str
|
The file or folder name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The local path to the downloaded file or folder. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the asset is not found in the catalog. |
get_path
Return the local directory path for a dataset, downloading if needed.
If the dataset has not been downloaded yet, or if the recorded
local_path no longer exists on disk, the download is triggered
automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_name
|
str
|
The dataset identifier (shared filename stem). |
required |
Returns:
| Type | Description |
|---|---|
str
|
The local directory path where the xdat files reside. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
list
Query the dataset catalog and return a filtered DataFrame.
Arguments act as hierarchical filters — each narrows the result further. Omitting an argument returns all values for that level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_folder
|
str | None
|
Exact name of the top-level date folder to filter on
(e.g. |
None
|
experiment
|
str | None
|
Exact name of the depth-2 experiment folder to filter on. |
None
|
Examples:
catalog.list() # everything catalog.list(date_folder="2026-02-15_batch") # one date folder catalog.list(date_folder="2026-02-15_batch", experiment="reaching") catalog.list(experiment="reaching") # across all dates
list_assets
Query the asset catalog and return a filtered DataFrame.
Arguments act as hierarchical filters. Omitting an argument returns all values for that level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_folder
|
str | None
|
Exact name of the top-level date folder to filter on
(e.g. |
None
|
experiment
|
str | None
|
Exact name of the depth-2 experiment folder to filter on. |
None
|
asset_type
|
Literal['folder', 'file'] | None
|
|
None
|
Examples:
catalog.list_assets() catalog.list_assets(date_folder="2026-02-15_batch", experiment="reaching") catalog.list_assets(asset_type="folder")
scan
Scan Drive recursively and rebuild the catalog JSON.
Any existing local_path entries are preserved so a rescan doesn't forget which datasets or assets have already been downloaded.
Config
dataclass
Configuration for radiens-drive-catalog.
All path fields (credentials_path, local_data_dir, catalog_path) support
~ and $ENV_VAR expansion and are resolved to absolute paths on construction.
Typically created via Config.from_file() rather than directly.
Attributes:
| Name | Type | Description |
|---|---|---|
credentials_path |
str
|
Path to the Google service account credentials JSON file. |
root_folder_id |
str
|
Google Drive folder ID of the data root folder. |
local_data_dir |
str
|
Local directory where datasets will be downloaded. |
catalog_path |
str
|
Path to the catalog JSON file (created by |
Functions
__post_init__
Expand ~ and $ENV_VARS in all path fields and resolve to absolute paths.
from_file
classmethod
Load config from a JSON file.
Resolution order when path is None:
RADIENS_DRIVE_CATALOG_CONFIGenvironment variable..secrets/config.jsonin the current working directory.config.jsonin the current working directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | None
|
Path to the config JSON file. When |
None
|
Returns:
| Type | Description |
|---|---|
Config
|
A |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no config file can be located. |
JSONDecodeError
|
If the config file is not valid JSON. |
TypeError
|
If the JSON fields do not match the |