tvb-rest-client


Nametvb-rest-client JSON
Version 2.8.1 PyPI version JSON
download
home_pagehttps://www.thevirtualbrain.org
SummaryA helper package for preparing and sending requests towards the TVB REST API
upload_time2023-05-23 18:41:28
maintainer
docs_urlNone
authorLia Domide, Paula Prodan, Bogdan Valean, Robert Vincze
requires_python
licenseGPL-3.0-or-later
keywords tvb rest client brain simulator neuroscience human animal neuronal dynamics models delay
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            TVB REST client
===============

The `tvb-rest-client` is a helper package built with the intention to simplify a
Python client interaction with TVB REST Server.
All the logic necessary to prepare and send requests towards the REST server, is embedded under this 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 have a TVB REST server running, or access to a public one.
Then into `tvb-rest-client` you need to provide the URL towards this TVB REST server.
For the following example, we will suppose TVB REST server runs on *http://localhost:9090*

To launch a TVB REST server locally, you should download `tvb-framework` version >2.0. and launch it::

    $ python -m tvb.interfaces.web.run WEB_PROFILE  # Launch TVB web and REST servers locally


Accessing the client API entry-point
-------------------------------------

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

.. code-block:: python

    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

.. code-block:: python

    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

.. code-block:: python

    datatype_path = tvb_client.retrieve_datatype(list_of_datatypes_in_project[0].gid, download_folder)
..

- method that loads in memory the datatype downloaded previously

.. code-block:: python

    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]*.

.. code-block:: python

    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

.. code-block:: python

    monitor_operation(tvb_client, operation_gid)
..

