This document outlines the revised, official two-phase strategy for integrating the StemLab library (a headless fork of pyrpl) with PyMoDAQ. The primary objective is to deliver a stable, maintainable, and user-friendly plugin for controlling Red Pitaya-based hardware from within the PyMoDAQ ecosystem. The decision to use StemLab is a direct result of insurmountable dependency conflicts with the original pyrpl library.
- Phase 1 focuses on rapid development via a direct, in-process plugin using
StemLab. This provides the fastest path to a functional prototype. - Phase 2 transitions to a robust, bridge server architecture for production use, ensuring maximum stability and process isolation.
The "Contract First" principle remains the strategic foundation of this plan.
- Project Tracking: All tasks will continue to be tracked on the Zen MPC Server under the project "PyRPL-PyMoDAQ Integration."
- Version Control: All code will be managed on the Octocode MCP Server using the established Git branching strategy (
main,develop,feature/*).
| Task ID | Task Description | Dependencies | Definition of Done |
|---|---|---|---|
| T01 | Update pyproject.toml with StemLab |
None | The pyrpl dependency is replaced with a Git dependency for ograsdijk/StemLab. |
| T02 | Refactor PyrplWorker to use StemLab |
T01 | The worker class in hardware/pyrpl_worker.py is updated to import and instantiate StemLab instead of Pyrpl. |
| T03 | Run Unit & Integration Test Suite | T02 | All tests in tests/unit and tests/integration pass successfully using the StemLab-based worker. |
| T04 | Run End-to-End Hardware Tests | T03 | All tests in tests/e2e, marked with @pytest.mark.hardware, pass against the real hardware at 100.107.106.75. |
| T05 | Finalize Documentation | T04 | The README.md and TESTING.md files are updated to reflect the use of StemLab and the successful test runs. |
| T06 | Prepare for Release | T05 | The develop branch is merged into main, and a release candidate is tagged. |
(This section remains unchanged. The PyrplInstrumentContract defined in src/pymodaq_plugins_pyrpl/hardware/pyrpl_contract.py is compatible with the StemLab API and will continue to be the guiding interface for the project.)
The strategy remains the same, but the implementation will now use the stemlab library. The PyrplWorker will instantiate StemLab, and because StemLab is headless, we anticipate none of the previous GUI-related errors.
Target File: src/pymodaq_plugins_pyrpl/hardware/pyrpl_worker.py
Instructions: The only required change is to the import and instantiation logic.
# src/pymodaq_plugins_pyrpl/hardware/pyrpl_worker.py
from qtpy.QtCore import QObject, Signal, Slot
from typing import Dict, Tuple, Optional
import numpy as np
# MODIFICATION: Import StemLab instead of Pyrpl
from stemlab import StemLab
from .pyrpl_contract import PyrplInstrumentContract
class PyrplWorker(QObject, PyrplInstrumentContract):
# ... (signals remain the same) ...
def __init__(self):
super().__init__()
# MODIFICATION: The type hint is now StemLab
self.pyrpl: Optional[StemLab] = None
def connect(self, config: Dict) -> bool:
try:
# MODIFICATION: Instantiate StemLab
self.pyrpl = StemLab(**config)
self.status_update.emit(f"Successfully connected to {self.get_idn()}")
return True
except Exception as e:
self.status_update.emit(f"Connection to StemLab failed: {e}")
return False
# ... (all other methods remain identical, as the API is the same) ...(This section remains conceptually unchanged. The PyrplBridgeServer will still instantiate the PyrplWorker. Since the worker is now based on StemLab, the server will automatically use the headless library, resolving all previous instability issues.)
The existing test suite (unit, integration, e2e) is still valid. The goal is now to run this suite against the StemLab-based implementation and achieve a passing result.
- Unit & Integration Tests: These should now pass without any modifications to third-party libraries, as the root cause of the errors (GUI dependencies) has been eliminated.
- End-to-End Tests: These will be the ultimate validation. We will execute the
test_hardware.pysuite against the live Red Pitaya to confirm thatStemLabprovides the same level of control and data integrity as the originalpyrpllibrary.
(This section remains unchanged for now. The end-user experience is identical, as the architectural change is internal. The user will still run the pyrpl_bridge_server command and use the BridgeClient plugin.)