opensemantic.lab
Python models and controllers for the world.opensemantic.lab page package.
Builds on opensemantic.base (DataToolController, TimeSeriesDatabaseController, archiving, typed read/write).
Overview
- Auto-generated Pydantic models (v1 and v2): OpcUaServer, OpcUaDataChannel, LaboratoryProcess, Sample, Material, etc.
- OpcUaServer controller - OPC UA client/server lifecycle with channel subscriptions and data archiving
OpcUaServer controller
Extends DataToolController with OPC UA protocol logic:
from opensemantic import compute_scoped_uuid
from opensemantic.lab.v1 import OpcUaServer, OpcUaDataChannel, OpcUaClientMode
from opensemantic.characteristics.quantitative.v1 import Temperature, Time, TimeUnit
from opensemantic.core.v1 import Label
from uuid import NAMESPACE_URL, uuid5
SERVER_UUID = uuid5(NAMESPACE_URL, "my-server")
server = OpcUaServer(
uuid=SERVER_UUID,
name="my_server",
label=[Label(text="My Server")],
url="opc.tcp://localhost:4840",
data_channels=[
OpcUaDataChannel(
uuid=compute_scoped_uuid(SERVER_UUID, "ns=2;s=Temperature"),
node_id="ns=2;s=Temperature",
name="temperature",
label=[Label(text="Temperature")],
opcua_data_type="Float",
client_mode=OpcUaClientMode.Subscription,
sampling_interval=Time(value=100, unit=TimeUnit.milli_second),
refresh_interval=Time(value=500, unit=TimeUnit.milli_second),
characteristic=Temperature.get_cls_iri(),
),
],
auto_archive=True,
)
OPC UA-specific methods
run_as_server(params)- start an OPC UA server with value callbacksrun_as_client(params)- connect, subscribe to channels, auto-archiveread_channel(params)/write_channel(params)- direct channel I/Obrowse(params)- browse the OPC UA address spacestop()- flush archive buffer and disconnect
Channel UUIDs
OpcUaDataChannel requires an explicit UUID. Use compute_scoped_uuid(server_uuid, node_id) from opensemantic to avoid collisions across servers.
Controller fields (runtime only)
url, archive_database, auto_archive, reset_opcua_connection_on_error are controller-only fields. They are stripped from to_json() / to_jsonld() serialization. Set them as runtime config when constructing the controller.
Inherited features
All DataTool features from opensemantic.base work automatically: auto-archive from storage_locations, typed read/write, subobject ID prefixing, channel characteristic warnings. See the opensemantic.base README for details.
Examples
See examples/ for complete runnable examples:
opc_ua_server.py- define server, store to oold backend, runopc_ua_client.py- load from backend, connect, print archived dataopcua_archiving.py- full workflow with auto-archiving and typed read/write
Installation
pip install opensemantic.lab # models only
pip install opensemantic.lab[controller] # + asyncua, opensemantic.base[controller]
Testing
pytest tests/test_controller.py
Tests include OPC UA server/client integration (uses asyncua's built-in test server, no external services needed).
For PostgREST-based archiving tests, see the opensemantic.base testing docs - requires a running pgstack instance with TimescaleDB.
Metadata
Release files for opensemantic.lab 0.7.0.post1000002003002
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 |
|---|---|---|---|---|
| opensemantic_lab-0.7.0.post1000002003002.tar.gz | 68.9 kB | Without provenance | Details for opensemantic_lab-0.7.0.post1000002003002.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opensemantic_lab-0.7.0.post1000002003002-py3-none-any.whl | Python 3 | none | any | Details for opensemantic_lab-0.7.0.post1000002003002-py3-none-any.whl |
Total release size: 115.5 kB
Release files / opensemantic_lab-0.7.0.post1000002003002.tar.gz
| Download URL | opensemantic_lab-0.7.0.post1000002003002.tar.gz |
|---|---|
| Size | 68.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b6c5509a2b443345d27bb3da02b5286bdb2d70f85da436bfd6b4449565eb406
|
|
BLAKE2b-256 checksum How to use checksums |
5e7cb0b1a52f06487269d6924e183380a365b9f4ad65b1ca07b3f661a7f780c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / opensemantic_lab-0.7.0.post1000002003002-py3-none-any.whl
| Download URL | opensemantic_lab-0.7.0.post1000002003002-py3-none-any.whl |
|---|---|
| Size | 46.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61452177ad62d49690fd62d51a6b04d7a27cf2b68caff640ba45486e5ffa392b
|
|
BLAKE2b-256 checksum How to use checksums |
9b9b338a945378fa7d59954016b58402e7fdfd126981e5bd7c75010435f4fba8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for opensemantic.lab 0.7.0.post1000002003002
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.