Exemplo n.º 1
0
 def __init__(self):
     submod = get_service_name() or 'sample_uploader'
     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_sample_uploader.import_samples,
                          name='sample_uploader.import_samples',
                          types=[dict])
     self.method_authentication[
         'sample_uploader.import_samples'] = 'required'  # noqa
     self.rpc_service.add(impl_sample_uploader.import_samples_from_IGSN,
                          name='sample_uploader.import_samples_from_IGSN',
                          types=[dict])
     self.method_authentication[
         'sample_uploader.import_samples_from_IGSN'] = 'required'  # noqa
     self.rpc_service.add(impl_sample_uploader.import_samples_from_NCBI,
                          name='sample_uploader.import_samples_from_NCBI',
                          types=[dict])
     self.method_authentication[
         'sample_uploader.import_samples_from_NCBI'] = 'required'  # noqa
     self.rpc_service.add(impl_sample_uploader.generate_OTU_sheet,
                          name='sample_uploader.generate_OTU_sheet',
                          types=[dict])
     self.method_authentication[
         'sample_uploader.generate_OTU_sheet'] = 'required'  # noqa
     self.rpc_service.add(impl_sample_uploader.update_sample_set_acls,
                          name='sample_uploader.update_sample_set_acls',
                          types=[dict])
     self.method_authentication[
         'sample_uploader.update_sample_set_acls'] = 'required'  # noqa
     self.rpc_service.add(impl_sample_uploader.export_samples,
                          name='sample_uploader.export_samples',
                          types=[dict])
     self.method_authentication[
         'sample_uploader.export_samples'] = 'required'  # noqa
     self.rpc_service.add(impl_sample_uploader.link_reads,
                          name='sample_uploader.link_reads',
                          types=[dict])
     self.method_authentication[
         'sample_uploader.link_reads'] = 'required'  # noqa
     self.rpc_service.add(impl_sample_uploader.status,
                          name='sample_uploader.status',
                          types=[dict])
     authurl = config.get(AUTH) if config else None
     self.auth_client = _KBaseAuth(authurl)
Exemplo n.º 2
0
 def setUpClass(cls):
     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('sample_uploader'):
         cls.cfg[nameval[0]] = nameval[1]
     authServiceUrl = cls.cfg['auth-service-url']
     auth_client = _KBaseAuth(authServiceUrl)
     cls.username = auth_client.get_user(cls.token)
     cls.test_dir = os.path.dirname(
         os.path.dirname(os.path.realpath(__file__)))
     sample_server = cls.cfg.get('sample-server', 'sampleservice')
     cls.sample_url = cls.cfg['kbase-endpoint'] + '/{}'.format(
         sample_server)
     cls.workspace_url = cls.cfg['workspace-url']
     cls.callback_url = os.environ['SDK_CALLBACK_URL']
Exemplo n.º 3
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('sample_uploader'):
         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': 'sample_uploader',
             'method': 'please_never_use_it_in_production',
             'method_params': []
         }],
         'authenticated':
         1
     })
     cls.curr_dir = os.path.dirname(os.path.realpath(__file__))
     cls.wsURL = cls.cfg['workspace-url']
     cls.wsClient = Workspace(cls.wsURL, token=token)
     cls.serviceImpl = sample_uploader(cls.cfg)
     # cls.curr_dir = os.path.dirname(os.path.realpath(__file__))
     cls.scratch = cls.cfg['scratch']
     # cls.wiz_url = cls.cfg['srv-wiz-url']
     cls.sample_url = cls.cfg['kbase-endpoint'] + '/sampleservice'
     cls.callback_url = os.environ['SDK_CALLBACK_URL']
     suffix = int(time.time() * 1000)
     cls.wsName = "test_ContigFilter_" + str(suffix)
     ret = cls.wsClient.create_workspace({'workspace': cls.wsName})  # noqa
     cls.wsID = ret[0]
Exemplo n.º 4
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('sample_uploader'):
         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': 'sample_uploader',
             'method': 'please_never_use_it_in_production',
             'method_params': []
         }],
         'authenticated':
         1
     })
     cls.wsURL = cls.cfg['workspace-url']
     cls.wsClient = Workspace(cls.wsURL, token=token)
     cls.serviceImpl = sample_uploader(cls.cfg)
     cls.curr_dir = os.path.dirname(os.path.realpath(__file__))
     cls.scratch = cls.cfg['scratch']
     cls.wiz_url = cls.cfg['srv-wiz-url']
     cls.sample_url = cls.cfg['kbase-endpoint'] + '/sampleservice'
     cls.callback_url = os.environ['SDK_CALLBACK_URL']
     suffix = int(time.time() * 1000)
     cls.wsName = "test_sample_uploader_" + str(suffix)
     ret = cls.wsClient.create_workspace({'workspace': cls.wsName})  # noqa
     cls.wsID = ret[0]
     cls.sesar_sample_file = os.path.join(cls.curr_dir, "data",
                                          "fake_samples.tsv")
     cls.sample_set_name = "test_sample_set_1"
     params = {
         'workspace_name': cls.wsName,
         'workspace_id': cls.wsID,
         'sample_file': cls.sesar_sample_file,
         'file_format': "sesar",
         'header_row_index': 2,
         'set_name': cls.sample_set_name,
         'description': "this is a test sample set.",
         'output_format': "",
         'name_field': "test name field",
         'incl_input_in_output': 1,
         'share_within_workspace': 1,
     }
     ret = cls.serviceImpl.import_samples(cls.ctx, params)[0]
     cls.sample_set = ret['sample_set']
     cls.a_sample_id = ret['sample_set']['samples'][0]['id']
     cls.sample_set_ref = ret['sample_set_ref']
     # add new user to test permissions
     cls.wsClient.set_permissions({
         "id": cls.wsID,
         "new_permission": "w",
         "users": ["psdehal"]
     })