Acknowledgments
===============
This project has received funding from the European Union’s Horizon 2020 Framework Programme for Research and
Innovation under the Specific Grant Agreement Nos. 785907 (Human Brain Project SGA2), 945539 (Human Brain Project SGA3)
and VirtualBrainCloud 826421.

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.thevirtualbrain.org",
    "name": "tvb-rest-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "tvb rest client brain simulator neuroscience human animal neuronal dynamics models delay",
    "author": "Lia Domide, Paula Prodan, Bogdan Valean, Robert Vincze",
    "author_email": "tvb.admin@thevirtualbrain.org",
    "download_url": "https://files.pythonhosted.org/packages/ae/40/4de0482948c5e5a9de514cbb61ab019593b5bab63eb13eb9a33bfbf028e8/tvb-rest-client-2.8.1.tar.gz",
    "platform": null,
    "description": "TVB REST client\n===============\n\nThe `tvb-rest-client` is a helper package built with the intention to simplify a\nPython client interaction with TVB REST Server.\nAll the logic necessary to prepare and send requests towards the REST server, is embedded under this client API.\n\n**GET** requests are sent from this python client using the **requests** library.\n\nFor the **POST** requests, a client has to attach a file with some input configuration.\nSuch a file is usually an **H5** in TVB specific format.\nThus, `tvb-rest-client` has all the logic for preparing those H5 files and sending requests.\nAlso, the REST server uses a Keycloak client at log in time, so this client will open a browser that allows the user to\nlog in, before attempting to make the requests.\n\nUsage\n=====\nYou should have a TVB REST server running, or access to a public one.\nThen into `tvb-rest-client` you need to provide the URL towards this TVB REST server.\nFor the following example, we will suppose TVB REST server runs on *http://localhost:9090*\n\nTo launch a TVB REST server locally, you should download `tvb-framework` version >2.0. and launch it::\n\n    $ python -m tvb.interfaces.web.run WEB_PROFILE  # Launch TVB web and REST servers locally\n\n\nAccessing the client API entry-point\n-------------------------------------\n\nIf the TVB REST server you want to access runs at another address, change the parameter\nin the bellow TVBClient instantiation.\n\n.. code-block:: python\n\n    from tvb.interfaces.rest.client.tvb_client import TVBClient\n    tvb_client = TVBClient(\"http://localhost:9090\")\n..\n\n\nAttempt to login and start using the client API to send requests, by calling different types of methods:\n\n- methods that return a list of DTOs\n\n.. code-block:: python\n\n    tvb_client.browser_login()\n    list_of_user_projects = tvb_client.get_project_list()\n    list_of_datatypes_in_project = tvb_client.get_data_in_project(list_of_user_projects[0].gid)\n    list_of_operations_for_datatype = tvb_client.get_operations_for_datatype(list_of_datatypes_in_project[0].gid)\n..\n\n- method that download data files locally, under a folder chosen by the client\n\n.. code-block:: python\n\n    datatype_path = tvb_client.retrieve_datatype(list_of_datatypes_in_project[0].gid, download_folder)\n..\n\n- method that loads in memory the datatype downloaded previously\n\n.. code-block:: python\n\n    datatype = tvb_client.load_datatype_from_file(datatype_path)\n..\n\n- methods that launch operations in the TVB server\n    Such an operation requires the client to prepare the operation configuration and send it in an H5 file together with the requests.\n\n    By using the client API, the user only needs to instantiate the proper Model class and send it as argument to the following method.\n    It wraps the serialization of the Model inside the H5 and the attaching to the POST request.\n\n    The example above launches a Fourier analyzer, we suppose the Fourier AlgorithmDTO is *list_of_operations_for_datatype[0]*.\n\n.. code-block:: python\n\n    from tvb.adapters.analyzers.fourier_adapter import FFTAdapterModel, FourierAdapter\n\n    project_gid = list_of_user_projects[0].gid\n    model = FFTAdapterModel()\n    # logic to fill the model with required attributes\n    operation_gid = tvb_client.launch_operation(project_gid, FourierAdapter, model)\n..\n\n- method to monitor the status of an operation\n\n.. code-block:: python\n\n    monitor_operation(tvb_client, operation_gid)\n..\n\nAcknowledgments\n===============\nThis project has received funding from the European Union\u2019s Horizon 2020 Framework Programme for Research and\nInnovation under the Specific Grant Agreement Nos. 785907 (Human Brain Project SGA2), 945539 (Human Brain Project SGA3)\nand VirtualBrainCloud 826421.\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "A helper package for preparing and sending requests towards the TVB REST API",
    "version": "2.8.1",
    "project_urls": {
        "Download": "https://github.com/the-virtual-brain/tvb-root",
        "Homepage": "https://www.thevirtualbrain.org"
    },
    "split_keywords": [
        "tvb",
        "rest",
        "client",
        "brain",
        "simulator",
        "neuroscience",
        "human",
        "animal",
        "neuronal",
        "dynamics",
        "models",
        "delay"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4a719ebcbef910a1e75d7be2dc9c80aa4270fb2776658235143dec0c66d97751",
                "md5": "04153ee1d081ff4b772b48bd782db964",
                "sha256": "d1a3a7680d517344680d896f002562081d96204ebc7825e58a0b9fe3247fa954"
            },
            "downloads": -1,
            "filename": "tvb_rest_client-2.8.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "04153ee1d081ff4b772b48bd782db964",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 743685,
            "upload_time": "2023-05-23T18:40:30",
            "upload_time_iso_8601": "2023-05-23T18:40:30.716284Z",
            "url": "https://files.pythonhosted.org/packages/4a/71/9ebcbef910a1e75d7be2dc9c80aa4270fb2776658235143dec0c66d97751/tvb_rest_client-2.8.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ae404de0482948c5e5a9de514cbb61ab019593b5bab63eb13eb9a33bfbf028e8",
                "md5": "9ab7144ccbf432991117c9ce1ccd7046",
                "sha256": "baf0023994408148b46627493ef01f9b2887c34905d65b2104c9cab81672384d"
            },
            "downloads": -1,
            "filename": "tvb-rest-client-2.8.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9ab7144ccbf432991117c9ce1ccd7046",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 412682,
            "upload_time": "2023-05-23T18:41:28",
            "upload_time_iso_8601": "2023-05-23T18:41:28.017365Z",
            "url": "https://files.pythonhosted.org/packages/ae/40/4de0482948c5e5a9de514cbb61ab019593b5bab63eb13eb9a33bfbf028e8/tvb-rest-client-2.8.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-23 18:41:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "the-virtual-brain",
    "github_project": "tvb-root",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "tvb-rest-client"
}
        
Elapsed time: 0.09240s