easyidp.config Advanced API

This page documents contributor-facing configuration internals. Ordinary users should prefer the module-level get(), set(), and reset() functions on the main Config page.

Classes

class easyidp.config.EasyIDPConfig(config_path: Path = <factory>, data_dir: Path = <factory>, log_level: str = 'INFO', show_banner: bool = True)

JSON-backed package configuration.

Parameters:

config_path (pathlib.Path, optional) – JSON config file path. Defaults to the platform user config path.

Returns:

Mutable session configuration object.

Return type:

EasyIDPConfig

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.get("log_level")
'DEBUG'
>>> tmp.cleanup()

Notes

set() and reset() persist JSON immediately. get() re-reads the file on each call so manual edits are visible.

get(key: str | None = None) Any

Return current config value(s).

Parameters:

key (str or None, optional) – Config key name. None returns a plain dict snapshot.

Returns:

Value for key, or a dict with 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()
reset() EasyIDPConfig

Restore factory defaults and persist JSON immediately.

Returns:

Self (fluent API).

Return type:

EasyIDPConfig

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()
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:

EasyIDPConfig

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()

Functions

easyidp.config.default_config_path() Path

Return the default EasyIDP JSON config path.

Returns:

Platform-specific config file path.

Return type:

pathlib.Path

Examples

>>> default_config_path().name
'config.json'

Notes

This function only computes a path and does not create files.

easyidp.config.default_data_dir() Path

Return the default EasyIDP dataset directory.

Returns:

Platform-specific data root path.

Return type:

pathlib.Path

Examples

>>> default_data_dir().name
'easyidp.data'