Skip to main content

Volume Segmantics User Interface (Client)

This is the client package for VSUI. It provides an interface for interacting with the api of a VSUI server.

It is recommended to use the object-oriented interface, although use of the methods in _vsui_client.py is possible to directly interact with the server. Communication is via a socketio connection to the server. The client only pushes notifications to the server, and cannot receive communications beyond the initial setup.

Example Use

import logging
from vsui_client import vsui_process, vsui_init

vsui_process is a decorator that provides exception handling. Specifically, it catches all exceptions apart from KeyboardInterrupt, to communicate the error to the server before the process exits. This includes SystemExit exceptions raised by sys.exit(). This exception handling behavior will only occur in wrapped functions, otherwise errors will result in undefined behaviour with regard to UI user feedback.

Setup

@vsui_process()
def entrypoint_to_my_process():
    logger = logging.get_logger()
    vsui_enabled = True
    process_id = 'my_process'
    logging_component_id = 'Logs'
    VSUI = init_vsui(vsui_enabled, process_id, logging_component_id)
    VSUI.connect()
    handler = VSUI.get_handler()
    logger.addHandler(handler)

Use in other modules

To get your current instance of VSUI from another process, it is possible to import it from where it was initialised, but it is recommended to use the vsui_client.get_client() method instead. This will return a reference to the current instance.

from vsui_client import get_client

VSUI = get_client()

Interacting with the server

The VSUI server thinks in terms of processes, tasks and components. Your program wrapped by @vsui_process, and using an instance of VSUIClient, is an example of a process. This should generally be a long-running task which you want to allow a user to setup via a GUI, and receive ongoing feedback from. Consult the VSUI documentation for more information about how to define a process.

Use the VSUIClient class to interact with the server api. In the following documentation VSUI is in instance of VSUIClient.

connect()

This Initiates a connection to a vsui server on the given host and port. The connection is via a socket that remains open until manually disconnected, or the process closes.

VSUI.connnect(host: str = 'host', port: str = 'port')

disconnect()

Disconnect the client from the server.

VSUI.disconnect()

edit element()

This method allows you to update the data of a component on the server. The component must be defined in the process definition on the server. The data must be serialisable to json.

VSUI.edit_element(element_uid: str, value: dict | str)

deactivate_task()

This method allows you to signal to the server that the task should be deactivated.

VSUI.deactivate_task()

notify()

This method allows you to send a toast notification to the client. The notification will be displayed in a toast and will disappear after a short time.

available types:

  • success
  • error
  • info
  • warning
VSUI.notify(txt: str, type: str)

set_task_id()

This method allows you to set the task id of the process.

VSUI.set_task_id(id: str)

set_logging_target()

This method allows you to set the component key of the task element that logs should be forwarded to.

VSUI.set_logging_target(key: str)

get_handler()

This method allows you to get the logging handler that forwards logs to the server.

VSUI.get_handler()

encode_image()

This method allows you to encode an image to base64.

VSUI.encode_image(arr: np.ndarray, title: str, format: str, figsize: tuple, cmap: str)

Metadata

Release files for vsui-client 1.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vsui-client 1.1.9
File Size Uploaded
vsui_client-1.1.9.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vsui-client 1.1.9
File Interpreter ABI Platform
vsui_client-1.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / vsui_client-1.1.9.tar.gz

Download URL vsui_client-1.1.9.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d2c677381fe7c3b727bf87870ec6de0f77c135165e2a00b513a7596da32422fe
BLAKE2b-256 checksum
How to use checksums
f339415061c1c55299ab2cf715357d89e758514a3289dfe7bf334e23a5dd6499
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.4 Linux/3.10.0-1160.88.1.el7.x86_64

Release files / vsui_client-1.1.9-py3-none-any.whl

Download URL vsui_client-1.1.9-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0498df0896be035bd6a23ff990c12c864b6660fe1144a79be18477d21e6006e3
BLAKE2b-256 checksum
How to use checksums
2cfbaa5723b3b53eb90e38bc41912bfe6faa10c2b5baf0944964d1a5b4479867
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.4 Linux/3.10.0-1160.88.1.el7.x86_64

Release history Release notifications | RSS feed

This release

1.1.9 This release

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page