本文整理汇总了Python中biokbase.workspace.client.Workspace.get_workspace_info方法的典型用法代码示例。如果您正苦于以下问题:Python Workspace.get_workspace_info方法的具体用法?Python Workspace.get_workspace_info怎么用?Python Workspace.get_workspace_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类biokbase.workspace.client.Workspace
的用法示例。
在下文中一共展示了Workspace.get_workspace_info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_loadGenome
# 需要导入模块: from biokbase.workspace.client import Workspace [as 别名]
# 或者: from biokbase.workspace.client.Workspace import get_workspace_info [as 别名]
def test_loadGenome(self):
''' Load a test Genome object into the test workspace. '''
# Create the test workspace.
wsClient = Workspace(self._config["workspace_url"], token=self._token)
try:
# See if the workspace exists.
wsInfo = wsClient.get_workspace_info( { "workspace": self._config["test_ws"] } )
except WorkspaceServerError as e:
# Hopefully this means the workspace does not exist. (It could also mean someone messed up setting up the URLs)
traceback.print_exc(file=sys.stderr)
wsInfo = wsClient.create_workspace( { "workspace": self._config["test_ws"] } )
# We also need to put in a mapping and a biochemistry object somewhere.
# To do this, I just create a "dependency workspace" and pull them from there.
try:
# See if the workspace exists.
wsInfo = wsClient.get_workspace_info( { "workspace": self._config["dependency_ws"] } )
except WorkspaceServerError as e:
# Hopefully this means the workspace does not exist. (It could also mean someone messed up setting up the URLs)
# traceback.print_exc(file=sys.stderr)
depWsInfo = wsClient.create_workspace( { "workspace": self._config["dependency_ws"] } )
# Load the mapping and biochemistry objects
testContigSet = json.load(open(self._config['contigset_file'], 'r'))
contigSetSaveData = dict()
contigSetSaveData['type'] = 'KBaseGenomes.ContigSet'
contigSetSaveData['name'] = self._config['contigsetid']
contigSetSaveData['data'] = testContigSet
testGenome = json.load(open(self._config["genome_file"], "r"))
genomeSaveData = dict()
genomeSaveData['type'] = 'KBaseGenomes.Genome'
genomeSaveData['name'] = self._config['genomeid']
genomeSaveData['data'] = testGenome
wsClient.save_objects( { 'workspace': self._config['test_ws'], 'objects': [ genomeSaveData, contigSetSaveData ] } )
示例2: setUp
# 需要导入模块: from biokbase.workspace.client import Workspace [as 别名]
# 或者: from biokbase.workspace.client.Workspace import get_workspace_info [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]})))