Beispiel #1
0
class TestRestService(TransactionalTestCase):
    def transactional_setup_method(self):
        self.tvb_client = TVBClient("http://rest-server:9090")
        keycloak_instance = KeycloakOpenID(
            "https://keycloak.codemart.ro/auth/", "TVB", "tvb-tests")
        self.tvb_client.update_auth_token(
            keycloak_instance.token("tvb_user", "pass")['access_token'])

    def test_launch_operation(self):
        launch_operation_examples(self.tvb_client)

    def test_fire_simulation(self):
        fire_simulation_example(self.tvb_client)
Beispiel #2
0

def quick_launch_an_operation(tvb_client_instance, project_gid, datatype_gid):
    """
    This is intended to simulate the following behavior:
        - in GUI the user has the possibility to view all algorithms that can run over a certain datatype
        - he chooses a datatype and all these algorithms are displayed
        - then, he selects an algorithm
    The data that should be sent to the server:
        - the selected datatype_gid
        - the index of the selected algorithm
    """
    algo_dto_list = tvb_client_instance.get_operations_for_datatype(
        datatype_gid)
    algo_dto_index = 0

    # Supposing that algo_dt_index and time_series_gid are sent from the client-side
    operation_gid = tvb_client.quick_launch_operation(
        project_gid, algo_dto_list[algo_dto_index], datatype_gid)
    monitor_operation(tvb_client, operation_gid)


if __name__ == '__main__':
    logger.info("Preparing client...")
    tvb_client = TVBClient(compute_rest_url())

    logger.info("Attempt to login")
    tvb_client.browser_login()
    project_gid, time_series_gid = fire_simulation_example(tvb_client)
    quick_launch_an_operation(tvb_client, project_gid, time_series_gid)
Beispiel #3
0
from tvb.adapters.uploaders.zip_connectivity_importer import ZIPConnectivityImporterModel, ZIPConnectivityImporter
from tvb.adapters.uploaders.zip_surface_importer import ZIPSurfaceImporterModel, ZIPSurfaceImporter
from tvb.adapters.uploaders.region_mapping_importer import RegionMappingImporterModel, RegionMappingImporter
from tvb.adapters.uploaders.csv_connectivity_importer import CSVConnectivityImporterModel, CSVConnectivityImporter
from tvb.basic.logger.builder import get_logger
from tvb.basic.profile import TvbProfile
from tvb.core.entities.model.model_operation import STATUS_ERROR, STATUS_CANCELED, STATUS_FINISHED
from tvb.core.entities.storage import dao
from tvb.interfaces.rest.client.tvb_client import TVBClient

if __name__ == '__main__':

    logger = get_logger(__name__)

    logger.info("Preparing client...")
    tvb_client = TVBClient("http://localhost:9090")

    logger.info("Requesting a list of users...")
    users_list = tvb_client.get_users()
    assert len(users_list) > 0
    logger.info("TVB has {} users registered".format(len(users_list)))

    username = users_list[0].username
    logger.info("Requesting projects for user {}...".format(username))
    projects_of_user = tvb_client.get_project_list(username)
    assert len(projects_of_user) > 0
    logger.info("TVB has {} projects for this user".format(len(projects_of_user)))

    project_gid = projects_of_user[0].gid

    logger.info("Preparing a connectivity H5 file...")
Beispiel #4
0
Then, we upload a region mapping that depends on both connectivity and surface to exist in TVB storage.
"""

from tvb.adapters.uploaders.region_mapping_importer import RegionMappingImporterModel, RegionMappingImporter
from tvb.adapters.uploaders.zip_connectivity_importer import ZIPConnectivityImporterModel, ZIPConnectivityImporter
from tvb.adapters.uploaders.zip_surface_importer import ZIPSurfaceImporterModel, ZIPSurfaceImporter
from tvb.basic.logger.builder import get_logger
from tvb.datatypes.surfaces import CORTICAL
from tvb.interfaces.rest.client.examples.utils import compute_tvb_data_path, monitor_operation
from tvb.interfaces.rest.client.tvb_client import TVBClient

if __name__ == '__main__':
    logger = get_logger(__name__)

    logger.info("Preparing client...")
    tvb_client = TVBClient("http://localhost:9090")

    logger.info("Login with default user...")
    tvb_client.login("tvb_user", "pass")

    logger.info("Requesting projects for logged user")
    projects_of_user = tvb_client.get_project_list()
    assert len(projects_of_user) > 0
    logger.info("TVB has {} projects for this user".format(
        len(projects_of_user)))

    project_gid = projects_of_user[0].gid

    # --- Launch operations to import a Connectivity, a Surface and a RegionMapping ---

    logger.info("Importing a connectivity from ZIP...")
import uuid
from tvb.adapters.analyzers.fourier_adapter import FFTAdapterModel
from tvb.adapters.datatypes.db.connectivity import ConnectivityIndex
from tvb.adapters.datatypes.h5.time_series_h5 import TimeSeriesH5
from tvb.adapters.simulator.simulator_adapter import SimulatorAdapterModel
from tvb.basic.logger.builder import get_logger
from tvb.core.entities.model.model_operation import STATUS_FINISHED, STATUS_CANCELED, STATUS_ERROR
from tvb.core.neocom import h5
from tvb.interfaces.rest.client.tvb_client import TVBClient

if __name__ == '__main__':

    logger = get_logger(__name__)

    logger.info("Preparing client...")
    tvb_client = TVBClient("http://localhost:9090")

    logger.info("Requesting a list of users...")
    users_list = tvb_client.get_users()
    assert len(users_list) > 0
    logger.info("TVB has {} users registered".format(len(users_list)))

    username = users_list[0].username
    logger.info("Requesting projects for user {}...".format(username))
    projects_of_user = tvb_client.get_project_list(username)
    assert len(projects_of_user) > 0
    logger.info("TVB has {} projects for this user".format(
        len(projects_of_user)))

    project_gid = projects_of_user[0].gid
    logger.info("Requesting datatypes from project {}...".format(project_gid))
Beispiel #6
0
 def transactional_setup_method(self):
     self.tvb_client = TVBClient("http://rest-server:9090")
     keycloak_instance = KeycloakOpenID(
         "https://keycloak.codemart.ro/auth/", "TVB", "tvb-tests")
     self.tvb_client.update_auth_token(
         keycloak_instance.token("tvb_user", "pass")['access_token'])
Beispiel #7
0
"""

from tvb.adapters.analyzers.fourier_adapter import FFTAdapterModel, FourierAdapter
from tvb.adapters.datatypes.db.connectivity import ConnectivityIndex
from tvb.adapters.datatypes.h5.time_series_h5 import TimeSeriesH5
from tvb.adapters.simulator.simulator_adapter import SimulatorAdapterModel
from tvb.basic.logger.builder import get_logger
from tvb.interfaces.rest.client.examples.utils import monitor_operation
from tvb.interfaces.rest.client.tvb_client import TVBClient

if __name__ == '__main__':

    logger = get_logger(__name__)

    logger.info("Preparing client...")
    tvb_client = TVBClient("http://localhost:9090")

    logger.info("Attempt to login")
    tvb_client.login('tvb_user', 'pass')

    logger.info("Requesting projects for logged user")
    projects_of_user = tvb_client.get_project_list()
    assert len(projects_of_user) > 0
    logger.info("TVB has {} projects for this user".format(
        len(projects_of_user)))

    project_gid = projects_of_user[0].gid
    logger.info("Requesting datatypes from project {}...".format(project_gid))
    data_in_project = tvb_client.get_data_in_project(project_gid)
    logger.info("We have {} datatypes".format(len(data_in_project)))