Skip to content

Commit 51c0a38

Browse files
committed
Merge branch 'develop' into vsaltykovx/add_mmdetection_input_parameters_validation
2 parents d1c521c + 719e80a commit 51c0a38

18 files changed

+158
-88
lines changed

ote_sdk/ote_sdk/entities/annotation.py

+35-13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Annotation(metaclass=abc.ABCMeta):
2626
def __init__(
2727
self, shape: ShapeEntity, labels: List[ScoredLabel], id: Optional[ID] = None
2828
):
29-
self.__id = ID(ObjectId()) if id is None else id
29+
self.__id_ = ID(ObjectId()) if id is None else id
3030
self.__shape = shape
3131
self.__labels = labels
3232

@@ -35,19 +35,29 @@ def __repr__(self):
3535
f"{self.__class__.__name__}("
3636
f"shape={self.shape}, "
3737
f"labels={self.get_labels(True)}, "
38-
f"id={self.id})"
38+
f"id={self.id_})"
3939
)
4040

4141
@property
42-
def id(self):
42+
def id_(self):
4343
"""
4444
Returns the id for the annotation
4545
"""
46-
return self.__id
46+
return self.__id_
47+
48+
@id_.setter
49+
def id_(self, value):
50+
self.__id_ = value
51+
52+
@property
53+
def id(self):
54+
"""DEPRECATED"""
55+
return self.__id_
4756

4857
@id.setter
4958
def id(self, value):
50-
self.__id = value
59+
"""DEPRECATED"""
60+
self.__id_ = value
5161

