当前位置: 首页>>代码示例>>Python>>正文


Python Workspace.list_objects方法代码示例

本文整理汇总了Python中biokbase.workspace.client.Workspace.list_objects方法的典型用法代码示例。如果您正苦于以下问题:Python Workspace.list_objects方法的具体用法?Python Workspace.list_objects怎么用?Python Workspace.list_objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在biokbase.workspace.client.Workspace的用法示例。


在下文中一共展示了Workspace.list_objects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_cleanup

# 需要导入模块: from biokbase.workspace.client import Workspace [as 别名]
# 或者: from biokbase.workspace.client.Workspace import list_objects [as 别名]
 def test_cleanup(self):
     ''' Cleanup objects created by tests. '''
     
     # Delete all of the objects in the test workspace.
     wsClient = Workspace(self._config["workspace_url"], token=self._token)
     listObjectsParams = dict()
     listObjectsParams['workspaces'] = [ self._config['test_ws'] ]
     objectList = wsClient.list_objects(listObjectsParams)
     deleteList = list()
     for object in objectList:
         deleteList.append( { 'wsid': object[6], 'objid': object[0], 'ver': object[4] })
     wsClient.delete_objects(deleteList)
     objectList = wsClient.list_objects(listObjectsParams)
     for object in objectList:
         print 'After delete Object %s %s' %(object[1], object[4])
开发者ID:kbase,项目名称:probabilistic_annotation,代码行数:17,代码来源:test-python-client.py

示例2: setUp

# 需要导入模块: from biokbase.workspace.client import Workspace [as 别名]
# 或者: from biokbase.workspace.client.Workspace import list_objects [as 别名]
    def setUp(cls):

      token = environ.get('KB_AUTH_TOKEN', None)

      if token is None:
          sys.stderr.write("Error: Unable to run tests without authentication token!\n")
          sys.exit(1)

      token_file = open('ltest/script_test/token.txt', 'w')
      token_file.write(token)

      config_file = environ.get('KB_DEPLOYMENT_CONFIG', None)
      cls.cfg = {}
      config = ConfigParser()
      config.read(config_file)
      for nameval in config.items('CoExpression'):
          cls.cfg[nameval[0]] = nameval[1]
      auth_service_url = cls.cfg.get('auth-service-url',
                                     "https://kbase.us/services/authorization/Sessions/Login")
      ws_url = cls.cfg['ws_url']
      auth_service_url_allow_insecure = cls.cfg['auth-service-url-allow-insecure']
      auth_client = _KBaseAuth(auth_service_url)
      user_id = auth_client.get_user(token)

      ws = Workspace(url=ws_url, token=token, auth_svc=auth_service_url,
                             trust_all_ssl_certificates=auth_service_url_allow_insecure)

      # update input data in reverse order of references
      ordered_file_list = [INPUT_META_DATA_DIR+'/test_diff_p_distribution_input_ref2.json',
                      INPUT_META_DATA_DIR+'/test_diff_p_distribution_input_ref1.json',
                      INPUT_META_DATA_DIR+'/test_diff_p_distribution_input.json',
                      INPUT_META_DATA_DIR+'/test_view_heatmap_input_ref1.json',
                      INPUT_META_DATA_DIR+'/test_view_heatmap_input.json',
                      INPUT_META_DATA_DIR+'/test_coex_clust_input.json',
                      INPUT_META_DATA_DIR+'/test_filter_genes_input.json']

      for filename in ordered_file_list:
          with open(filename, 'r') as infile:
            input_meta_data = json.load(infile)

          # create workspace that is local to the user if it does not exist
          workspace_name_t = Template(str(input_meta_data['params'][0]['workspace_name']))
          workspace_name = workspace_name_t.substitute(user_id=user_id)
          print('workspace_name: ' + workspace_name)

          try:
              ws_info = ws.get_workspace_info({'workspace': workspace_name})
              print("workspace already exists: " + str(ws_info))
          except:
              ws_info = ws.create_workspace(
                {'workspace': workspace_name, 'description': 'Workspace for ' + str(input_meta_data['method'])})
              print("Created new workspace: " + str(ws_info))

          print('reading input file: '+filename)
          object_name = str(input_meta_data['params'][0]['object_name'])
          print('object_name: '+object_name)

          input_data_filename = INPUT_DATA_DIR + '/' + object_name + '.json'
          print('input data filename: ' + input_data_filename)

          with open(input_data_filename, 'r') as infile:
            input_data = json.load(infile)

          # update workspace name in input data
          input_data_str = json.dumps(input_data)
          input_data_t = Template(input_data_str)
          input_data_str = input_data_t.substitute(workspace_name=workspace_name)
          input_data = json.loads(input_data_str)

          print('type: '+input_data[0]['info'][2])

          #upload data (no effect if data already exists in workspace)
          print('uploading input data to workspace')
          ws.save_objects(
                  {'workspace': workspace_name, 'objects': [{'type': input_data[0]['info'][2],
                                                                  'data': input_data[0]['data'],
                                                                  'name': object_name}]})
      print('ws objects: ' + str(ws.list_objects({'workspaces': [workspace_name]})))
开发者ID:kbase,项目名称:coexpression,代码行数:80,代码来源:basic_test.py


注:本文中的biokbase.workspace.client.Workspace.list_objects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。