Skip to main content

Interfaces used internally

config.json

The config file under config/config.json contains all parameters to tweak Pyra's operation. Schema: /packages/core/types/config.py.

state.json

The state file is generated under logs/state.json. Pyra Core writes its internal values to this file. The state file is used to communicate between modules as well as with the "outside" world (UI, CLI). Schema: /packages/core/types/state.py.

Validation strategy

MyPy will make full use of the schemas included above (see testing). Whenever loading the config- or state files, the respective schema validation will run. Hence, Pyra will detect when a JSON file does not have the expected schema and raise a precise Exception. All internal code interfaces (function calls, etc.) are covered by the strict MyPy validation.

info

With pyra-cli config get, only the schema will be validated, not the value rules. This command is necessary because the UI can deal with invalid values, but not with an invalid schema.

How the UI reads logs and state

The UI reads the log files and the state file periodically using Tauri's file system API. We tested using sockets or file watchers, but both did not work well on Windows, and reading it periodically is the most basic implementation.

Logging

All scripts that output messages at runtime should use the Logger class:

from packages.core import utils

logger = utils.Logger()

logger.debug("...")
logger.info("...")
logger.warning("...")
logger.critical("...")
logger.error("...")


# By default, it will log from a "pyra.core" origin
logger = utils.Logger()

# Here, it will log from a "camtracker" origin
logger = utils.Logger(origin="camtracker")

Messages from all log levels can be found in logs/debug.log, and messages from levels INFO/WARNING/CRITICAL/ERROR can be found in logs/info.log.

Activity Log

Pyra Core stores its activity (is it measuring, are there errors, etc.) in logs/activity/activity-YYYY-MM-DD.json. This is the same information as in the regular log files but significantly easier to parse. Schema: /packages/core/types/activity_history.py.

Pyra CLI commands from UI

All write operations from the UI (update config, etc.) are done by running Pyra CLI commands. This is why we have to use the global Python interpreter instead of a virtual environment: We did not make it work that the shell interface from Tauri can make use of a virtual environment.