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):
- Explicit path argument to
Config.from_file(). RADIENS_DRIVE_CATALOG_CONFIGenvironment variable..secrets/config.json, thenconfig.json, searched starting in the current working directory and then each parent directory up to the filesystem root (closest directory wins).
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" }
Relative paths in the config file (credentials_path, local_data_dir,
catalog_path) are resolved against the config file's own directory, not
the process's current working directory. This keeps a config portable: it
works the same whether loaded from a repo-root script or a notebook running
in a subdirectory.
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.
When loaded via Config.from_file(), relative paths resolve against the
config file's own directory. When constructed directly (Config(...)),
relative paths resolve against the current working directory.
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.json, thenconfig.json, searched starting in the current working directory and then each parent directory up to the filesystem root (closest directory wins).~/.config/radiens-drive/config.jsonin the user's home directory./etc/radiens-drive/config.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | None
|
Path to the config JSON file. When |
None
|
Relative paths in the config file are resolved against the config file's own directory, not the current working directory.
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 |