Skip to main content

TVB REST client

The tvb-rest-client is a helper package built with the intention to simplify the client interaction with TVB REST API.

All the logic necessary to prepare and send requests towards the REST server, is embeded under a client API.

GET requests are sent from this python client using the requests library.

For the POST requests, a client has to attach a file with some input configuration. Such a file is usually an H5 in TVB specific format. Thus, tvb-rest-client has all the logic for preparing those H5 files and sending requests. Also, the REST server uses a Keycloak client at log in time, so this client will open a browser that allows the user to log in, before attempting to make the requests.

Usage

You should provide the URL towards the TVB REST server. For the following example, we will suppose TVB REST server runs on http://localhost:9090

Accessing the client API entrypoint:

If the TVB REST server you want to access runs at another address, change the parameter in the bellow TVBClient instantiation.

from tvb.interfaces.rest.client.tvb_client import TVBClient
tvb_client = TVBClient("http://localhost:9090")

Attempt to login and start using the client API to send requests, by calling different types of methods:

  • methods that return a list of DTOs

tvb_client.browser_login()
list_of_user_projects = tvb_client.get_project_list()
list_of_datatypes_in_project = tvb_client.get_data_in_project(list_of_user_projects[0].gid)
list_of_operations_for_datatype = tvb_client.get_operations_for_datatype(list_of_datatypes_in_project[0].gid)
  • method that download data files locally, under a folder chosen by the client

datatype_path = tvb_client.retrieve_datatype(list_of_datatypes_in_project[0].gid, download_folder)
  • method that loads in memory the datatype downloaded previously

datatype = tvb_client.load_datatype_from_file(datatype_path)
  • methods that launch operations in the TVB server

    Such an operation requires the client to prepare the operation configuration and send it in an H5 file together with the requests.

    By using the client API, the user only needs to instantiate the proper Model class and send it as argument to the following method. It wraps the serialization of the Model inside the H5 and the attaching to the POST request.

    The example above launches a Fourier analyzer, we suppose the Fourier AlgorithmDTO is list_of_operations_for_datatype[0].

from tvb.adapters.analyzers.fourier_adapter import FFTAdapterModel, FourierAdapter

project_gid = list_of_user_projects[0].gid
model = FFTAdapterModel()
# logic to fill the model with required attributes
operation_gid = tvb_client.launch_operation(project_gid, FourierAdapter, model)
  • method to monitor the status of an operation

monitor_operation(tvb_client, operation_gid)

Download files

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

Source Distribution

tvb-rest-client-2.0.4.tar.gz (377.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tvb_rest_client-2.0.4-py3-none-any.whl (746.3 kB view details)

Uploaded Python 3

File details

Details for the file tvb-rest-client-2.0.4.tar.gz.

File metadata

  • Download URL: tvb-rest-client-2.0.4.tar.gz
  • Upload date:
  • Size: 377.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.3

File hashes

Hashes for tvb-rest-client-2.0.4.tar.gz
Algorithm Hash digest
SHA256 3630c6dfa1df10c70e75767fa6ac0376f85123f54ceb81cc6a5df7ee785b0831
MD5 e37078f448b3c69c35b2a1a42bea3a23
BLAKE2b-256 cd4e353408c88a5285548479bafaaece6c67155f201b3a1fe6b7c75f4323465a

See more details on using hashes here.

File details

Details for the file tvb_rest_client-2.0.4-py3-none-any.whl.

File metadata

  • Download URL: tvb_rest_client-2.0.4-py3-none-any.whl
  • Upload date:
  • Size: 746.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.3

File hashes

Hashes for tvb_rest_client-2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8d3d3c5e97b48d64334ef58ef6081d22e2bef7356b154bf81ac314e35e1cd26e
MD5 3a98be1b6abac0abd0d04a8f36f1406a
BLAKE2b-256 1e8bbb202614f8abcde40cd4a8250ec0f649d79c77c1c0b0f02f6759d97f2b1f

See more details on using hashes here.

Supported by

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