pyccapt.control.core package
Submodules
pyccapt.control.core.baking_loging module
pyccapt.control.core.com_ports module
pyccapt.control.core.control_data_tool module
- pyccapt.control.core.control_data_tool.concatenate_datasets(hdf5_file_path_1, hdf_file_path_2, index_2)[source]
Concatenate datasets in nested HDF5 groups.
- pyccapt.control.core.control_data_tool.copy_npy_to_hdf_surface_concept(path, hdf5_file_name)[source]
copy npy data to hdf5 file for surface concept TDC
- Parameters:
path – path to the npy files
hdf5_file_name – name of the hdf5 file
- Returns:
None
- pyccapt.control.core.control_data_tool.correct_surface_concept_old_data(hdf5_file_path)[source]
correct surface concept old data
- Parameters:
hdf5_file_path – path to the hdf5 file
- Returns:
None
- pyccapt.control.core.control_data_tool.crop_dataset_to_new_file(original_path, new_path, num_of_samples)[source]
Crop dataset and save to a new file.
- Parameters:
original_path – Path to the original dataset.
new_path – Path to save the cropped dataset.
num_of_samples – Number of samples to keep.
- Returns:
None
pyccapt.control.core.experiment_statistics module
pyccapt.control.core.hdf5_creator module
pyccapt.control.core.loggi module
Application and per-experiment logging for the pyccapt control package.
There are two layers:
Application logging — configured once at GUI startup via
setup_application_logging(). This installs:A rotating per-day file handler under
<project_root>/files/logs/gui/gui_<YYYY-MM-DD>.log. Files rotate at 5 MiB, with 10 backups kept. The intent is that this log captures everything the operator needs to diagnose what happened in a given day, without growing without bound.A console handler that mirrors records to stderr at INFO level (so the operator still sees the same kind of output that
printwas producing before).logging.captureWarnings(True)so Python warnings land in the log.A
sys.excepthookreplacement so otherwise-uncaught exceptions are written to the log with a full traceback before propagating.An optional
sys.stdout/sys.stderrmirror: everyprintcall in the GUI process is duplicated into the log without losing console output.
Per-experiment logging —
logger_creator()returns a logger whose own dedicated file lives in the experiment’smeta_datafolder (<exp>/meta_data/apt.logby default). Because the per-experiment logger inherits from the root logger configured in step 1, every experiment record is also captured in the daily GUI log, giving a single chronological view across multiple experiments while keeping each experiment’s own folder self-contained for archival.
Both functions are idempotent: calling them multiple times will not produce duplicate handlers or duplicate log lines.
- pyccapt.control.core.loggi.log_configuration_snapshot(logger: Logger, conf: dict[str, Any], variables: Any | None = None) None[source]
Log a stable subset of config keys so we can compare runs after the fact.
This is informational only and never raises.
- pyccapt.control.core.loggi.logger_creator(script_name: str, variables: Any, log_name: str, path: PathLike[str] | str) Logger[source]
Create or fetch a per-experiment logger writing to
<path>/<log_name>.This signature matches the historical API and is used by
apt_exp_control.pyto attach a dedicated log file to each experiment’smeta_datafolder.Behaviours:
Inherits from the root logger, so the same records also appear in the GUI session log configured by
setup_application_logging().Has its own dedicated file handler in the experiment folder.
Is idempotent: a duplicate file handler is not created on repeat calls.
Always returns a working logger object. If the file handler cannot be attached (permissions, missing folder, etc.) the returned logger still accepts
.info/.warning/.exceptioncalls — they just won’t be persisted to the experiment file. This avoids cascadingAttributeError: 'NoneType' object has no attribute 'info'failures later in the experiment hot path.
- Parameters:
script_name – Logger name. Conventional value is
"apt".variables – Shared variables namespace (currently unused, kept for backwards compatibility with the previous signature).
log_name – File name (e.g.
"apt.log").path – Directory in which to create the file. Created if missing.
- Returns:
A configured
logging.Logger.
- pyccapt.control.core.loggi.setup_application_logging(project_root: PathLike[str] | str, *, console_level: int = 20, file_level: int = 10, mirror_stdio: bool = True) Logger[source]
Configure the root logger for the running pyccapt process.
- Parameters:
project_root – Project root directory (the folder that contains
config.tomlandfiles/). The GUI log file is created under<project_root>/files/logs/gui/.console_level – Verbosity for the console mirror. The file always records
file_leveland below regardless of console level.file_level – Verbosity for the rotating file. Defaults to DEBUG so the log file always contains the most detail available.
mirror_stdio – When True (the default),
printoutput is also recorded in the log. Console output is preserved.
- Returns:
The
pyccapt.guilogger. Returning a child logger here, rather than the root logger, gives downstream code a sensible default name for records that do not specify their own logger.
pyccapt.control.core.read_files module
File-loading helpers for the control package.
- pyccapt.control.core.read_files.load_config_file(config_file_path: str | Path) dict[str, Any][source]
Load a control configuration file from .toml.
- Parameters:
config_file_path – Absolute or relative path to the config file.
- Returns:
Parsed config dictionary.
- Raises:
ValueError – If file extension is unsupported.
- pyccapt.control.core.read_files.normalize_control_config(config: dict[str, Any]) dict[str, Any][source]
Normalize supported control config toggle aliases to legacy values.
- pyccapt.control.core.read_files.read_json_file(json_file_path: str | Path) dict[str, Any][source]
Read a JSON file and return its content as a dictionary.
- Parameters:
json_file_path – Absolute or relative path to the JSON file.
- Returns:
Parsed JSON content.
- Raises:
FileNotFoundError – If the file does not exist.
ValueError – If the file does not contain a JSON object.
json.JSONDecodeError – If the file content is invalid JSON.
- pyccapt.control.core.read_files.read_toml_file(toml_file_path: str | Path) dict[str, Any][source]
Read a TOML file and return its content as a dictionary.
- Parameters:
toml_file_path – Absolute or relative path to the TOML file.
- Returns:
Parsed TOML content.
- Raises:
FileNotFoundError – If the file does not exist.
ValueError – If the file does not contain a TOML object.
tomllib.TOMLDecodeError – If the file content is invalid TOML.