Karabo-Proxy
Overview
The Karabo WebProxy device exposes a web API that allows any HTTP client to interact with devices in its Karabo topic.
This project, Karabo-Proxy, provides a convenience Python 3 client library for interacting with an instance of the Karabo WebProxy device in a (mostly) HTTP-agnostic way.
Karabo-Proxy offers two client variants, SyncKaraboProxy and
AsyncKaraboProxy, with a common interface. The first is a synchronous
(blocking) client and the second is an asynchronous (asyncio-friendly) client.
Examples of use of both clients in some common scenarios are shown below. For full details please look at the docstrings available in the library.
Installation
From a local clone of the project
git clone https://github.com/European-XFEL/karabo_proxy.git
cd karabo_proxy
pip install .
From pypi.org
pip install karabo_proxy
How to Use
Connect to a WebProxy instance
from karabo_proxy import SyncKaraboProxy
client = SyncKaraboProxy("http://web_proxy_host:8282")
from karabo_proxy import AsyncKaraboProxy
async_client = AsyncKaraboProxy("http://web_proxy_host:8282")
Retrieve the Topology of the Karabo Topic
The topology is returned as an object of type karabo_proxy.data.topology.TopologyInfo.
topology = client.get_topology()
topology = await async_client.get_topology()
Get the Configuration of a Device
The device configuration is returned as a dictionary where the identifiers of the device
properties are the keys and the values are of type karabo_proxy.data.device_config.PropertyInfo (property value with timing information).
config = client.get_device_configuration("DEVICE_ID")
config = await async_client.get_device_configuration("DEVICE_ID")
Configure a Device
This operation is only allowed on devices that are in the list of reconfigurableDevices
of the connected WebProxy. The properties being set should be provided as a dictionary
where the key is the property identifier and the value is the value to be set for the property.
result = client.set_device_configuration("DEVICE_ID",
"{"prop_1": 3.14159,
"prop_2": "activating ..." })
result = await async_client.set_device_configuration("DEVICE_ID",
"{"prop_1": 3.14159,
"prop_2": "activating ..." })
result will be an object with two attributes: success (bool) and reason (str).
reason is empty for successful operations. Otherwise (success == False), it
contains an error message detailing what went wrong.
Execute a Device Slot
Slot execution requires the specified device to be in the list of reconfigurableDevices
of the connected WebProxy. Its return value has the same type and semantics of the
return value of the set_device_configuration operation.
result = client.execute_slot("DEVICE_ID",
"slot_start", {"param1": "NOW", "param2": 30})
result = await async_client.execute_slot("DEVICE_ID",
"slot_start",
{"param1": "NOW", "param2": 30})
The slot parameters, if any, should be passed as a dictionary with the parameter name as the key and the value as the value.
Contact
For questions, please contact opensource@xfel.eu.
License and Contributing
This software is released by the European XFEL GmbH as is and without any warranty under the GPLv3 license. If you have questions on contributing to the project, please get in touch at opensource@xfel.eu.
Metadata
Release files for Karabo-proxy 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| karabo_proxy-1.0.4.tar.gz | 14.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Karabo_proxy-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.5 kB
Release files / karabo_proxy-1.0.4.tar.gz
| Download URL | karabo_proxy-1.0.4.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b70c4f63bdec604c3c516ff4a0b503037a24225b7f9cb19fa61b8d35e6145e5
|
|
BLAKE2b-256 checksum How to use checksums |
cb15a638f9be110da119233e33b3a37e61d405851a3e29361b93869764b5b3ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.2
|
Release files / Karabo_proxy-1.0.4-py3-none-any.whl
| Download URL | Karabo_proxy-1.0.4-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d21e9dbd73b44d1a9e41d4b3e701962e81b2fd4a0c5d457312c7fbe9a7dbbb9
|
|
BLAKE2b-256 checksum How to use checksums |
f33956de32c63319ed6f96a154cf1ede1b673e290858610a37c2fcecf475f40c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.2
|