LAPLACE Server (LAPLACE-LHC)
Server for the LAPLACE-LHC project.
This package provides a lightweight, command-driven server running in its own non-deamon thread, designed to exchange structured messages with clients using a defined protocol. It is independent from GUI frameworks, while still allowing seamless integration with PyQt through callback-based controllers.
Features
- ZMQ-based TCP server
- Runs in its own non-daemon thread
- Protocol-based message validation and dispatching
- Configurable command callbacks
- Optional PyQt6 signal integration (without QObject inheritance)
- Clear separation between protocol, validation, and handlers
Installation
From PyPI:
pip install laplace-server
Or from source (editable mode):
git clone https://github.com/LOA-APPLi/laplace_server.git
cd laplace_server
pip install -e .
Basic Usage
Start a server
from laplace_server import ServerLHC
from laplace_server.protocol import DEVICE_MOTOR
server = ServerLHC(
name="my_server",
address="tcp://*:5555",
freedom=2,
device=DEVICE_MOTOR
)
server.start()
Update server data
server.set_data({"x": 1.2, "y": 3.4})
The stored data is transmitted when a CMD_GET request is received.
Stop the server
server.stop()
⚠️ The server runs in its own non-daemon thread and must be explicitly stopped to allow the Python process to exit cleanly.
Protocol Overview
The server communicates using a lightweight, JSON-based message protocol over ZMQ. Each message must follow a well-defined structure and include a protocol version to ensure compatibility between clients and servers.
Message Structure
All messages exchanged with the server must be JSON objects with the following fields:
version— Protocol version identifiercmd— Command namefrom— Sender identifierpayload— Command-specific data (may be empty)
Example message:
{
"version": "0.1.6",
"cmd": "GET",
"from": "client_1",
"payload": {}
}
Messages that do not comply with this structure are rejected and may trigger an error response from the server.
Commands
The protocol defines a fixed set of commands used to interact with the server, including:
CMD_INFO— Request server informationCMD_PING— Check server availabilityCMD_GET— Retrieve the server dataCMD_SET— For motor realted server, set new positionsCMD_SAVE— Indicate a saving pathCMD_OPT— Send optimization-related dataCMD_STOP— Request server shutdown
Each command is handled by a dedicated handler function on the server side.
Protocol Versioning
The protocol version is defined by laplace_server.protocol.PROTOCOL_VERSION and is
validated for every incoming message. If a version mismatch is detected, the message
is rejected to prevent undefined behavior.
The protocol version is independent from the package release version
(__version__) and is only updated when the message format or semantics change.
PyQt6 Integration
The server does not inherit from QObject.
Instead, callbacks can be connected to a ServerController, which emits PyQt6
signals.
from laplace_server import ServerLHC
from laplace_server.server_controller import ServerController
server = ServerLHC(...)
controller = ServerController()
server.set_on_get(controller.on_get)
server.set_on_opt(controller.on_opt)
This design keeps the server independent from PyQt while remaining GUI-friendly.
Project Structure
laplace_server/
├── __init__.py
├── server_lhc.py # Main server implementation
├── server_controller.py # PyQt6 signal controller (optional)
├── protocol.py # Protocol constants and helpers
├── validations.py # Input and message validation utilities
├── get_ip.py # helper providing the ip of the process
└── handlers/ # Command handlers
├── handler_get.py # handle the CMD_GET
├── handler_info.py # handle the CMD_INFO
├── ...
Versioning
-
laplace_server.__version__Package release version (matches the PyPI version). -
laplace_server.protocol.PROTOCOL_VERSIONInternal communication protocol version, used to validate messages and ensure compatibility between clients and servers.
These two versions are intentionally independent.
Error Handling
- Validation functions return human-readable error messages or
None - Errors are logged, not raised, for expected runtime issues
- The server decides how to react (reply with error, ignore, continue)
License
GPL-3.0
Status
This project is actively used within the LAPLACE-LHC ecosystem and is intended for controlled environments rather than general-purpose networking.
Metadata
Release files for laplace-server 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| laplace_server-0.2.0.tar.gz | 27.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| laplace_server-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.7 kB
Release files / laplace_server-0.2.0.tar.gz
| Download URL | laplace_server-0.2.0.tar.gz |
|---|---|
| Size | 27.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b40eeaee87174e2cddbb881c4425f9e33cfb2b1b8ae9843e533a0fd3c8060d23
|
|
BLAKE2b-256 checksum How to use checksums |
7a5af1fa315a348369d41e84235cf8d69feb46867d4229260bb0e0cbcd39784c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / laplace_server-0.2.0-py3-none-any.whl
| Download URL | laplace_server-0.2.0-py3-none-any.whl |
|---|---|
| Size | 33.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fcfc589cfdbae24b0751efe3d37fdc94cae6780d1704ab801e600413b131073e
|
|
BLAKE2b-256 checksum How to use checksums |
1bff2ca357047569d867c8df81c654fadb4748c81b4d293e95ae85b042f90592
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for laplace-server 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.