Skip to content

Comments

SOHO: add PONEMAH data collector with Pydantic-validated config#85

Open
iezqrom wants to merge 21 commits intodevfrom
soho-init
Open

SOHO: add PONEMAH data collector with Pydantic-validated config#85
iezqrom wants to merge 21 commits intodevfrom
soho-init

Conversation

@iezqrom
Copy link
Collaborator

@iezqrom iezqrom commented Oct 30, 2025

This PR introduces Soho, a small client to collect telemetry data from PONEMAH (the software driving our implant telemetry probes for mouse core temperature). I’ve been using this code across projects with Amanda and Gamze; this brings it into poulet_py so we can reuse it consistently. I've done a bit of pydantic.

@iezqrom iezqrom requested a review from vkaramanis October 30, 2025 13:27
pyproject.toml Outdated
## Main modules ##
converters = ["poulet_py[seq]"]
hardware = ["poulet_py[camera, arduino, julabo, qst, triggers]"]
hardware = ["poulet_py[camera, arduino, julabo, qst, triggers, sensor]"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sensor has to be defined too under hardware section:
sensor = ["poulet_py[soho]"]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've resolved this by updating the hardware extra on line 84 to reference soho instead of sensor. The soho extra was already defined on line 77 with its pandas dependency, but the hardware aggregate was still pointing to the non-existent sensor extra. Now when someone installs poulet_py[hardware], it'll properly include the SOHO sensor dependencies along with the other hardware modules.

time.sleep(0.1)

@staticmethod
def log_error(error_message: str, error_log_file: Optional[str]) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need a function for logs? LOGGER can output all logs to a file if defined by env (not sure though if this is working yet, havent fixed the env problem)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, i'll remove this

output_path: Optional[str] = None
error_log_path: Optional[str] = None

class Soho:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this way SohoConfig is not much needed.

my proposal is for the Soho class to inherit from BaseModel and define there the required fields.
for internal private fields use PrivateAttr i.e. _private: int = PrivateAttr(default=1)

this way you ensure the validation and boundaries and all these setters getter can be minimized

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've refactored the Soho class to inherit from BaseModel directly, eliminating the separate SohoConfig class. The config fields (host, port, output_path, error_log_path) are now defined as Field attributes on Soho itself, and I've converted the private fields (_stop, _active, _collection_thread, _listener_thread) to use PrivateAttr as suggested. This simplifies the API, provides automatic validation through Pydantic, and aligns with the pattern used by other hardware classes like GPIOTrigger. I've also updated all references from self.config.host/self.config.port to self.host/self.port, and removed SohoConfig from the module exports. The class now follows a cleaner, more consistent structure whilst maintaining all existing functionality.

is this what you meant?

@iezqrom iezqrom changed the title Soho: add PONEMAH data collector with Pydantic-validated config SOHO: add PONEMAH data collector with Pydantic-validated config Jan 28, 2026
vkaramanis and others added 15 commits January 29, 2026 13:29
…t handling and improve import statements. Adjusted baseline temperature range in TCSStimulus class and refined data handling in Soho class.
… limits (20-45 °C) and adjust corresponding field description.
… docstrings, including usage examples and parameter descriptions for improved clarity and usability.
…ctionality to launch the Ponemah executable. Enhanced import statements and included a new helper function for managing Ponemah connections.
…ation, and add new attributes for error logging, output files, and data handling. Removed redundant attribute initializations from the constructor for cleaner code.
…ocking mechanism for thread safety and implementing an incremental data update method. Refactor data saving logic to ensure proper handling of output file and data state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants