Skip to content

Commit f70481e

Browse files
committed
Add repeat row support in item_context method
1 parent 2c7c5d1 commit f70481e

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed

CHANGELOG.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ History
66

77
All release highlights of this project will be documented in this file.
88

9+
4.4.34 - April 11, 2025
10+
______________________
11+
12+
**Added**
13+
14+
- ``SAClient.get_integrations`` Added integration_id in integration metadata.
15+
- ``SAClient.list_workflows`` Retrieves team workflows.
16+
17+
**Removed**
18+
- ``SAClient.get_project_workflow``
19+
- ``SAClient.set_project_workflow``
20+
921
4.4.33 - April 1, 2025
1022
______________________
1123

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ minversion = 3.7
33
log_cli=true
44
python_files = test_*.py
55
;pytest_plugins = ['pytest_profiling']
6-
addopts = -n 6 --dist loadscope
6+
;addopts = -n 6 --dist loadscope

src/superannotate/__init__.py

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

55

6-
__version__ = "4.4.34dev1"
6+
__version__ = "4.4.34dev2"
77

88

99
os.environ.update({"sa_version": __version__})

src/superannotate/lib/infrastructure/annotation_adapter.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,39 @@ def save(self):
3939
raise NotImplementedError
4040

4141
def get_component_value(self, component_id: str):
42-
if component_id in self.annotation["data"]:
43-
return self.annotation["data"][component_id]["value"]
42+
component_data = self.annotation.get("data", {}).get(component_id)
43+
if isinstance(component_data, dict):
44+
return component_data.get("value")
45+
elif isinstance(component_data, list):
46+
# Find the dict with the smallest element_path
47+
annotation = min(
48+
(elem for elem in component_data if isinstance(elem, dict) and "element_path" in elem),
49+
key=lambda x: x["element_path"],
50+
default=None
51+
)
52+
if annotation is not None:
53+
return annotation.get("value")
4454
return None
4555

56+
4657
def set_component_value(self, component_id: str, value: Any):
47-
self.annotation.setdefault("data", {}).setdefault(component_id, {})[
48-
"value"
49-
] = value
58+
data = self.annotation.setdefault("data", {})
59+
component_data = data.get(component_id)
60+
61+
if component_data is None:
62+
data[component_id] = [{"value": value}]
63+
elif isinstance(component_data, dict):
64+
component_data["value"] = value
65+
elif isinstance(component_data, list):
66+
# Find the dict with the smallest element_path
67+
annotation = min(
68+
(elem for elem in component_data if isinstance(elem, dict) and "element_path" in elem),
69+
key=lambda x: x["element_path"],
70+
default=None
71+
)
72+
if annotation is not None:
73+
annotation["value"] = value
74+
5075
return self
5176

5277

@@ -71,7 +96,7 @@ def annotation(self) -> dict:
7196
project=self._project,
7297
folder=self._folder,
7398
item_id=self._item.id,
74-
transform_version="llmJsonV2",
99+
transform_version="llmJsonV3",
75100
)
76101
if not response or response.status_code == 404:
77102
self._annotation = {
@@ -88,7 +113,7 @@ def save(self):
88113
project=self._project,
89114
folder=self._folder,
90115
item_id=self._item.id,
91-
transform_version="llmJsonV2",
116+
transform_version="llmJsonV3",
92117
data=self.annotation,
93118
overwrite=self._overwrite,
94119
etag=self._etag,
@@ -104,7 +129,7 @@ def annotation(self) -> dict:
104129
project=self._project,
105130
item=self._item,
106131
reporter=self._controller.reporter,
107-
transform_version="llmJsonV2",
132+
transform_version="llmJsonV3",
108133
)
109134
)
110135
return self._annotation
@@ -117,6 +142,6 @@ def save(self):
117142
item_id=self._item.id,
118143
data=StringIO(json.dumps(self._annotation)),
119144
chunk_size=5 * 1024 * 1024,
120-
transform_version="llmJsonV2",
145+
transform_version="llmJsonV3",
121146
)
122147
)

0 commit comments

Comments
 (0)