Config¶
Purpose¶
The config module stores package-wide EasyIDP preferences in a small JSON file. It is the single public entry point for settings such as the demo dataset root, logger level, and startup banner display.
Most users should access it through easyidp.config:
import easyidp as idp
idp.config.set(data_dir="/path/to/easyidp.data")
data_dir = idp.config.get("data_dir")
Settings¶
data_dirRoot folder for EasyIDP demo datasets.
log_levelLogger level used by EasyIDP, such as
"INFO"or"DEBUG".show_bannerWhether EasyIDP shows the startup banner during import.
Functions¶
- easyidp.config.get(key: str | None = None) Any¶
Return current config value(s).
- Parameters:
key (str or None, optional) – Config key name.
Nonereturns a plain dict snapshot.- Returns:
Value for key, or a
dictwith all known settings.- Return type:
Any
- Raises:
KeyError – If key is not a recognised config key.
Examples
>>> from pathlib import Path >>> import tempfile >>> tmp = tempfile.TemporaryDirectory() >>> cfg = EasyIDPConfig(config_path=Path(tmp.name) / "config.json") >>> cfg.get("log_level") 'INFO' >>> sorted(cfg.get()) ['data_dir', 'log_level', 'show_banner'] >>> tmp.cleanup()
- easyidp.config.set(**kwargs: Any) EasyIDPConfig¶
Update config values and persist JSON immediately.
- Parameters:
**kwargs (Any) – One or more recognised config keys with new values.
- Returns:
Self (fluent API).
- Return type:
- Raises:
KeyError – If any key in kwargs is not recognised.
Examples
>>> from pathlib import Path >>> import tempfile >>> tmp = tempfile.TemporaryDirectory() >>> cfg = EasyIDPConfig(config_path=Path(tmp.name) / "config.json") >>> isinstance(cfg.set(log_level="DEBUG", show_banner=False), EasyIDPConfig) True >>> cfg.get("show_banner") False >>> tmp.cleanup()
- easyidp.config.reset() EasyIDPConfig¶
Restore factory defaults and persist JSON immediately.
- Returns:
Self (fluent API).
- Return type:
Examples
>>> from pathlib import Path >>> import tempfile >>> tmp = tempfile.TemporaryDirectory() >>> cfg = EasyIDPConfig(config_path=Path(tmp.name) / "config.json") >>> isinstance(cfg.set(log_level="DEBUG"), EasyIDPConfig) True >>> cfg.reset().get("log_level") 'INFO' >>> tmp.cleanup()
Advanced API¶
Most users should only call the module-level get(), set(), and
reset() functions above. Internally, easyidp.config creates one
module-level configuration object and exposes bound methods from it:
config = EasyIDPConfig()
get = config.get
set = config.set
reset = config.reset
This means idp.config.set(...) is the public shortcut for the singleton
configuration object’s set(...) method, not a request for users to
instantiate EasyIDPConfig themselves.
The contributor-facing configuration object and path helpers are documented on the hidden Config Advanced API page.