Skip to content

Commit

Permalink
[DEVX-572]: Removing 'id-' prefix from concept ids from SDK (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthbachala20 authored Oct 15, 2024
1 parent 2796865 commit 2aaf180
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions clarifai/client/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.)
]))
])
Expand Down Expand Up @@ -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.)
]))
])
Expand Down
2 changes: 1 addition & 1 deletion clarifai/datasets/upload/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
10 changes: 5 additions & 5 deletions tests/test_data_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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])
Expand All @@ -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]
Expand All @@ -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

Expand Down

0 comments on commit 2aaf180

Please sign in to comment.