config_io
tit.config_io ¶
JSON serialisation for config dataclasses.
Provides helpers to serialise typed config dataclasses (with Enum fields, nested dataclasses, and union-typed ROI/electrode specs) to JSON files and read them back.
Public API¶
serialize_config
Convert a config dataclass to a JSON-serialisable dict (with
project_dir injection).
write_config_json
Serialise a config dataclass to a temporary JSON file.
read_config_json
Read a JSON config file and return the parsed dict.
Examples¶
from tit.config_io import write_config_json, read_config_json path = write_config_json(my_flex_config, prefix="flex") data = read_config_json(path)
See Also¶
tit.opt.config : FlexConfig and ExConfig dataclasses.
tit.sim.config : Montage dataclass.
serialize_config ¶
Convert a config dataclass to a JSON-serialisable dict.
Handles Enum fields (via .value), nested dataclasses (recursed),
union-typed ROI / electrode specs (injects a _type discriminator),
and None values (preserved as JSON null).
Also injects project_dir from the active :class:~tit.paths.PathManager
so that subprocess entry points can initialise their own singleton.
Parameters¶
config : dataclass instance
Any config dataclass (e.g., FlexConfig, ExConfig).
Returns¶
dict JSON-serialisable dictionary representation of config.
See Also¶
write_config_json : Serialise and write to a temp file in one step. read_config_json : Read a JSON config back into a dict.
Source code in tit/config_io.py
write_config_json ¶
Serialise a config dataclass to a temporary JSON file.
Parameters¶
config : dataclass instance
Config object to serialise.
prefix : str, optional
Filename prefix for the temp file. Default is "config".
Returns¶
str Absolute path to the created JSON file.
See Also¶
serialize_config : Convert to dict without writing to disk. read_config_json : Read a JSON config file.
Source code in tit/config_io.py
read_config_json ¶
Read a JSON config file and return the parsed dict.
Parameters¶
path : str Path to the JSON file.
Returns¶
dict Parsed JSON contents.
See Also¶
write_config_json : Create a config JSON file from a dataclass.