Skip to main content

Client library for the Karabo WebProxy with sync and async support

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

karabo_proxy-1.0.4.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

Karabo_proxy-1.0.4-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file karabo_proxy-1.0.4.tar.gz.

File metadata

  • Download URL: karabo_proxy-1.0.4.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for karabo_proxy-1.0.4.tar.gz
Algorithm Hash digest
SHA256 0b70c4f63bdec604c3c516ff4a0b503037a24225b7f9cb19fa61b8d35e6145e5
MD5 2af3dce2bb51eae8d0d2e14d478cc401
BLAKE2b-256 cb15a638f9be110da119233e33b3a37e61d405851a3e29361b93869764b5b3ef

See more details on using hashes here.

File details

Details for the file Karabo_proxy-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: Karabo_proxy-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for Karabo_proxy-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5d21e9dbd73b44d1a9e41d4b3e701962e81b2fd4a0c5d457312c7fbe9a7dbbb9
MD5 10e36db9b77efe89600efbe668db3e15
BLAKE2b-256 f33956de32c63319ed6f96a154cf1ede1b673e290858610a37c2fcecf475f40c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page