Beispiel #1
0
    def setUpClass(cls):
        token = os.environ.get('KB_AUTH_TOKEN', None)
        config_file = os.environ.get('KB_DEPLOYMENT_CONFIG', None)
        cls.cfg = {}
        config = ConfigParser()
        config.read(config_file)
        for nameval in config.items('GenericsAPI'):
            cls.cfg[nameval[0]] = nameval[1]
        # Getting username from Auth profile for token
        authServiceUrl = cls.cfg['auth-service-url']
        auth_client = _KBaseAuth(authServiceUrl)
        user_id = auth_client.get_user(token)
        # WARNING: don't call any logging methods on the context object,
        # it'll result in a NoneType error
        cls.ctx = MethodContext(None)
        cls.ctx.update({'token': token,
                        'user_id': user_id,
                        'provenance': [
                            {'service': 'GenericsAPI',
                             'method': 'please_never_use_it_in_production',
                             'method_params': []
                             }],
                        'authenticated': 1})
        cls.wsURL = cls.cfg['workspace-url']
        cls.wsClient = workspaceService(cls.wsURL)
        cls.serviceImpl = GenericsAPI(cls.cfg)
        cls.scratch = cls.cfg['scratch']
        cls.callback_url = os.environ['SDK_CALLBACK_URL']
        cls.dfu = DataFileUtil(cls.callback_url)
        cls.pca_util = PCAUtil(cls.cfg)

        suffix = int(time.time() * 1000)
        cls.wsName = "test_pca_util_" + str(suffix)
        ret = cls.wsClient.create_workspace({'workspace': cls.wsName})
        cls.wsId = ret[0]
