From 2aaf180badafba9dc06218688de53bffad378ec8 Mon Sep 17 00:00:00 2001 From: Srikanth Bachala Date: Tue, 15 Oct 2024 19:11:01 +0530 Subject: [PATCH] [DEVX-572]: Removing 'id-' prefix from concept ids from SDK (#424) --- clarifai/client/input.py | 6 +++--- clarifai/datasets/upload/utils.py | 2 +- tests/test_data_upload.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clarifai/client/input.py b/clarifai/client/input.py index 512c725a..a8610d87 100644 --- a/clarifai/client/input.py +++ b/clarifai/client/input.py @@ -100,7 +100,7 @@ def _get_proto(input_id: str, if not label_ids: concepts=[ resources_pb2.Concept( - id=f"id-{''.join(_label.split(' '))}", name=_label, value=1.)\ + id=_label, name=_label, value=1.)\ for _label in labels ] else: @@ -516,7 +516,7 @@ def get_bbox_proto(input_id: str, right_col=bbox[2] #x_max )), data=resources_pb2.Data(concepts=[ - resources_pb2.Concept(id=f"id-{''.join(label.split(' '))}", name=label, value=1.) + resources_pb2.Concept(id=label, name=label, value=1.) if not label_id else resources_pb2.Concept(id=label_id, name=label, value=1.) ])) ]) @@ -561,7 +561,7 @@ def get_mask_proto(input_id: str, visibility="VISIBLE") for _point in polygons ])), data=resources_pb2.Data(concepts=[ - resources_pb2.Concept(id=f"id-{''.join(label.split(' '))}", name=label, value=1.) + resources_pb2.Concept(id=label, name=label, value=1.) if not label_id else resources_pb2.Concept(id=label_id, name=label, value=1.) ])) ]) diff --git a/clarifai/datasets/upload/utils.py b/clarifai/datasets/upload/utils.py index e35c31e9..0765ce97 100644 --- a/clarifai/datasets/upload/utils.py +++ b/clarifai/datasets/upload/utils.py @@ -143,7 +143,7 @@ def get_dataset_version_stats( for data in dict_response["datasetVersionMetricsGroups"]: if isinstance(data["value"], str): - if data["value"].startswith("id-"): + if ("type" in data) and (data["type"] == "CONCEPT_ID"): data["metrics"].update({"Concept": data["value"]}) data["metrics"].pop("regionLocationMatrix", None) dataset_statistics.append(data["metrics"]) diff --git a/tests/test_data_upload.py b/tests/test_data_upload.py index 2b04c50a..88fb550b 100644 --- a/tests/test_data_upload.py +++ b/tests/test_data_upload.py @@ -151,7 +151,7 @@ def test_get_mask_proto(self): input_id="input_1", label="input_1_polygon_label", polygons=polygon_points, - label_id="id-input_1_polygon_label", + label_id="input_1_polygon_label", annot_id="input_1_polygon_annot") assert annotation.id == "input_1_polygon_annot" and annotation.input_id == "input_1" @@ -179,7 +179,7 @@ def test_patch_annotations(self, caplog): input_id="input_1", label="input_1_label", bbox=bbox_points, - label_id="id-input_1_label", + label_id="input_1_label", annot_id="input_1_annot") with caplog.at_level(logging.INFO): self.input_object.upload_annotations([annotation]) @@ -190,7 +190,7 @@ def test_patch_annotations(self, caplog): input_id="input_1", label="input_1_label", bbox=bbox_points, - label_id="id-input_1_label", + label_id="input_1_label", annot_id="input_1_annot") self.input_object.patch_annotations([annotation], action='merge') test_annotation = list(self.input_object.list_annotations())[0] @@ -201,10 +201,10 @@ def test_patch_annotations(self, caplog): def test_patch_concepts(self): self.input_object.patch_concepts( - concept_ids=["id-input_1_label"], labels=["SUCCESS"], values=[], action='overwrite') + concept_ids=["input_1_label"], labels=["SUCCESS"], values=[], action='overwrite') concepts = list(self.app.list_concepts()) for concept in concepts: - if concept.id == "id-input_1_label": + if concept.id == "input_1_label": assert concepts[0].name == "SUCCESS" break