Skip to content

radiens_drive_catalog.config

config.py

Configuration management for radiens-drive-catalog.

Config is loaded from a JSON file. The file is located using the following resolution order (first match wins):

  1. Explicit path argument to Config.from_file().
  2. RADIENS_DRIVE_CATALOG_CONFIG environment variable.
  3. .secrets/config.json in the current working directory.
  4. config.json in the current working directory.

Example config JSON: { "credentials_path": "/path/to/service_account.json", "root_folder_id": "1aBcDeFgHiJkLmNoPqRsTuVw", "local_data_dir": "/data/neural", "catalog_path": "/data/neural/catalog.json" }

Classes

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 Catalog.scan()).

Functions

__post_init__
__post_init__()

Expand ~ and $ENV_VARS in all path fields and resolve to absolute paths.

from_file classmethod
from_file(path=None)

Load config from a JSON file.

Resolution order when path is None:

  1. RADIENS_DRIVE_CATALOG_CONFIG environment variable.
  2. .secrets/config.json in the current working directory.
  3. config.json in the current working directory.
  4. ~/.config/radiens-drive/config.json in the user's home directory.
  5. /etc/radiens-drive/config.json.

Parameters:

Name Type Description Default
path str | None

Path to the config JSON file. When None, the resolution order above is used.

None

Returns:

Type Description
Config

A Config instance with all paths expanded and resolved.

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 Config field names.