Skip to content

Commit 67f6da2

Browse files
author
Claire Pajot
committed
Refactored
1 parent 1e2f93b commit 67f6da2

File tree

2 files changed

+16
-25
lines changed

2 files changed

+16
-25
lines changed

nucleus/__init__.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@
128128
construct_box_predictions_payload,
129129
construct_model_creation_payload,
130130
construct_segmentation_payload,
131-
construct_taxonomy_payload,
132131
)
133132
from .prediction import (
134133
BoxPrediction,
@@ -1250,27 +1249,6 @@ def create_image_index(self, dataset_id: str):
12501249
requests_command=requests.post,
12511250
)
12521251

1253-
def add_taxonomy(
1254-
self,
1255-
dataset_id: str,
1256-
taxonomy_name: str,
1257-
taxonomy_type: str,
1258-
labels: List[str],
1259-
):
1260-
"""
1261-
Creates a new taxonomy.
1262-
Returns a response with dataset_id, taxonomy_name and type for the new taxonomy.
1263-
:param dataset_id: id of dataset to add the taxonomy to
1264-
:param taxonomy_name: name of the taxonomy
1265-
:param type: type of the taxonomy
1266-
:param labels: list of possible labels for the taxonomy
1267-
"""
1268-
return self.make_request(
1269-
construct_taxonomy_payload(taxonomy_name, taxonomy_type, labels),
1270-
f"dataset/{dataset_id}/add_taxonomy",
1271-
requests_command=requests.post,
1272-
)
1273-
12741252
def make_request(
12751253
self, payload: dict, route: str, requests_command=requests.post
12761254
) -> dict:

nucleus/dataset.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from .payload_constructor import (
3737
construct_append_scenes_payload,
3838
construct_model_run_creation_payload,
39+
construct_taxonomy_payload,
3940
)
4041

4142
WARN_FOR_LARGE_UPLOAD = 50000
@@ -408,10 +409,22 @@ def create_image_index(self):
408409
return AsyncJob.from_json(response, self._client)
409410

410411
def add_taxonomy(
411-
self, taxonomy_name: str, taxonomy_type: str, labels: List[str]
412+
self,
413+
taxonomy_name: str,
414+
taxonomy_type: str,
415+
labels: List[str],
412416
):
413-
return self._client.add_taxonomy(
414-
self.id, taxonomy_name, taxonomy_type, labels
417+
"""
418+
Creates a new taxonomy.
419+
Returns a response with dataset_id, taxonomy_name and type for the new taxonomy.
420+
:param taxonomy_name: name of the taxonomy
421+
:param type: type of the taxonomy
422+
:param labels: list of possible labels for the taxonomy
423+
"""
424+
return self._client.make_request(
425+
construct_taxonomy_payload(taxonomy_name, taxonomy_type, labels),
426+
f"dataset/{self.id}/add_taxonomy",
427+
requests_command=requests.post,
415428
)
416429

417430
def check_index_status(self, job_id: str):

0 commit comments

Comments
 (0)