def get_upload_algorithms(): """ :return: List of StoredAdapter entities """ categories = dao.get_uploader_categories() categories_ids = [categ.id for categ in categories] return dao.get_adapters_from_categories(categories_ids)
def get_upload_algorithms(): """ :return: List of StoredAdapter entities """ categories = dao.get_uploader_categories() categories_ids = [categ.id for categ in categories] return dao.get_adapters_from_categories(categories_ids)
def transactional_setup_method(self): """ Prepare some entities to work with during tests:""" self.algorithm_service = AlgorithmService() category = dao.get_uploader_categories()[0] self.algorithm = dao.store_entity(model_operation.Algorithm(TEST_ADAPTER_VALID_MODULE, TEST_ADAPTER_VALID_CLASS, category.id))
def transactional_setup_method(self): """ Prepare some entities to work with during tests:""" self.flow_service = FlowService() self.test_user = TestFactory.create_user() self.test_project = TestFactory.create_project(admin=self.test_user) category = dao.get_uploader_categories()[0] self.algorithm = dao.store_entity(model_operation.Algorithm(TEST_ADAPTER_VALID_MODULE, TEST_ADAPTER_VALID_CLASS, category.id))
def setUp(self): """ Prepare some entities to work with during tests:""" self.flow_service = FlowService() self.test_user = TestFactory.create_user() self.test_project = TestFactory.create_project(admin=self.test_user) category = dao.get_uploader_categories()[0] self.algorithm = dao.store_entity(model.Algorithm(TEST_ADAPTER_VALID_MODULE, TEST_ADAPTER_VALID_CLASS, category.id))
def ensure_db(self): """ Ensure algorithm exists in DB and add it if not """ cat = dao.get_uploader_categories()[0] cls = self.__class__ cmd, cnm = cls.__module__, cls.__name__ gp = dao.get_algorithm_by_module(cmd, cnm) if gp is None: gp = model.Algorithm(cmd, cnm, cat.id) gp = dao.store_entity(gp) self.stored_adapter = gp
def ensure_db(self): """ Ensure algorithm exists in DB and add it if not """ cat = dao.get_uploader_categories()[0] cls = self.__class__ cmd, cnm = cls.__module__, cls.__name__ gp = dao.find_group(cmd, cnm) if gp is None: gp = model.AlgorithmGroup(cmd, cnm, cat.id) gp = dao.store_entity(gp) dao.store_entity(model.Algorithm(gp.id, cnm, cnm)) self.algorithm_group = gp
def ensure_db(self): """ Ensure algorithm exists in DB and add it if not """ cat = dao.get_uploader_categories()[0] cls = self.__class__ cmd, cnm = cls.__module__, cls.__name__ gp = dao.find_group(cmd, cnm) if gp is None: gp = model.AlgorithmGroup(cmd, cnm, cat.id) gp = dao.store_entity(gp) dao.store_entity(model.Algorithm(gp.id, cnm, cnm)) self.algorithm_group = gp
def get_uploader_categories(): """Retrieve all algorithm categories with Upload mechanism""" return dao.get_uploader_categories()
def get_uploader_categories(): """Retrieve all algorithm categories with Upload mechanism""" return dao.get_uploader_categories()
from tvb.core.services.operation_service import OperationService from .new_importer import FooDataImporter # Before starting this, we need to have TVB web interface launched at least once (to have a default project, user, etc) if __name__ == "__main__": operation_service = OperationService() # This ID of a project needs to exists in Db, and it can be taken from the WebInterface: project = dao.get_project_by_id(1) # This is our new added Importer: adapter_instance = FooDataImporter() # We need to store a reference towards the new algorithms also in DB: # First select the category of uploaders: upload_category = dao.get_uploader_categories()[0] # check if the algorithm has been added in DB already algorithm = dao.get_algorithm_by_module(FooDataImporter.__module__, FooDataImporter.__name__) if algorithm is None: # not stored in DB previously, we will store it now: algorithm = Algorithm(FooDataImporter.__module__, FooDataImporter.__name__, upload_category.id) algorithm = dao.store_entity(algorithm) adapter_instance.stored_adapter = algorithm # Prepare the input algorithms as if they were coming from web UI submit: # launch_args = {"array_data": "[1, 2, 3, 4, 5]"} launch_args = {"array_data": "demo_array.txt"}
## Before starting this, we need to have TVB web interface launched at least once (to have a default project, user, etc) if __name__ == "__main__": flow_service = FlowService() operation_service = OperationService() ## This ID of a project needs to exists in Db, and it can be taken from the WebInterface: project = dao.get_project_by_id(1) ## This is our new added Importer: adapter_instance = FooDataImporter() ## We need to store a reference towards the new algorithms also in DB: # First select the category of uploaders: upload_category = dao.get_uploader_categories()[0] # check if the algorithm has been added in DB already my_group = dao.find_group(FooDataImporter.__module__, FooDataImporter.__name__) if my_group is None: # not stored in DB previously, we will store it now: my_group = AlgorithmGroup(FooDataImporter.__module__, FooDataImporter.__name__, upload_category.id) my_group = dao.store_entity(my_group) dao.store_entity(Algorithm(my_group.id, "", "FooName")) adapter_instance.algorithm_group = my_group ## Prepare the input algorithms as if they were coming from web UI submit: #launch_args = {"array_data": "[1, 2, 3, 4, 5]"} launch_args = {"array_data": "demo_array.txt"} ## launch an operation and have the results sotored both in DB and on disk