Skip to content

Commit bc7b13b

Browse files
committed
changind dev version and merging with latest friday
2 parents 0d2cad4 + c9b2127 commit bc7b13b

File tree

6 files changed

+55
-46
lines changed

6 files changed

+55
-46
lines changed

docs/source/superannotate.sdk.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Subsets
9494
______
9595

9696
.. automethod:: superannotate.SAClient.get_subsets
97+
.. automethod:: superannotate.SAClient.add_items_to_subset
9798

9899
----------
99100

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ plotly==4.1.0
1313
ffmpeg-python>=0.2.0
1414
fire==0.4.0
1515
mixpanel==4.8.3
16-
pydantic>=1.8.2
16+
pydantic>=1.10.2
1717
setuptools~=57.4.0
1818
aiohttp==3.8.1
1919
email-validator>=1.0.3

src/superannotate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sys
33

4-
__version__ = "4.4.4dev8"
4+
__version__ = "4.4.5dev3"
55

66
sys.path.append(os.path.split(os.path.realpath(__file__))[0])
77

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3052,7 +3052,7 @@ def add_items_to_subset(
30523052
30533053
Associates selected items with a given subset. Non-existing subset will be automatically created.
30543054
3055-
:param project: project name (e.g., “project1”)
3055+
:param project: project name (e.g., “project1”)
30563056
:type project: str
30573057
30583058
:param subset: a name of an existing/new subset to associate items with. New subsets will be automatically created.
@@ -3062,49 +3062,55 @@ def add_items_to_subset(
30623062
:type items: list of dicts
30633063
30643064
Request Example:
3065-
30663065
::
3067-
client = SAClient()
3066+
client = SAClient()
30683067
3069-
# option 1
3070-
queried_items = client.query(
3071-
project="Image Project",
3072-
query="instance(error = true)"
3073-
)
3068+
# option 1
3069+
queried_items = client.query(
3070+
project="Image Project",
3071+
query="instance(error = true)"
3072+
)
30743073
3075-
client.add_items_to_subset(
3076-
project="Medical Annotations",
3077-
subset="Brain Study - Disapproved",
3078-
items=queried_items
3079-
)
3080-
3081-
items_list = [
3082-
{
3083-
'name': 'image_1.jpeg',
3084-
'path': 'Image Project'
3085-
},
3086-
{
3087-
'name': 'image_2.jpeg',
3088-
'path': 'Image Project/Subfolder A'
3089-
}
3090-
]
3074+
client.add_items_to_subset(
3075+
project="Medical Annotations",
3076+
subset="Brain Study - Disapproved",
3077+
items=queried_items
3078+
)
30913079
3092-
client.add_items_to_subset(
3093-
project="Image Project",
3094-
subset="Subset Name",
3095-
items=items_list
3080+
items_list = [
3081+
{
3082+
'name': 'image_1.jpeg',
3083+
'path': 'Image Project'
3084+
},
3085+
{
3086+
'name': 'image_2.jpeg',
3087+
'path': 'Image Project/Subfolder A'
3088+
}
3089+
]
30963090
3097-
)
3091+
client.add_items_to_subset(
3092+
project="Image Project",
3093+
subset="Subset Name",
3094+
items=items_list
30983095
3096+
)
30993097
31003098
Response Example:
31013099
::
3102-
{
3103-
"succeeded": [{}, {}],
3104-
"failed": [],
3105-
"skipped": []
3106-
}
3107-
3100+
{
3101+
"succeeded": [
3102+
{
3103+
'name': 'image_1.jpeg',
3104+
'path': 'Image Project'
3105+
},
3106+
{
3107+
'name': 'image_2.jpeg',
3108+
'path': 'Image Project/Subfolder A'
3109+
}
3110+
],
3111+
"failed": [],
3112+
"skipped": []
3113+
}
31083114
"""
31093115

31103116
project_name, _ = extract_project_folder(project)

src/superannotate/lib/core/usecases/items.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def __init__(
145145
folder: FolderEntity,
146146
backend_service_provider: SuperannotateServiceProvider,
147147
query: str,
148-
subset: str,
148+
subset: str = None,
149149
):
150150
super().__init__(reporter)
151151
self._project = project
@@ -918,7 +918,8 @@ def __separate_to_paths(
918918
folders=self.folder_repository,
919919
condition=Condition.get_empty_condition(),
920920
).execute()
921-
921+
if folder_candidates.errors:
922+
raise AppException(folder_candidates.errors)
922923
for f in folder_candidates.data:
923924
if f.name == folder:
924925
value["folder"] = f
@@ -931,7 +932,7 @@ def __separate_to_paths(
931932
except Exception as e:
932933
removeables.append(path)
933934

934-
## Removing completely incorrect paths and their items
935+
# Removing completely incorrect paths and their items
935936
for item in removeables:
936937
self.results["skipped"].extend(self.path_separated[item]["items"])
937938
self.path_separated.pop(item)
@@ -945,7 +946,6 @@ def __build_query_string(self, path, item_names):
945946
return query_str
946947

947948
def __query(self, path, items):
948-
folder = None
949949
_, folder = extract_project_folder(path)
950950

951951
item_names = [item["name"] for item in items["items"]]
@@ -1041,7 +1041,9 @@ def execute(
10411041
self.subset_name,
10421042
)
10431043

1044-
self.reporter.log_info("You've successfully created a new subset - {subset name}.")
1044+
self.reporter.log_info(
1045+
f"You've successfully created a new subset - {self.subset_name}."
1046+
)
10451047

10461048
subset_id = subset["id"]
10471049
response = None
@@ -1050,7 +1052,7 @@ def execute(
10501052
tmp_response = self._backend_client.add_items_to_subset(
10511053
project_id=self.project.id,
10521054
team_id=self.project.team_id,
1053-
item_ids=self.item_ids[i : i + self.CHUNK_SIZE],
1055+
item_ids=self.item_ids[i : i + self.CHUNK_SIZE], # noqa
10541056
subset_id=subset_id,
10551057
)
10561058

src/superannotate/lib/infrastructure/services.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,9 @@ def sort_items_by_size(
16631663
response_data["large"].extend(response_json.get("large", []))
16641664
return response_data
16651665

1666-
def add_items_to_subset(self, project_id, team_id, item_ids, subset_id):
1666+
def add_items_to_subset(
1667+
self, project_id: int, team_id: int, item_ids: List[int], subset_id: int
1668+
):
16671669
params = {"team_id": team_id}
16681670

16691671
data = {"action": "ATTACH", "item_ids": item_ids}
@@ -1711,7 +1713,6 @@ def get_subset(self, team_id, project_id, subset_name):
17111713
for subset in subsets:
17121714
if subset["name"] == subset_name:
17131715
return subset
1714-
17151716
return None
17161717

17171718
def create_subset(self, team_id, project_id, subset_name):
@@ -1732,5 +1733,4 @@ def create_subset(self, team_id, project_id, subset_name):
17321733
if not response.ok:
17331734
raise AppException(response.json().get("errors", "undefined"))
17341735

1735-
17361736
return response.json()[0]

0 commit comments

Comments
 (0)