5262
@property
5363
def shape(self):
@@ -79,7 +89,9 @@ def get_label_ids(self, include_empty: bool = False) -> Set[ID]:
7989
:return: Set of label id's in annotation
8090
"""
8191
return {
82-
label.id for label in self.__labels if include_empty or (not label.is_empty)
92+
label.id_
93+
for label in self.__labels
94+
if include_empty or (not label.is_empty)
8395
}
8496

8597
def append_label(self, label: ScoredLabel):
@@ -101,7 +113,7 @@ def set_labels(self, labels: List[ScoredLabel]):
101113
def __eq__(self, other):
102114
if isinstance(other, Annotation):
103115
return (
104-
self.id == other.id
116+
self.id_ == other.id_
105117
and self.get_labels(True) == other.get_labels(True)
106118
and self.shape == other.shape
107119
)
@@ -163,7 +175,7 @@ def __init__(
163175
self.__kind = kind
164176
self.__editor = editor
165177
self.__creation_date = now() if creation_date is None else creation_date
166-
self.__id = ID() if id is None else id
178+
self.__id_ = ID() if id is None else id
167179

168180
def __repr__(self):
169181
return (
@@ -172,19 +184,29 @@ def __repr__(self):
172184
f"kind={self.kind}, "
173185
f"editor={self.editor_name}, "
174186
f"creation_date={self.creation_date}, "
175-
f"id={self.id})"
187+
f"id={self.id_})"
176188
)
177189

178190
@property
179-
def id(self):
191+
def id_(self):
180192
"""
181193
Returns the ID of the AnnotationSceneEntity.
182194
"""
183-
return self.__id
195+
return self.__id_
196+
197+
@id_.setter
198+
def id_(self, value):
199+
self.__id_ = value
200+
201+
@property
202+
def id(self):
203+
"""DEPRECATED"""
204+
return self.__id_
184205

185206
@id.setter
186207
def id(self, value):
187-
self.__id = value
208+
"""DEPRECATED"""
209+
self.__id_ = value
188210

189211
@property
190212
def kind(self):
@@ -279,7 +301,7 @@ def get_labels(self, include_empty: bool = False) -> List[LabelEntity]:
279301
labels: Dict[str, LabelEntity] = {}
280302
for annotation in self.annotations:
281303
for label in annotation.get_labels(include_empty):
282-
id_ = label.id
304+
id_ = label.id_
283305
if id_ not in labels:
284306
labels[id_] = label.get_label()
285307
return list(labels.values())

ote_sdk/ote_sdk/entities/datasets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def with_empty_annotations(
277277

278278
# reset ROI
279279
roi = copy.copy(dataset_item.roi)
280-
roi.id = ID(ObjectId())
280+
roi.id_ = ID(ObjectId())
281281
roi.set_labels([])
282282

283283
new_dataset_item = DatasetItemEntity(

ote_sdk/ote_sdk/entities/label.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(
102102
self._domain = domain
103103
self._is_empty = is_empty
104104
self._creation_date = creation_date
105-
self._id = id
105+
self.__id_ = id
106106
self.is_anomalous = is_anomalous
107107

108108
@property
@@ -164,26 +164,36 @@ def creation_date(self) -> datetime.datetime:
164164
return self._creation_date
165165

166166
@property
167-
def id(self) -> ID:
167+
def id_(self) -> ID:
168168
"""
169169
Returns the label id.
170170
"""
171-
return self._id
171+
return self.__id_
172+
173+
@id_.setter
174+
def id_(self, value: ID):
175+
self.__id_ = value
176+
177+
@property
178+
def id(self) -> ID:
179+
"""DEPRECATED"""
180+
return self.__id_
172181

173182
@id.setter
174183
def id(self, value: ID):
175-
self._id = value
184+
"""DEPRECATED"""
185+
self.__id_ = value
176186

177187
def __repr__(self):
178188
return (
179-
f"LabelEntity({self.id}, name={self.name}, hotkey={self.hotkey}, "
189+
f"LabelEntity({self.id_}, name={self.name}, hotkey={self.hotkey}, "
180190
f"domain={self.domain}, color={self.color})"
181191
)
182192

183193
def __eq__(self, other):
184194
if isinstance(other, LabelEntity):
185195
return (
186-
self.id == other.id
196+
self.id_ == other.id_
187197
and self.name == other.name
188198
and self.color == other.color
189199
and self.hotkey == other.hotkey
@@ -194,12 +204,12 @@ def __eq__(self, other):
194204

195205
def __lt__(self, other):
196206
if isinstance(other, LabelEntity):
197-
return self.id < other.id
207+
return self.id_ < other.id_
198208
return False
199209

200210
def __gt__(self, other):
201211
if isinstance(other, LabelEntity):
202-
return self.id > other.id
212+
return self.id_ > other.id_
203213
return False
204214

205215
def __hash__(self):

ote_sdk/ote_sdk/entities/label_schema.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,29 @@ def __init__(
5353
group_type: LabelGroupType = LabelGroupType.EXCLUSIVE,
5454
id: ID = None,
5555
):
56-
self.id = ID(ObjectId()) if id is None else id
56+
self.id_ = ID(ObjectId()) if id is None else id
5757

58-
self.labels = sorted(labels, key=lambda x: x.id)
58+
self.labels = sorted(labels, key=lambda x: x.id_)
5959
self.name = name
6060
self.group_type = group_type
6161

62+
@property
63+
def id(self) -> ID:
64+
"""DEPRECATED"""
65+
return self.id_
66+
67+
@id.setter
68+
def id(self, value: ID):
69+
"""DEPRECATED"""
70+
self.id_ = value
71+
6272
@property
6373
def minimum_label_id(self) -> ID:
6474
"""
6575
Returns the minimum (oldest) label ID, which is the first label in self.labels
6676
since this list is sorted
6777
"""
68-
return self.labels[0].id
78+
return self.labels[0].id_
6979

7080
def remove_label(self, label: LabelEntity) -> None:
7181
"""
@@ -87,14 +97,14 @@ def is_single_label(self) -> bool:
8797
def __eq__(self, other: object):
8898
if not isinstance(other, LabelGroup):
8999
return False
90-
return self.id == other.id and (
100+
return self.id_ == other.id_ and (
91101
set(self.labels) == set(other.labels)
92102
and self.group_type == other.group_type
93103
)
94104

95105
def __repr__(self) -> str:
96106
return (
97-
f"LabelGroup(id={self.id}, name={self.name}, group_type={self.group_type},"
107+
f"LabelGroup(id={self.id_}, name={self.name}, group_type={self.group_type},"
98108
f" labels={self.labels})"
99109
)
100110

@@ -316,7 +326,7 @@ def get_labels(self, include_empty) -> List[LabelEntity]:
316326
for label in group.labels
317327
if include_empty or not label.is_empty
318328
}
319-
return sorted(list(labels), key=lambda x: x.id)
329+
return sorted(list(labels), key=lambda x: x.id_)
320330

