diff --git a/NarrativeService.spec b/NarrativeService.spec index 247de18..56702d2 100644 --- a/NarrativeService.spec +++ b/NarrativeService.spec @@ -104,7 +104,6 @@ module NarrativeService { converted into string). types - optional filter field, limiting output list to set of types. includeMetadata - if 1, includes object metadata, if 0, does not. Default 0. - include_data_palettes - if 1, includes data palette info, if 0, does not. Default 0. */ typedef structure { string ws_name; @@ -112,13 +111,11 @@ module NarrativeService { list workspaces; list types; boolean includeMetadata; - boolean include_data_palettes; } ListObjectsWithSetsParams; /* data_palette_refs - mapping from workspace Id to reference to DataPalette - container existing in given workspace. Not present if include_data_palettes is 0 - in the input parameters. + container existing in given workspace. */ typedef structure { list data; diff --git a/lib/NarrativeService/NarrativeManager.py b/lib/NarrativeService/NarrativeManager.py index 305797b..7d8fc51 100644 --- a/lib/NarrativeService/NarrativeManager.py +++ b/lib/NarrativeService/NarrativeManager.py @@ -39,15 +39,15 @@ def __init__(self, config, ctx, set_api_cache, dps_cache): self.DATA_PALETTES_TYPES = DataPaletteTypes(True) def list_objects_with_sets(self, ws_id=None, ws_name=None, workspaces=None, - types=None, include_metadata=0, include_data_palettes=0): + types=None, include_metadata=0): if not workspaces: if not ws_id and not ws_name: raise ValueError("One and only one of 'ws_id', 'ws_name', 'workspaces' " + "parameters should be set") workspaces = [self._get_workspace_name_or_id(ws_id, ws_name)] - return self._list_objects_with_sets(workspaces, types, include_metadata, include_data_palettes) + return self._list_objects_with_sets(workspaces, types, include_metadata) - def _list_objects_with_sets(self, workspaces, types, include_metadata, include_data_palettes): + def _list_objects_with_sets(self, workspaces, types, include_metadata): type_map = None if types is not None: type_map = {key: True for key in types} @@ -117,42 +117,35 @@ def _list_objects_with_sets(self, workspaces, types, include_metadata, include_d if self.DEBUG: print(" (time=" + str(time.time() - t3) + ")") - return_data = { - "data": data - } - - if include_data_palettes == 1: - if self.DEBUG: - print("NarrativeManager._list_objects_with_sets: processing DataPalettes") - t5 = time.time() - if dp_data is None or dp_refs is None: - dps = self.dps_cache - dp_ret = dps.call_method("list_data", [{'workspaces': workspaces, - 'include_metadata': include_metadata}], - self.token) - dp_data = dp_ret['data'] - dp_refs = dp_ret['data_palette_refs'] - for item in dp_data: - ref = item['ref'] - if self._check_info_type(item['info'], type_map): - data_item = None - if ref in processed_refs: - data_item = processed_refs[ref] - else: - data_item = {'object_info': item['info']} - processed_refs[ref] = data_item - data.append(data_item) - dp_info = {} - if 'dp_ref' in item: - dp_info['ref'] = item['dp_ref'] - if 'dp_refs' in item: - dp_info['refs'] = item['dp_refs'] - data_item['dp_info'] = dp_info - return_data["data_palette_refs"] = dp_refs - if self.DEBUG: - print(" (time=" + str(time.time() - t5) + ")") - - return return_data + if self.DEBUG: + print("NarrativeManager._list_objects_with_sets: processing DataPalettes") + t5 = time.time() + if dp_data is None or dp_refs is None: + dps = self.dps_cache + dp_ret = dps.call_method("list_data", [{'workspaces': workspaces, + 'include_metadata': include_metadata}], + self.token) + dp_data = dp_ret['data'] + dp_refs = dp_ret['data_palette_refs'] + for item in dp_data: + ref = item['ref'] + if self._check_info_type(item['info'], type_map): + data_item = None + if ref in processed_refs: + data_item = processed_refs[ref] + else: + data_item = {'object_info': item['info']} + processed_refs[ref] = data_item + data.append(data_item) + dp_info = {} + if 'dp_ref' in item: + dp_info['ref'] = item['dp_ref'] + if 'dp_refs' in item: + dp_info['refs'] = item['dp_refs'] + data_item['dp_info'] = dp_info + if self.DEBUG: + print(" (time=" + str(time.time() - t5) + ")") + return {"data": data, 'data_palette_refs': dp_refs} def _check_info_type(self, info, type_map): if type_map is None: diff --git a/lib/NarrativeService/NarrativeServiceImpl.py b/lib/NarrativeService/NarrativeServiceImpl.py index 3ef4599..fe867e3 100644 --- a/lib/NarrativeService/NarrativeServiceImpl.py +++ b/lib/NarrativeService/NarrativeServiceImpl.py @@ -26,8 +26,8 @@ class NarrativeService: # the latter method is running. ######################################### noqa VERSION = "0.2.1" - GIT_URL = "https://github.com/briehl/NarrativeService" - GIT_COMMIT_HASH = "d57f119e95cc9b8132ff4993cb0de4e11a0eb3ff" + GIT_URL = "https://github.com/Tianhao-Gu/NarrativeService.git" + GIT_COMMIT_HASH = "1a9ec28a5fbc301e62945e12404470c53d62dd52" #BEGIN_CLASS_HEADER def _nm(self, ctx): @@ -65,17 +65,14 @@ def list_objects_with_sets(self, ctx, params): (in case of 'workspaces' each string could be workspace name or ID converted into string). types - optional filter field, limiting output list to set of types. includeMetadata - if 1, includes - object metadata, if 0, does not. Default 0. include_data_palettes - - if 1, includes data palette info, if 0, does not. Default 0.) -> - structure: parameter "ws_name" of String, parameter "ws_id" of - Long, parameter "workspaces" of list of String, parameter "types" - of list of String, parameter "includeMetadata" of type "boolean" - (@range [0,1]), parameter "include_data_palettes" of type - "boolean" (@range [0,1]) + object metadata, if 0, does not. Default 0.) -> structure: + parameter "ws_name" of String, parameter "ws_id" of Long, + parameter "workspaces" of list of String, parameter "types" of + list of String, parameter "includeMetadata" of type "boolean" + (@range [0,1]) :returns: instance of type "ListObjectsWithSetsOutput" (data_palette_refs - mapping from workspace Id to reference to - DataPalette container existing in given workspace. Not present if - include_data_palettes is 0 in the input parameters.) -> structure: + DataPalette container existing in given workspace.) -> structure: parameter "data" of list of type "ListItem" (object_info - workspace info for object (including set object), set_items - optional property listing info for items of set object, dp_info - @@ -138,11 +135,9 @@ def list_objects_with_sets(self, ctx, params): workspaces = params.get("workspaces") types = params.get("types") include_metadata = params.get("includeMetadata", 0) - include_data_palettes = params.get("include_data_palettes", 0) - returnVal = self._nm(ctx).list_objects_with_sets( - ws_id=ws_id, ws_name=ws_name, workspaces=workspaces, types=types, - include_metadata=include_metadata, include_data_palettes=include_data_palettes - ) + returnVal = self._nm(ctx).list_objects_with_sets(ws_id=ws_id, ws_name=ws_name, + workspaces=workspaces, types=types, + include_metadata=include_metadata) #END list_objects_with_sets # At some point might do deeper type checking... diff --git a/lib/NarrativeService/NarrativeServiceServer.py b/lib/NarrativeService/NarrativeServiceServer.py index efa8591..de84c60 100644 --- a/lib/NarrativeService/NarrativeServiceServer.py +++ b/lib/NarrativeService/NarrativeServiceServer.py @@ -381,10 +381,6 @@ def __init__(self): name='NarrativeService.get_all_app_info', types=[dict]) self.method_authentication['NarrativeService.get_all_app_info'] = 'none' # noqa - self.rpc_service.add(impl_NarrativeService.get_ignore_categories, - name='NarrativeService.get_ignore_categories', - types=[]) - self.method_authentication['NarrativeService.get_ignore_categories'] = 'none' # noqa self.rpc_service.add(impl_NarrativeService.status, name='NarrativeService.status', types=[dict]) diff --git a/test/NarrativeService_server_test.py b/test/NarrativeService_server_test.py index 7ea4027..8109430 100644 --- a/test/NarrativeService_server_test.py +++ b/test/NarrativeService_server_test.py @@ -167,26 +167,8 @@ def test_list_object_with_sets(self): set_items = item["set_items"]["set_items_info"] self.assertEqual(1, len(set_items)) self.assertEqual(1, set_count) - self.assertNotIn('data_palette_refs', list_ret) - ws_id = self.getWsClient().get_workspace_info({"workspace": ws_name1})[0] - - list_ret = self.getImpl().list_objects_with_sets(self.getContext(), - {"ws_name": ws_name1, - "include_data_palettes": 1})[0] - ret = list_ret['data'] - self.assertTrue(len(ret) > 0) - set_count = 0 - for item in ret: - self.assertTrue("object_info" in item) - if "set_items" in item: - set_count += 1 - set_items = item["set_items"]["set_items_info"] - self.assertEqual(1, len(set_items)) - self.assertEqual(1, set_count) self.assertIn('data_palette_refs', list_ret) ws_id = self.getWsClient().get_workspace_info({"workspace": ws_name1})[0] - - ret2 = self.getImpl().list_objects_with_sets(self.getContext(), {"ws_id": ws_id})[0]["data"] self.assertEqual(len(ret), len(ret2)) @@ -285,8 +267,7 @@ def test_copy_narrative(self): self.assertNotEqual(ws_name, copy_nar_data['metadata']['ws_name']) self.assertEqual(copy_nar_name, copy_nar_data['metadata']['name']) ret = self.getImpl().list_objects_with_sets(self.getContext(), - {"ws_id": copy_ws_id, - "include_data_palettes": 1})[0]["data"] + {"ws_id": copy_ws_id})[0]["data"] dp_found = False for item in ret: obj_info = item["object_info"] @@ -320,6 +301,7 @@ def test_copy_narrative(self): try: ret = self.getImpl().list_objects_with_sets(self.getContext(), {"ws_id": copy_ws_id})[0]["data"] + dp_found = False for item in ret: obj_info = item["object_info"] if obj_info[7] == reads_ws_name: @@ -328,6 +310,7 @@ def test_copy_narrative(self): self.assertTrue('refs' in item['dp_info']) self.assertEqual(str(copy_ws_id), item['dp_info']['ref'].split('/')[0]) self.assertEqual(reads_obj_name, obj_info[1]) + dp_found = True self.assertTrue(dp_found) finally: # Cleaning up new created workspace @@ -487,8 +470,7 @@ def test_copy_narrative_two_users(self): copy_ws_id = ret['newWsId'] try: ret = self.getImpl().list_objects_with_sets(self.getContext2(), - {"ws_name": str(copy_ws_id), - "include_data_palettes": 1})[0]["data"] + {"ws_name": str(copy_ws_id)})[0]["data"] found = False for item in ret: info = item['object_info'] @@ -596,8 +578,7 @@ def test_copy_object(self): target_name = ret[0]['info']['name'] # Let's check that we see reads copy in list_objects_with_sets ret = self.getImpl().list_objects_with_sets(self.getContext(), - {"ws_name": ws_name, - "include_data_palettes": 1})[0]["data"] + {"ws_name": ws_name})[0]["data"] found = False for item in ret: obj_info = item["object_info"] @@ -630,8 +611,7 @@ def test_copy_object_two_users(self): 'users': [self.getContext2()['user_id']]}) # Get ref-path to reads object ret = self.getImpl().list_objects_with_sets(self.getContext(), - {"ws_name": ws_name1, - "include_data_palettes": 1})[0]['data'] + {"ws_name": ws_name1})[0]['data'] reads_ref_path = None for item in ret: if 'dp_info' in item: @@ -730,8 +710,7 @@ def test_two_users_sharing_dp(self): # Let's check that we can list and access reads object ret = self.getImpl().list_objects_with_sets(self.getContext2(), {"ws_name": ws_name2, - "includeMetadata": 0, - "include_data_palettes": 1})[0]["data"] + "includeMetadata": 0})[0]["data"] self.assertEqual(1, len(ret)) item = ret[0] self.assertTrue('dp_info' in item)