matterlab_valves
matterlab_valves is a Python package for controlling several valve controllers used in the Matter Lab. It provides a shared switching-valve interface plus device-specific drivers built on top of matterlab_serial_device.
Supported Devices
JKem4in1Valve: classic JKem 4-in-1 serial valve controllerJKemNewValve: newer JKem serial valve protocolValcoSelectionValve: Valco selection valvesIdexValve: IDEX selection valvesRunzeSelectionValve: Runze RS485 selection valvesSwitchingValve: shared abstract base class for valve-like devices
Installation
Install the package:
pip install matterlab_valves
For development:
pip install -e .[dev]
The package depends on matterlab_serial_device, which is installed automatically as a runtime dependency.
Quick Start
Example with a Valco valve:
from matterlab_valves import ValcoSelectionValve
valve = ValcoSelectionValve(
com_port="COM5",
num_port=10,
ports={"home": 1, "collect": 2},
)
print("Current port:", valve.port)
valve.switch_port("collect")
print("Current port:", valve.port)
All valve implementations expose a port property for reading and setting the active position. If you provide a ports mapping, you can use human-readable names with switch_port(...).
Device Overview
JKem 4-in-1
Required parameters:
com_portvalve_num
Example:
from matterlab_valves import JKem4in1Valve
valve = JKem4in1Valve(
com_port="COM11",
valve_num=3,
ports={"load": 1, "inject": 2},
)
valve.port = 1
valve.switch_port("inject")
JKem New
Required parameters:
com_portvalve_num
Example:
from matterlab_valves import JKemNewValve
valve = JKemNewValve(
com_port="COM11",
valve_num=1,
ports={"load": 1, "inject": 2},
)
print(valve.port)
Valco Selection Valve
Required parameters:
com_portnum_port
Example:
from matterlab_valves import ValcoSelectionValve
valve = ValcoSelectionValve(
com_port="COM5",
num_port=10,
ports={"home": 1, "collect": 2},
)
valve.port = 2
valve.switch_port("home")
IDEX Selection Valve
Required parameters:
com_portnum_port
from matterlab_valves import IdexValve
valve = IdexValve(com_port="COM5", num_port=10, ports={"load": 1, "collect": 2})
print(valve.port)
valve.switch_port("collect")
valve.home()
The IDEX driver reads the position with S, moves with P0XX (hexadecimal port),
and homes with M. A response containing * raises IdexValveBusyError when
reading or moving. Like the Valco driver, initialization homes the valve unless
connect_hardware=False is passed.
Runze Selection Valve
Required parameters:
com_portaddressnum_port
Example:
from matterlab_valves import RunzeSelectionValve
valve = RunzeSelectionValve(
com_port="COM3",
address=0,
num_port=10,
ports={"home": 1, "collect": 2},
)
valve.port = 2
valve.switch_port("home")
Examples
Readable usage examples live in examples/:
examples/test_sim.py: one-click simulation-only test runnerexamples/real_devices.py: human-readable hardware usage examplesexamples/README.md: short guide to the examples directory
Run the simulation suite with:
python examples/test_sim.py
Testing
Simulation Tests
The simulation suite is the default validation layer and is safe for CI.
One-click run:
python examples/test_sim.py
Direct pytest run:
pytest tests/test_jkem_4in1_sim.py tests/test_jkem_new_sim.py tests/test_valco_selection_sim.py tests/test_idex_valve_sim.py tests/test_runze_selection_sim.py tests/test_switching_valve.py
Hardware Tests
Hardware tests are present for all supported valve families, but they are opt-in because physical devices may not be connected in every environment.
Available hardware test files:
tests/test_jkem_4in1_real.pytests/test_jkem_new_real.pytests/test_valco_selection_real.pytests/test_runze_selection_real.py
They are marked with @pytest.mark.real and are skipped unless --run-real is provided.
Example:
pytest tests/test_jkem_4in1_real.py --run-real --com-port COM11 --valve-num 3
Hardware configuration may be supplied through CLI flags or environment variables:
--com-portorVALVE_COM_PORT--num-portorVALVE_NUM_PORT--addressorVALVE_ADDRESS--valve-numorVALVE_VALVE_NUM
Development
Useful commands:
pytest
ruff check .
ruff format .
The default pytest configuration includes timeout, rerun, and coverage options from pyproject.toml.
Package Layout
src/matterlab_valves/
base_valve.py
jkem_4in1_valve.py
jkem_new.py
runze_valve.py
valco_selection_valve.py
idex_valve.py
tests/
examples/
License
This project is distributed under the MIT License. See LICENSE for details.
Metadata
Release files for matterlab-valves 1.2.3
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 | Actions |
|---|---|---|---|---|
| matterlab_valves-1.2.3.tar.gz | 21.1 kB | Without provenance | Details for matterlab_valves-1.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| matterlab_valves-1.2.3-py3-none-any.whl | Python 3 | none | any | Details for matterlab_valves-1.2.3-py3-none-any.whl |
Total release size: 37.8 kB
Release files / matterlab_valves-1.2.3.tar.gz
| Download URL | matterlab_valves-1.2.3.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c51028ec16d247c5cfa5673b45eed109babfaec193439b60f479ae5aa780bec
|
|
BLAKE2b-256 checksum How to use checksums |
8632071dc4dd2463482c3eadee3eb60d5feed3133f882e1e599f3a502778ef5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.0
|
Release files / matterlab_valves-1.2.3-py3-none-any.whl
| Download URL | matterlab_valves-1.2.3-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
781fe758c6e5990a2306629eb426dc704f87d1870c4c336be536ba32bd733e83
|
|
BLAKE2b-256 checksum How to use checksums |
0519e79dedffcf8e52615d5f479b4bd1bea6ed87e8c1cc06d74371d972fe73b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.0
|
Security for matterlab-valves 1.2.3
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.