321331
def get_groups(self, include_empty: bool = False) -> List[LabelGroup]:
322332
"""
@@ -371,7 +381,7 @@ def get_label_ids(self, include_empty) -> List[ID]:
371381
:param include_empty: Include empty label id or not
372382
"""
373383
label_ids = {
374-
label.id
384+
label.id_
375385
for group in self._groups
376386
for label in group.labels
377387
if include_empty or not label.is_empty

ote_sdk/ote_sdk/entities/model.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init__(
135135
if model_adapters is None:
136136
model_adapters = {}
137137

138-
self.__id = _id
138+
self.__id_ = _id
139139
self.__creation_date = creation_date
140140
self.__train_dataset = train_dataset
141141
self.__previous_trained_revision = previous_trained_revision
@@ -161,13 +161,23 @@ def __init__(
161161
self.__model_size_reduction = model_size_reduction
162162

163163
@property
164-
def id(self) -> ID:
164+
def id_(self) -> ID:
165165
"""Gets or sets the id of a Model"""
166-
return self.__id
166+
return self.__id_
167+
168+
@id_.setter
169+
def id_(self, value: ID):
170+
self.__id_ = value
171+
172+
@property
173+
def id(self) -> ID:
174+
"""DEPRECATED"""
175+
return self.__id_
167176

168177
@id.setter
169178
def id(self, value: ID):
170-
self.__id = value
179+
"""DEPRECATED"""
180+
self.__id_ = value
171181

172182
@property
173183
def configuration(self) -> ModelConfiguration:
@@ -458,7 +468,7 @@ def is_optimized(self) -> bool:
458468
def __eq__(self, other):
459469
if isinstance(other, ModelEntity):
460470
return (
461-
self.id == other.id
471+
self.id_ == other.id_
462472
and self.train_dataset == other.train_dataset
463473
and self.performance == other.performance
464474
)

ote_sdk/ote_sdk/entities/resultset.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(
8080
id = ID() if id is None else id
8181
performance = NullPerformance() if performance is None else performance
8282
creation_date = now() if creation_date is None else creation_date
83-
self.__id = id
83+
self.__id_ = id
8484
self.__model = model
8585
self.__prediction_dataset = prediction_dataset
8686
self.__ground_truth_dataset = ground_truth_dataset
@@ -89,13 +89,23 @@ def __init__(
8989
self.__creation_date = creation_date
9090

9191
@property
92-
def id(self) -> ID:
92+
def id_(self) -> ID:
9393
"""Returns the id of the ResultSet"""
94-
return self.__id
94+
return self.__id_
95+
96+
@id_.setter
97+
def id_(self, value: ID) -> None:
98+
self.__id_ = value
99+
100+
@property
101+
def id(self) -> ID:
102+
"""DEPRECATED"""
103+
return self.__id_
95104

96105
@id.setter
97-
def id(self, value: ID) -> None:
98-
self.__id = value
106+
def id(self, value: ID):
107+
"""DEPRECATED"""
108+
self.__id_ = value
99109

100110
@property
101111
def model(self) -> ModelEntity:
@@ -170,5 +180,5 @@ def __repr__(self):
170180
f"purpose={self.purpose}, "
171181
f"performance={self.performance}, "
172182
f"creation_date={self.creation_date}, "
173-
f"id={self.id})"
183+
f"id={self.id_})"
174184
)

ote_sdk/ote_sdk/entities/scored_label.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ def name(self) -> str:
3131
return self.label.name
3232

3333
@property
34-
def id(self) -> ID:
34+
def id_(self) -> ID:
3535
"""
3636
Returns the label id.
3737
"""
38+
return self.label.id_
39+
40+
@property
41+
def id(self) -> ID:
42+
"""DEPRECATED"""
3843
return self.label.id
3944

4045
@property
@@ -80,14 +85,14 @@ def get_label(self) -> LabelEntity:
8085

8186
def __repr__(self):
8287
return (
83-
f"ScoredLabel({self.id}, name={self.name}, probability={self.probability}, "
88+
f"ScoredLabel({self.id_}, name={self.name}, probability={self.probability}, "
8489
f"domain={self.domain}, color={self.color}, hotkey={self.hotkey})"
8590
)
8691

8792
def __eq__(self, other):
8893
if isinstance(other, ScoredLabel):
8994
return (
90-
self.id == other.id
95+
self.id_ == other.id_
9196
and self.name == other.name
9297
and self.color == other.color
9398
and self.hotkey == other.hotkey

0 commit comments

Comments
 (0)