Beispiel #2
0
    def setUpClass(cls):
        cls.token = environ.get('KB_AUTH_TOKEN', None)
        config_file = environ.get('KB_DEPLOYMENT_CONFIG', None)
        cls.cfg = {}
        config = ConfigParser()
        config.read(config_file)
        for nameval in config.items('GenericsAPI'):
            cls.cfg[nameval[0]] = nameval[1]
        # Getting username from Auth profile for token
        authServiceUrl = cls.cfg['auth-service-url']
        auth_client = _KBaseAuth(authServiceUrl)
        user_id = auth_client.get_user(cls.token)
        # WARNING: don't call any logging methods on the context object,
        # it'll result in a NoneType error
        cls.ctx = MethodContext(None)
        cls.ctx.update({
            'token':
            cls.token,
            'user_id':
            user_id,
            'provenance': [{
                'service': 'GenericsAPI',
                'method': 'please_never_use_it_in_production',
                'method_params': []
            }],
            'authenticated':
            1
        })
        cls.wsURL = cls.cfg['workspace-url']
        cls.wsClient = workspaceService(cls.wsURL)
        cls.serviceImpl = GenericsAPI(cls.cfg)
        cls.scratch = cls.cfg['scratch']
        cls.callback_url = os.environ['SDK_CALLBACK_URL']
        cls.shockURL = cls.cfg['shock-url']
        cls.dfu = DataFileUtil(cls.callback_url)
        cls.sample_uploader = sample_uploader(cls.callback_url,
                                              service_ver="dev")
        cls.sample_url = cls.cfg.get('kbase-endpoint') + '/sampleservice'
        cls.sample_ser = SampleService(cls.sample_url)
        cls.hs = HandleService(url=cls.cfg['handle-service-url'],
                               token=cls.token)

        suffix = int(time.time() * 1000)
        cls.wsName = "test_GenericsAPI_" + str(suffix)
        ret = cls.wsClient.create_workspace({'workspace': cls.wsName})
        cls.wsId = ret[0]

        small_file = os.path.join(cls.scratch, 'test.txt')
        with open(small_file, "w") as f:
            f.write("empty content")
        cls.test_shock = cls.dfu.file_to_shock({
            'file_path': small_file,
            'make_handle': True
        })
        cls.handles_to_delete = []
        cls.nodes_to_delete = []
        cls.handles_to_delete.append(cls.test_shock['handle']['hid'])
        cls.nodes_to_delete.append(cls.test_shock['shock_id'])

        cls.prepare_data()
    def setUpClass(cls):
        cls.maxDiff = 70000
        cls.token = os.environ.get('KB_AUTH_TOKEN', None)
        config_file = os.environ.get('KB_DEPLOYMENT_CONFIG', None)
        cls.cfg = {}
        config = ConfigParser()
        config.read(config_file)
        for nameval in config.items('GenericsAPI'):
            cls.cfg[nameval[0]] = nameval[1]
        # Getting username from Auth profile for token
        authServiceUrl = cls.cfg['auth-service-url']
        auth_client = _KBaseAuth(authServiceUrl)
        user_id = auth_client.get_user(cls.token)
        # WARNING: don't call any logging methods on the context object,
        # it'll result in a NoneType error
        cls.ctx = MethodContext(None)
        cls.ctx.update({'token': cls.token,
                        'user_id': user_id,
                        'provenance': [
                            {'service': 'GenericsAPI',
                             'method': 'please_never_use_it_in_production',
                             'method_params': []
                             }],
                        'authenticated': 1})
        cls.wsURL = cls.cfg['workspace-url']
        cls.wsClient = workspaceService(cls.wsURL)
        cls.serviceImpl = GenericsAPI(cls.cfg)
        cls.serviceUtils = AttributesUtil(cls.cfg)
        cls.shockURL = cls.cfg['shock-url']
        cls.scratch = cls.cfg['scratch']
        cls.callback_url = os.environ['SDK_CALLBACK_URL']
        cls.dfu = DataFileUtil(cls.callback_url)
        cls.hs = HandleService(url=cls.cfg['handle-service-url'],
                               token=cls.token)

        suffix = int(time.time() * 1000)
        cls.wsName = "test_CompoundSetUtils_" + str(suffix)
        ret = cls.wsClient.create_workspace({'workspace': cls.wsName})
        cls.wsId = ret[0]
        cls.attribute_mapping = json.load(open('data/AM1.json'))
        info = cls.dfu.save_objects({
            "id": cls.wsId,
            "objects": [{
                "type": "KBaseExperiments.AttributeMapping",
                "data": cls.attribute_mapping,
                "name": "test_cond_set"
            }]
        })[0]
        cls.attribute_mapping_ref = "%s/%s/%s" % (info[6], info[0], info[4])
        cls.attribute_mapping_2 = json.load(open('data/AM2.json'))

        small_file = os.path.join(cls.scratch, 'test.txt')
        with open(small_file, "w") as f:
            f.write("empty content")
        cls.test_shock = cls.dfu.file_to_shock({'file_path': small_file, 'make_handle': True})
        cls.handles_to_delete = []
        cls.nodes_to_delete = []
        cls.handles_to_delete.append(cls.test_shock['handle']['hid'])
        cls.nodes_to_delete.append(cls.test_shock['shock_id'])
    def setUpClass(cls):
        cls.maxDiff = 70000
        token = os.environ.get('KB_AUTH_TOKEN', None)
        config_file = os.environ.get('KB_DEPLOYMENT_CONFIG', None)
        cls.cfg = {}
        config = ConfigParser()
        config.read(config_file)
        for nameval in config.items('GenericsAPI'):
            cls.cfg[nameval[0]] = nameval[1]
        # Getting username from Auth profile for token
        authServiceUrl = cls.cfg['auth-service-url']
        auth_client = _KBaseAuth(authServiceUrl)
        user_id = auth_client.get_user(token)
        # WARNING: don't call any logging methods on the context object,
        # it'll result in a NoneType error
        cls.ctx = MethodContext(None)
        cls.ctx.update({'token': token,
                        'user_id': user_id,
                        'provenance': [
                            {'service': 'GenericsAPI',
                             'method': 'please_never_use_it_in_production',
                             'method_params': []
                             }],
                        'authenticated': 1})
        cls.wsURL = cls.cfg['workspace-url']
        
        cls.wsClient = workspaceService(cls.wsURL)
        cls.serviceImpl = GenericsAPI(cls.cfg)
        cls.serviceUtils = AttributesUtil(cls.cfg)
        cls.scratch = cls.cfg['scratch']
        cls.callback_url = os.environ['SDK_CALLBACK_URL']
        cls.dfu = DataFileUtil(cls.callback_url)

        suffix = int(time.time() * 1000)
        #cls.wsName = "test_CompoundSetUtils_" + str(suffix)
        cls.wsName = "man4ish_gupta:narrative_1568644342277"
        ret = cls.wsClient.create_workspace({'workspace': cls.wsName})
        #exit(cls.wsId)
        #cls.wsId = ret[0]
        cls.wsid = 44071
        cls.attribute_mapping = json.load(open('data/AM1.json'))
        info = cls.dfu.save_objects({
            "id": cls.wsId,
            "objects": [{
                "type": "KBaseExperiments.AttributeMapping",
                "data": cls.attribute_mapping,
                "name": "test_cond_set"
            }]
        })[0]
        cls.attribute_mapping_ref = "%s/%s/%s" % (info[6], info[0], info[4])
        cls.attribute_mapping_2 = json.load(open('data/AM2.json'))
 def __init__(self):
     submod = get_service_name() or 'GenericsAPI'
     self.userlog = log.log(submod,
                            ip_address=True,
                            authuser=True,
                            module=True,
                            method=True,
                            call_id=True,
                            changecallback=self.logcallback,
                            config=get_config_file())
     self.serverlog = log.log(submod,
                              ip_address=True,
                              authuser=True,
                              module=True,
                              method=True,
                              call_id=True,
                              logfile=self.userlog.get_log_file())
     self.serverlog.set_log_level(6)
     self.rpc_service = JSONRPCServiceCustom()
     self.method_authentication = dict()
     self.rpc_service.add(impl_GenericsAPI.fetch_data,
                          name='GenericsAPI.fetch_data',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.fetch_data'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.export_matrix,
                          name='GenericsAPI.export_matrix',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.export_matrix'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.validate_data,
                          name='GenericsAPI.validate_data',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.validate_data'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.import_matrix_from_excel,
                          name='GenericsAPI.import_matrix_from_excel',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.import_matrix_from_excel'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.import_matrix_from_biom,
                          name='GenericsAPI.import_matrix_from_biom',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.import_matrix_from_biom'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.save_object,
                          name='GenericsAPI.save_object',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.save_object'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.search_matrix,
                          name='GenericsAPI.search_matrix',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.search_matrix'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.filter_matrix,
                          name='GenericsAPI.filter_matrix',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.filter_matrix'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.standardize_matrix,
                          name='GenericsAPI.standardize_matrix',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.standardize_matrix'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.file_to_attribute_mapping,
                          name='GenericsAPI.file_to_attribute_mapping',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.file_to_attribute_mapping'] = 'required'  # noqa
     self.rpc_service.add(
         impl_GenericsAPI.update_matrix_attribute_mapping,
         name='GenericsAPI.update_matrix_attribute_mapping',
         types=[dict])
     self.method_authentication[
         'GenericsAPI.update_matrix_attribute_mapping'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.attribute_mapping_to_tsv_file,
                          name='GenericsAPI.attribute_mapping_to_tsv_file',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.attribute_mapping_to_tsv_file'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.export_attribute_mapping_tsv,
                          name='GenericsAPI.export_attribute_mapping_tsv',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.export_attribute_mapping_tsv'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.export_attribute_mapping_excel,
                          name='GenericsAPI.export_attribute_mapping_excel',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.export_attribute_mapping_excel'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.export_cluster_set_excel,
                          name='GenericsAPI.export_cluster_set_excel',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.export_cluster_set_excel'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.export_corr_matrix_excel,
                          name='GenericsAPI.export_corr_matrix_excel',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.export_corr_matrix_excel'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.export_pca_matrix_excel,
                          name='GenericsAPI.export_pca_matrix_excel',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.export_pca_matrix_excel'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.export_amplicon_set_tsv,
                          name='GenericsAPI.export_amplicon_set_tsv',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.export_amplicon_set_tsv'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.compute_correlation_matrix,
                          name='GenericsAPI.compute_correlation_matrix',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.compute_correlation_matrix'] = 'required'  # noqa
     self.rpc_service.add(
         impl_GenericsAPI.compute_correlation_across_matrices,
         name='GenericsAPI.compute_correlation_across_matrices',
         types=[dict])
     self.method_authentication[
         'GenericsAPI.compute_correlation_across_matrices'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.build_network,
                          name='GenericsAPI.build_network',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.build_network'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.run_pca,
                          name='GenericsAPI.run_pca',
                          types=[dict])
     self.method_authentication['GenericsAPI.run_pca'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.view_matrix,
                          name='GenericsAPI.view_matrix',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.view_matrix'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.status,
                          name='GenericsAPI.status',
                          types=[dict])
     authurl = config.get(AUTH) if config else None
     self.auth_client = _KBaseAuth(authurl)
 def __init__(self):
     submod = get_service_name() or 'GenericsAPI'
     self.userlog = log.log(submod,
                            ip_address=True,
                            authuser=True,
                            module=True,
                            method=True,
                            call_id=True,
                            changecallback=self.logcallback,
                            config=get_config_file())
     self.serverlog = log.log(submod,
                              ip_address=True,
                              authuser=True,
                              module=True,
                              method=True,
                              call_id=True,
                              logfile=self.userlog.get_log_file())
     self.serverlog.set_log_level(6)
     self.rpc_service = JSONRPCServiceCustom()
     self.method_authentication = dict()
     self.rpc_service.add(impl_GenericsAPI.fetch_data,
                          name='GenericsAPI.fetch_data',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.fetch_data'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.generate_matrix_html,
                          name='GenericsAPI.generate_matrix_html',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.generate_matrix_html'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.export_matrix,
                          name='GenericsAPI.export_matrix',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.export_matrix'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.validate_data,
                          name='GenericsAPI.validate_data',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.validate_data'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.import_matrix_from_excel,
                          name='GenericsAPI.import_matrix_from_excel',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.import_matrix_from_excel'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.save_object,
                          name='GenericsAPI.save_object',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.save_object'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.search_matrix,
                          name='GenericsAPI.search_matrix',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.search_matrix'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.filter_matrix,
                          name='GenericsAPI.filter_matrix',
                          types=[dict])
     self.method_authentication[
         'GenericsAPI.filter_matrix'] = 'required'  # noqa
     self.rpc_service.add(impl_GenericsAPI.status,
                          name='GenericsAPI.status',
                          types=[dict])
     authurl = config.get(AUTH) if config else None
     self.auth_client = _KBaseAuth(authurl)