pyleco
Python implementation of the Laboratory Experiment COntrol (LECO) protocol
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 1 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.2%) to scientific vocabulary
Keywords
Repository
Python implementation of the Laboratory Experiment COntrol (LECO) protocol
Basic Info
Statistics
- Stars: 13
- Watchers: 4
- Forks: 4
- Open Issues: 16
- Releases: 13
Topics
Metadata Files
README.md
PyLECO
Python reference implementation of the Laboratory Experiment COntrol (LECO) protocol.
Note: LECO is still under development, such that the code and API might change. The LECO protocol branch pyleco-state contains the assumptions used in this project, which are not yet accepted into the LECO main branch. See this documentation for the LECO definitions including these assumptions. These things might change, if LECO defines them differently.
For a tutorial on how to get started, see GETTING_STARTED.md.
You are welcome to contribute, for more information see CONTRIBUTING.md.
Quick Start
- Install Python,
- install PyLECO with
pip install pylecoorconda install conda-forge::pyleco, - import the package
pylecoin your python scripts, - and use it as desired.
LECO Overview
Network Topology
PyLECO is an implementation of LECO, for the full protocol specifications please visit https://github.com/pymeasure/leco-protocol. LECO offers a protocol for data exchange, for example for laboratory experimental control.
There exist two different communication protocols in LECO.
- The control protocol allows to exchange messages between any two Components in a LECO network, which is useful for controlling devices.
- The data protocol is a broadcasting protocol to send information to all those, who want to receive it, which is useful for regular measurement data or for log entries.
A LECO network needs at least one Coordinator (server), which routes the messages among the connected Components.
Each Component has a name unique in the network.
This name consists in the name of the Coordinator they are connected to and their own name.
For example N1.component1 is the full name of component1 connected to the Coordinator of the Namespace N1.
That Coordinator itself is called N1.COORDINATOR, as Coordinators are always called COORDINATOR.
Remote Procedure Calls
The default messaging content of the control protocol are remote procedure calls (RPC) according to JSON-RPC.
RPC means, that you execute a method (or procedure) on a remote Component.
For example you have an Actor, which is for example a Component controlling a measurement instrument.
In order to set the output of that measurement instrument, you want to call the set_output method of that instrument.
For that purpose, you send a message which encodes exactly that (via jsonrpc): the method to call and the parameters of that method.
Usage of the Control Protocol
Minimum Setup
For a minimum setup, you need:
- a Coordinator (just execute
coordinatorin your terminal or run thecoordinator.pyfile with your Python interpreter), - one Component.
For example, you can use a Communicator instance to send/receive messages via LECO protocol.
The following example requests the list of Components connected currently to the Coordinator:
```python from pyleco.utils.communicator import Communicator
c = Communicator(name="TestCommunicator") connectedcomponents = c.askrpc(method="sendlocalcomponents") print(connected_components) ```
Instrument Control
Let's say you have an instrument with a pymeasure driver Driver, which you want to control.
You need to start (in different threads):
- a Coordinator (as described above),
- an
Actorinstance listening to commands and controlling the instrument:actor = Actor(name="inst_actor", cls=Driver). For an example see thepymeasure_actor.pyin the examples folder, - a
TransparentDirector:director=TransparentDirector(actor="inst_actor"). Theactorparameter has to match the Actor'snameparameter. For an example of a measurement script seemeasurement_script.pyin the examples folder.
If you want to set some property of the instrument (e.g. instrument.voltage = 5), you can just use the director transparently: director.device.voltage = 5.
In the background, the TransparentDirector, which does not have a device, sends a message to the Actor to set that parameter.
The Actor in turn sets that parameter of the instrument driver, which in turn will send some command to the device to take an appropriate action (e.g. setting the voltage to 5 V).
Currently you cannot call methods in a similar, transparent way, without manual intervention.
You can add RemoteCall descriptor (in transparent_director module) to the director for each method call you want to use.
Afterwards you can use these methods transparently similar to the property shown above.
Overview of Offered Packages and Modules
PyLECO offers the following subpackages and modules. For more information and for examples see the docstrings of the relevant methods and classes.
- The
coresubpackage contains elements necessary for implementing LECO and for interacting with PyLECO, for example:- The
MessageandDataMessageclass help to create and interpret LECO messages for the control and broadcasting protocol, respectively. - The
leco_protocolsmodule contains Protocol classes for the different LECO Components, in order to test, whether a Component satisfies the LECO standard for communicating with other programs. - The
internal_protocolsmodule contains Protocol classes which define the API access to PyLECO.
- The
- The
utilssubpackage contains modules useful for creating LECO Components.- The
Communicatorcan send and receive messages, but neither blocks (just for a short time waiting for an answer) nor requires an extra thread. It satisfies theCommunicatorProtocoland is useful in scripts. - The
MessageHandleralso satisfies theCommunicatorProtocol, but handles incoming messages in a continuous loop (blocking until stopped). It is useful for creating standalone scripts, like tasks for the Starter. - The
ExtendedMessageHandleradds the capability to subscribe and receive data protocol messages. - The
Listeneroffers an interface according to theCommunicatorProtocol, but listens at the same time in an extra thread for incoming messages (with anExtendedMessageHandler). It is useful if you want to react to incoming messages (via data or control protocol) and if you want to send messages of your own accord, for example for GUI applications.
- The
- The
coordinatorssubpackage contains the different Coordinators.Coordinatoris the Coordinator for the control protocol (exchanging messages).proxy_serveris the Coordinator for the data protocol (broadcasting).
- The
actorssubpackage contains Actor classes to control devices. - The
managementsubpackage contains Components useful for experiment management.- The
Startercan execute tasks in separate threads. A task could be an Actor controlling some Device. - The
DataLoggerlistens to published data (via the data protocol) and collects them.
- The
- The
directorssubpackage contains Directors, which facilitate controlling actors or management utilities.- The
Directoris a base Director. It can communicate via any util, which implements theCommunicatorProtocol. - For example the
CoordinatorDirectorhas a method for getting Coordinators and Components connected to a Coordinator. - The
TransparentDirectorreads / writes all messages to the remote actor, such that you use the director'sdeviceas if it were the instrument itself.
- The
PyLECO extras
The pyleco-extras package contains additional modules.
Among them are GUIs controlling the DataLogger and the Starter.
Owner
- Name: PyMeasure
- Login: pymeasure
- Kind: organization
- Website: https://pymeasure.readthedocs.io
- Repositories: 4
- Profile: https://github.com/pymeasure
Scientific measurements with Python
Citation (CITATION.cff)
cff-version: 1.2.0
title: "PyLECO"
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- family-names: Burger
given-names: Benedikt
orcid: "https://orcid.org/0000-0003-3302-3674"
- family-names: Klebel-Knobloch
given-names: Benjamin
- family-names: Buchner
given-names: Christoph
identifiers:
- type: doi
value: 10.5281/zenodo.10837366
doi: 10.5281/zenodo.10837366
repository-code: 'https://github.com/pymeasure/pyleco'
abstract: >-
Python implementation of the Laboratory Experiment COntrol
(LECO) protocol.
publisher:
- name: Zenodo
version: 0.6.0
date-released: 2025-08-28
GitHub Events
Total
- Create event: 24
- Release event: 4
- Issues event: 20
- Watch event: 1
- Delete event: 22
- Issue comment event: 38
- Push event: 67
- Pull request review comment event: 1
- Pull request event: 43
Last Year
- Create event: 24
- Release event: 4
- Issues event: 20
- Watch event: 1
- Delete event: 22
- Issue comment event: 38
- Push event: 67
- Pull request review comment event: 1
- Pull request event: 43
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 51
- Total pull requests: 95
- Average time to close issues: about 1 month
- Average time to close pull requests: about 1 month
- Total issue authors: 3
- Total pull request authors: 4
- Average comments per issue: 0.92
- Average comments per pull request: 1.83
- Merged pull requests: 79
- Bot issues: 0
- Bot pull requests: 7
Past Year
- Issues: 14
- Pull requests: 41
- Average time to close issues: 13 days
- Average time to close pull requests: 1 day
- Issue authors: 2
- Pull request authors: 2
- Average comments per issue: 0.14
- Average comments per pull request: 0.83
- Merged pull requests: 38
- Bot issues: 0
- Bot pull requests: 7
Top Authors
Issue Authors
- BenediktBurger (43)
- bmoneke (3)
- Ashwolaa (1)
Pull Request Authors
- BenediktBurger (124)
- dependabot[bot] (7)
- bmoneke (5)
- bklebel (3)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 3,308 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 13
- Total maintainers: 2
pypi.org: pyleco
Python reference implementation of the Laboratory Experiment COntrol (LECO) protocol
- Homepage: https://github.com/pymeasure/pyleco
- Documentation: https://pyleco.readthedocs.io/
- License: MIT License Copyright (c) 2023-2025 PyLECO Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
Latest release: 0.6.0
published 6 months ago
Rankings
Maintainers (2)
Dependencies
- pyzmq *
- MishaKav/pytest-coverage-comment main composite
- actions/checkout v3 composite
- ammaraskar/sphinx-problem-matcher master composite
- chartboost/ruff-action v1 composite
- mamba-org/setup-micromamba v1 composite
- actions/checkout v4 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish v1.8.11 composite