Skip to main content

Brayns python API

Project description

Brayns Python Client

A client for Brayns based on the Rockets client to provide remote control of a running Brayns instance.

Travis CI

Table of Contents

Installation


You can install this package from PyPI:

pip install brayns

Usage


Client vs. AsyncClient

Brayns provides two types of clients to support asychronous and synchronous usage.

The AsyncClient exposes all of its functionality as async functions, hence an asyncio event loop is needed to complete pending execution via await or run_until_complete(). The added benefit is to watch progress of pending tasks or cancel their execution. This is provided by according widgets if the Brayns client is used from within a Jupyter notebook.

For simplicity, a synchronous Client is provided which automagically executes in a synchronous, blocking fashion.

Connection

Create a client:

from brayns import Client

client = Client('localhost:8200')
print(brayns)
`Brayns version 0.8.0.c52dd4b running on http://localhost:8200/`

Create an asynchronous client:

from brayns import AsyncClient

client = await AsyncClient('localhost:8200')
print(brayns)
`Brayns version 0.8.0.c52dd4b running on http://localhost:8200/`

Properties

Exposed properties from Brayns are properties on the python side as well:

from brayns import Client

client = Client('myhost:8080')

print(client.camera)

Changes on the properties must be communicated with commit() to Brayns:

from brayns import Client

client = Client('myhost:8080')

client.camera.origin = [1,2,3]
client.camera.commit()

Methods

Calling an RPC on Brayns is as simple as calling a method on the client object:

from brayns import Client

client = Client('myhost:8080')

client.set_camera(current='orthographic')

Above method does only return something on error. There are also requests:

from brayns import Client

client = Client('myhost:8080')

clip_planes = client.get_clip_planes()

Snapshot

Make a snapshot and return a PIL image:

from brayns import Client

client = Client('myhost:8080')

img = client.image(format='png', size=(1920, 1080), samples_per_pixel=64)

Live rendering

If you are using the client in a Jupyter notebook, you can watch the live rendering of Brayns in a widget:

from brayns import Client

client = Client('myhost:8080')

client.show()

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

brayns-1.0.0.tar.gz (31.2 kB view details)

Uploaded Source

File details

Details for the file brayns-1.0.0.tar.gz.

File metadata

  • Download URL: brayns-1.0.0.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

File hashes

Hashes for brayns-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cf119c6f12f9cfbd7f0b334026abe3d6869495ebb7e9dfef407c134f84c12a22
MD5 93dd42521b8e5e7005819510a19fa862
BLAKE2b-256 475c6594e0ac63e4ff6e70a06326d0575d6c9992a96aff1549c0032e0b56070a

See more details on using hashes here.

Provenance

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