From b42c2b025ec5feda0fbcc016968e08b4dd9adaf5 Mon Sep 17 00:00:00 2001 From: Harmjan Date: Tue, 15 Feb 2022 16:50:24 +0100 Subject: [PATCH 01/11] rename id to id_ --- external/anomaly/ote_anomalib/data/mvtec.py | 4 +- ote_cli/ote_cli/datasets/anomaly/dataset.py | 4 +- ote_cli/ote_cli/registry/registry.py | 2 +- ote_cli/ote_cli/utils/hpo.py | 2 +- .../configuration/configurable_parameters.py | 6 +- .../ote_sdk/configuration/helper/convert.py | 6 +- ote_sdk/ote_sdk/entities/annotation.py | 48 +++++---- ote_sdk/ote_sdk/entities/datasets.py | 4 +- ote_sdk/ote_sdk/entities/label.py | 28 ++--- ote_sdk/ote_sdk/entities/label_schema.py | 20 ++-- ote_sdk/ote_sdk/entities/model.py | 20 ++-- ote_sdk/ote_sdk/entities/resultset.py | 22 ++-- ote_sdk/ote_sdk/entities/scored_label.py | 10 +- ote_sdk/ote_sdk/serialization/label_mapper.py | 18 ++-- ote_sdk/ote_sdk/test_suite/fixtures.py | 10 +- .../test_suite/training_tests_helper.py | 6 +- .../test_configurable_parameters.py | 4 +- .../tests/entities/shapes/test_rectangle.py | 6 +- .../ote_sdk/tests/entities/test_annotation.py | 26 ++--- .../tests/entities/test_dataset_item.py | 46 ++++---- .../ote_sdk/tests/entities/test_datasets.py | 2 +- ote_sdk/ote_sdk/tests/entities/test_label.py | 20 ++-- .../tests/entities/test_label_schema.py | 101 +++++++++--------- ote_sdk/ote_sdk/tests/entities/test_model.py | 4 +- .../tests/entities/test_result_media.py | 12 +-- .../ote_sdk/tests/entities/test_resultset.py | 10 +- .../tests/entities/test_scored_label.py | 6 +- .../tests/entities/test_task_environment.py | 20 ++-- .../tests/serialization/test_id_mapper.py | 10 +- .../tests/serialization/test_label_mapper.py | 30 +++--- ote_sdk/ote_sdk/tests/test_helpers.py | 2 +- .../usecases/evaluation/test_accuracy.py | 6 +- .../tests/usecases/evaluation/test_dice.py | 8 +- .../usecases/evaluation/test_f_measure.py | 34 +++--- ...test_prediction_to_annotation_converter.py | 80 +++++++------- .../exportable_code/test_visualization.py | 8 +- .../tests/utils/test_segmentation_utils.py | 14 +-- .../ote_sdk/tests/utils/test_shape_drawer.py | 34 +++--- .../usecases/exportable_code/demo/demo.py | 2 +- .../prediction_to_annotation_converter.py | 4 +- ote_sdk/ote_sdk/utils/segmentation_utils.py | 2 +- 41 files changed, 355 insertions(+), 346 deletions(-) diff --git a/external/anomaly/ote_anomalib/data/mvtec.py b/external/anomaly/ote_anomalib/data/mvtec.py index 9ffc669700c..40b2b6b2659 100644 --- a/external/anomaly/ote_anomalib/data/mvtec.py +++ b/external/anomaly/ote_anomalib/data/mvtec.py @@ -66,10 +66,10 @@ def __init__( self.create_validation_set = create_validation_set self.normal_label = LabelEntity( - name=LabelNames.normal, domain=Domain.ANOMALY_CLASSIFICATION, id=ID(LabelNames.normal) + name=LabelNames.normal, domain=Domain.ANOMALY_CLASSIFICATION, id_=ID(LabelNames.normal) ) self.abnormal_label = LabelEntity( - name=LabelNames.anomalous, domain=Domain.ANOMALY_CLASSIFICATION, id=ID(LabelNames.anomalous) + name=LabelNames.anomalous, domain=Domain.ANOMALY_CLASSIFICATION, id_=ID(LabelNames.anomalous) ) def get_samples(self) -> DataFrame: diff --git a/ote_cli/ote_cli/datasets/anomaly/dataset.py b/ote_cli/ote_cli/datasets/anomaly/dataset.py index 5dc4800213d..d4c5695d6ab 100644 --- a/ote_cli/ote_cli/datasets/anomaly/dataset.py +++ b/ote_cli/ote_cli/datasets/anomaly/dataset.py @@ -65,10 +65,10 @@ def __init__( items: List[DatasetItemEntity] = [] self.normal_label = LabelEntity( - id=ID(0), name="Normal", domain=Domain.ANOMALY_CLASSIFICATION + id_=ID(0), name="Normal", domain=Domain.ANOMALY_CLASSIFICATION ) self.abnormal_label = LabelEntity( - id=ID(1), name="Anomalous", domain=Domain.ANOMALY_CLASSIFICATION + id_=ID(1), name="Anomalous", domain=Domain.ANOMALY_CLASSIFICATION ) if train_subset is not None: diff --git a/ote_cli/ote_cli/registry/registry.py b/ote_cli/ote_cli/registry/registry.py index 1c7d63813e2..180dc0dd425 100644 --- a/ote_cli/ote_cli/registry/registry.py +++ b/ote_cli/ote_cli/registry/registry.py @@ -95,7 +95,7 @@ def __str__(self): templates_infos = [ { "name": t.name, - "id": t.model_template_id, + "id_": t.model_template_id, "path": t.model_template_path, "task_type": str(t.task_type), } diff --git a/ote_cli/ote_cli/utils/hpo.py b/ote_cli/ote_cli/utils/hpo.py index 91838d8fb48..39dc657a6f8 100644 --- a/ote_cli/ote_cli/utils/hpo.py +++ b/ote_cli/ote_cli/utils/hpo.py @@ -584,7 +584,7 @@ class HpoUnpickler(pickle.Unpickler): "LabelSchemaEntity", "LabelGraph", }, - "ote_sdk.entities.id": { + "ote_sdk.entities.id_": { "ID", }, "ote_sdk.entities.label": { diff --git a/ote_sdk/ote_sdk/configuration/configurable_parameters.py b/ote_sdk/ote_sdk/configuration/configurable_parameters.py index 4faa2c54f43..232472aec18 100644 --- a/ote_sdk/ote_sdk/configuration/configurable_parameters.py +++ b/ote_sdk/ote_sdk/configuration/configurable_parameters.py @@ -17,16 +17,16 @@ class ConfigurableParameters(ParameterGroup): """ Base class representing a generic set of configurable parameters. A - ConfigurableParameters instance is essentially a parameter group with an id + ConfigurableParameters instance is essentially a parameter group with an id_ attached to it, so that it can be uniquely identified in the repositories. - :var id: ID that uniquely identifies the ConfigurableParameters + :var id_: ID that uniquely identifies the ConfigurableParameters :var header: User friendly name for the ConfigurableParameters, that will be displayed in the UI """ - id: ID = attrib(default=ID(), kw_only=True, converter=convert_string_to_id) + id_: ID = attrib(default=ID(), kw_only=True, converter=convert_string_to_id) type: ConfigElementType = attrib( default=ConfigElementType.CONFIGURABLE_PARAMETERS, repr=False, diff --git a/ote_sdk/ote_sdk/configuration/helper/convert.py b/ote_sdk/ote_sdk/configuration/helper/convert.py index 49c313b19ca..29c9d36c103 100644 --- a/ote_sdk/ote_sdk/configuration/helper/convert.py +++ b/ote_sdk/ote_sdk/configuration/helper/convert.py @@ -111,7 +111,7 @@ def convert( :param enum_to_str: Boolean specifying whether to convert enums within the config to their string representation. For conversion to yaml, enums are automatically converted and this option is disregarded. - :param id_to_str: True to convert the id of the configurable parameters to a string + :param id_to_str: True to convert the id_ of the configurable parameters to a string representation, False to leave it as an ID object :param values_only: True to keep only the parameter values, and remove all meta data from the target output @@ -127,8 +127,8 @@ def convert( ) if id_to_str or target == str or target == DictConfig: - config_id = config_dict.get("id", None) - config_dict["id"] = str(config_id) if config_id is not None else None + config_id = config_dict.get("id_", None) + config_dict["id_"] = str(config_id) if config_id is not None else None if target == str: result = yaml.dump(config_dict) diff --git a/ote_sdk/ote_sdk/entities/annotation.py b/ote_sdk/ote_sdk/entities/annotation.py index 5b0027a2ef8..c9525ce2b10 100644 --- a/ote_sdk/ote_sdk/entities/annotation.py +++ b/ote_sdk/ote_sdk/entities/annotation.py @@ -24,9 +24,9 @@ class Annotation(metaclass=abc.ABCMeta): # pylint: disable=redefined-builtin; def __init__( - self, shape: ShapeEntity, labels: List[ScoredLabel], id: Optional[ID] = None + self, shape: ShapeEntity, labels: List[ScoredLabel], id_: Optional[ID] = None ): - self.__id = ID(ObjectId()) if id is None else id + self.__id_ = ID(ObjectId()) if id_ is None else id_ self.__shape = shape self.__labels = labels @@ -35,19 +35,19 @@ def __repr__(self): f"{self.__class__.__name__}(" f"shape={self.shape}, " f"labels={self.get_labels(True)}, " - f"id={self.id})" + f"id_={self.id_})" ) @property - def id(self): + def id_(self): """ - Returns the id for the annotation + Returns the id_ for the annotation """ - return self.__id + return self.__id_ - @id.setter - def id(self, value): - self.__id = value + @id_.setter + def id_(self, value): + self.__id_ = value @property def shape(self): @@ -76,10 +76,12 @@ def get_label_ids(self, include_empty: bool = False) -> Set[ID]: Get a set of ID's of labels that are assigned to this annotation :param include_empty: set to True to include empty label (if exists) in the output. - :return: Set of label id's in annotation + :return: Set of label id_'s in annotation """ return { - label.id for label in self.__labels if include_empty or (not label.is_empty) + label.id_ + for label in self.__labels + if include_empty or (not label.is_empty) } def append_label(self, label: ScoredLabel): @@ -101,7 +103,7 @@ def set_labels(self, labels: List[ScoredLabel]): def __eq__(self, other): if isinstance(other, Annotation): return ( - self.id == other.id + self.id_ == other.id_ and self.get_labels(True) == other.get_labels(True) and self.shape == other.shape ) @@ -147,7 +149,7 @@ class AnnotationSceneEntity(metaclass=abc.ABCMeta): :param kind: Kind of annotation scene `AnnotationSceneKind`. E.g. `AnnotationSceneKind.ANNOTATION`. :param editor: The user that made this annotation scene object :param creation_date: Creation date of annotation scene entity. - :param id: ID of AnnotationSceneEntity. + :param id_: ID of AnnotationSceneEntity. """ # pylint: disable=too-many-arguments, redefined-builtin @@ -157,13 +159,13 @@ def __init__( kind: AnnotationSceneKind, editor: str = "", creation_date: Optional[datetime.datetime] = None, - id: Optional[ID] = None, + id_: Optional[ID] = None, ): self.__annotations = annotations self.__kind = kind self.__editor = editor self.__creation_date = now() if creation_date is None else creation_date - self.__id = ID() if id is None else id + self.__id_ = ID() if id_ is None else id_ def __repr__(self): return ( @@ -172,19 +174,19 @@ def __repr__(self): f"kind={self.kind}, " f"editor={self.editor_name}, " f"creation_date={self.creation_date}, " - f"id={self.id})" + f"id_={self.id_})" ) @property - def id(self): + def id_(self): """ Returns the ID of the AnnotationSceneEntity. """ - return self.__id + return self.__id_ - @id.setter - def id(self, value): - self.__id = value + @id_.setter + def id_(self, value): + self.__id_ = value @property def kind(self): @@ -279,7 +281,7 @@ def get_labels(self, include_empty: bool = False) -> List[LabelEntity]: labels: Dict[str, LabelEntity] = {} for annotation in self.annotations: for label in annotation.get_labels(include_empty): - id_ = label.id + id_ = label.id_ if id_ not in labels: labels[id_] = label.get_label() return list(labels.values()) @@ -304,7 +306,7 @@ class NullAnnotationSceneEntity(AnnotationSceneEntity): def __init__(self) -> None: super().__init__( - id=ID(), + id_=ID(), kind=AnnotationSceneKind.NONE, editor="", creation_date=datetime.datetime.now(), diff --git a/ote_sdk/ote_sdk/entities/datasets.py b/ote_sdk/ote_sdk/entities/datasets.py index 3fa6914f209..edc329e2962 100644 --- a/ote_sdk/ote_sdk/entities/datasets.py +++ b/ote_sdk/ote_sdk/entities/datasets.py @@ -95,7 +95,7 @@ class DatasetEntity: DatasetItemEntity( media=Image(image.jpg, width=640, height=480), annotation_scene=NullAnnotationSceneEntity(), - roi=Annotation(shape=Rectangle(x=0.0, y=0.0, width=1.0, height=1.0), labels=[], id=6149e454893b7ebbe3a8faf6), + roi=Annotation(shape=Rectangle(x=0.0, y=0.0, width=1.0, height=1.0), labels=[], id_=6149e454893b7ebbe3a8faf6), subset=NONE ) @@ -277,7 +277,7 @@ def with_empty_annotations( # reset ROI roi = copy.copy(dataset_item.roi) - roi.id = ID(ObjectId()) + roi.id_ = ID(ObjectId()) roi.set_labels([]) new_dataset_item = DatasetItemEntity( diff --git a/ote_sdk/ote_sdk/entities/label.py b/ote_sdk/ote_sdk/entities/label.py index c7051d80b0d..cc4aa81483f 100644 --- a/ote_sdk/ote_sdk/entities/label.py +++ b/ote_sdk/ote_sdk/entities/label.py @@ -74,7 +74,7 @@ class LabelEntity: :param hotkey: key or combination of keys to select this label in the UI :param creation_date: the date time of the label creation :param is_empty: set to True if the label is an empty label. - :param id: the ID of the label. Set to ID() so that a new unique ID + :param id_: the ID of the label. Set to ID() so that a new unique ID will be assigned upon saving. If the argument is None, it will be set to ID() """ @@ -87,9 +87,9 @@ def __init__( hotkey: str = "", creation_date: Optional[datetime.datetime] = None, is_empty: bool = False, - id: Optional[ID] = None, + id_: Optional[ID] = None, ): - id = ID() if id is None else id + id_ = ID() if id_ is None else id_ color = Color.random() if color is None else color creation_date = now() if creation_date is None else creation_date @@ -99,7 +99,7 @@ def __init__( self._domain = domain self._is_empty = is_empty self._creation_date = creation_date - self._id = id + self.__id_ = id_ @property def name(self): @@ -160,26 +160,26 @@ def creation_date(self) -> datetime.datetime: return self._creation_date @property - def id(self) -> ID: + def id_(self) -> ID: """ - Returns the label id. + Returns the label id_. """ - return self._id + return self.__id_ - @id.setter - def id(self, value: ID): - self._id = value + @id_.setter + def id_(self, value: ID): + self.__id_ = value def __repr__(self): return ( - f"LabelEntity({self.id}, name={self.name}, hotkey={self.hotkey}, " + f"LabelEntity({self.id_}, name={self.name}, hotkey={self.hotkey}, " f"domain={self.domain}, color={self.color})" ) def __eq__(self, other): if isinstance(other, LabelEntity): return ( - self.id == other.id + self.id_ == other.id_ and self.name == other.name and self.color == other.color and self.hotkey == other.hotkey @@ -189,12 +189,12 @@ def __eq__(self, other): def __lt__(self, other): if isinstance(other, LabelEntity): - return self.id < other.id + return self.id_ < other.id_ return False def __gt__(self, other): if isinstance(other, LabelEntity): - return self.id > other.id + return self.id_ > other.id_ return False def __hash__(self): diff --git a/ote_sdk/ote_sdk/entities/label_schema.py b/ote_sdk/ote_sdk/entities/label_schema.py index 68ee3550451..beac819c6b2 100644 --- a/ote_sdk/ote_sdk/entities/label_schema.py +++ b/ote_sdk/ote_sdk/entities/label_schema.py @@ -38,7 +38,7 @@ class LabelGroup: The labels have to be from one task. - :param id: ID of the LabelGroup. If no ID is provided, a new ObjectId() will be + :param id_: ID of the LabelGroup. If no ID is provided, a new ObjectId() will be assigned :param name: Descriptive name of the label group :param labels: Labels that form the group @@ -51,11 +51,11 @@ def __init__( name: str, labels: Sequence[LabelEntity], group_type: LabelGroupType = LabelGroupType.EXCLUSIVE, - id: ID = None, + id_: ID = None, ): - self.id = ID(ObjectId()) if id is None else id + self.id_ = ID(ObjectId()) if id_ is None else id_ - self.labels = sorted(labels, key=lambda x: x.id) + self.labels = sorted(labels, key=lambda x: x.id_) self.name = name self.group_type = group_type @@ -65,7 +65,7 @@ def minimum_label_id(self) -> ID: Returns the minimum (oldest) label ID, which is the first label in self.labels since this list is sorted """ - return self.labels[0].id + return self.labels[0].id_ def remove_label(self, label: LabelEntity) -> None: """ @@ -87,14 +87,14 @@ def is_single_label(self) -> bool: def __eq__(self, other: object): if not isinstance(other, LabelGroup): return False - return self.id == other.id and ( + return self.id_ == other.id_ and ( set(self.labels) == set(other.labels) and self.group_type == other.group_type ) def __repr__(self) -> str: return ( - f"LabelGroup(id={self.id}, name={self.name}, group_type={self.group_type}," + f"LabelGroup(id_={self.id_}, name={self.name}, group_type={self.group_type}," f" labels={self.labels})" ) @@ -316,7 +316,7 @@ def get_labels(self, include_empty) -> List[LabelEntity]: for label in group.labels if include_empty or not label.is_empty } - return sorted(list(labels), key=lambda x: x.id) + return sorted(list(labels), key=lambda x: x.id_) def get_groups(self, include_empty: bool = False) -> List[LabelGroup]: """ @@ -368,10 +368,10 @@ def get_parent(self, label: LabelEntity) -> Optional[LabelEntity]: def get_label_ids(self, include_empty) -> List[ID]: """ Returns a list of label ids that are in the LabelSchema - :param include_empty: Include empty label id or not + :param include_empty: Include empty label id_ or not """ label_ids = { - label.id + label.id_ for group in self._groups for label in group.labels if include_empty or not label.is_empty diff --git a/ote_sdk/ote_sdk/entities/model.py b/ote_sdk/ote_sdk/entities/model.py index ebd0f1a78d5..52d86c4c17f 100644 --- a/ote_sdk/ote_sdk/entities/model.py +++ b/ote_sdk/ote_sdk/entities/model.py @@ -113,9 +113,9 @@ def __init__( optimization_objectives: Dict[str, str] = None, performance_improvement: Dict[str, float] = None, model_size_reduction: float = 0.0, - _id: Optional[ID] = None, + id_: Optional[ID] = None, ): - _id = ID() if _id is None else _id + id_ = ID() if id_ is None else id_ performance = NullPerformance() if performance is None else performance creation_date = now() if creation_date is None else creation_date @@ -135,7 +135,7 @@ def __init__( if model_adapters is None: model_adapters = {} - self.__id = _id + self.__id_ = id_ self.__creation_date = creation_date self.__train_dataset = train_dataset self.__previous_trained_revision = previous_trained_revision @@ -161,13 +161,13 @@ def __init__( self.__model_size_reduction = model_size_reduction @property - def id(self) -> ID: - """Gets or sets the id of a Model""" - return self.__id + def id_(self) -> ID: + """Gets or sets the id_ of a Model""" + return self.__id_ - @id.setter - def id(self, value: ID): - self.__id = value + @id_.setter + def id_(self, value: ID): + self.__id_ = value @property def configuration(self) -> ModelConfiguration: @@ -458,7 +458,7 @@ def is_optimized(self) -> bool: def __eq__(self, other): if isinstance(other, ModelEntity): return ( - self.id == other.id + self.id_ == other.id_ and self.train_dataset == other.train_dataset and self.performance == other.performance ) diff --git a/ote_sdk/ote_sdk/entities/resultset.py b/ote_sdk/ote_sdk/entities/resultset.py index e7bdf4212fd..56c5df044e0 100644 --- a/ote_sdk/ote_sdk/entities/resultset.py +++ b/ote_sdk/ote_sdk/entities/resultset.py @@ -62,7 +62,7 @@ class ResultSetEntity(metaclass=abc.ABCMeta): :param performance: the performance of the model on the ground truth dataset :param creation_date: the date time which the resultset is created. Set to None to set this to datetime.now(datetime.timezone.utc) - :param id: the id of the resultset. Set to ID() so that a new unique ID will be assigned upon saving. + :param id_: the id_ of the resultset. Set to ID() so that a new unique ID will be assigned upon saving. If the argument is None, it will be set to ID() """ @@ -75,12 +75,12 @@ def __init__( purpose: ResultsetPurpose = ResultsetPurpose.EVALUATION, performance: Optional[Performance] = None, creation_date: Optional[datetime.datetime] = None, - id: Optional[ID] = None, + id_: Optional[ID] = None, ): - id = ID() if id is None else id + id_ = ID() if id_ is None else id_ performance = NullPerformance() if performance is None else performance creation_date = now() if creation_date is None else creation_date - self.__id = id + self.__id_ = id_ self.__model = model self.__prediction_dataset = prediction_dataset self.__ground_truth_dataset = ground_truth_dataset @@ -89,13 +89,13 @@ def __init__( self.__creation_date = creation_date @property - def id(self) -> ID: - """Returns the id of the ResultSet""" - return self.__id + def id_(self) -> ID: + """Returns the id_ of the ResultSet""" + return self.__id_ - @id.setter - def id(self, value: ID) -> None: - self.__id = value + @id_.setter + def id_(self, value: ID) -> None: + self.__id_ = value @property def model(self) -> ModelEntity: @@ -170,5 +170,5 @@ def __repr__(self): f"purpose={self.purpose}, " f"performance={self.performance}, " f"creation_date={self.creation_date}, " - f"id={self.id})" + f"id_={self.id_})" ) diff --git a/ote_sdk/ote_sdk/entities/scored_label.py b/ote_sdk/ote_sdk/entities/scored_label.py index d2b5419551b..632573aa624 100644 --- a/ote_sdk/ote_sdk/entities/scored_label.py +++ b/ote_sdk/ote_sdk/entities/scored_label.py @@ -31,11 +31,11 @@ def name(self) -> str: return self.label.name @property - def id(self) -> ID: + def id_(self) -> ID: """ - Returns the label id. + Returns the label id_. """ - return self.label.id + return self.label.id_ @property def color(self) -> Color: @@ -80,14 +80,14 @@ def get_label(self) -> LabelEntity: def __repr__(self): return ( - f"ScoredLabel({self.id}, name={self.name}, probability={self.probability}, " + f"ScoredLabel({self.id_}, name={self.name}, probability={self.probability}, " f"domain={self.domain}, color={self.color}, hotkey={self.hotkey})" ) def __eq__(self, other): if isinstance(other, ScoredLabel): return ( - self.id == other.id + self.id_ == other.id_ and self.name == other.name and self.color == other.color and self.hotkey == other.hotkey diff --git a/ote_sdk/ote_sdk/serialization/label_mapper.py b/ote_sdk/ote_sdk/serialization/label_mapper.py index 8b713adc327..8e1c22f9a7f 100644 --- a/ote_sdk/ote_sdk/serialization/label_mapper.py +++ b/ote_sdk/ote_sdk/serialization/label_mapper.py @@ -60,7 +60,7 @@ def forward( """Serializes to dict.""" return { - "_id": IDMapper().forward(instance.id), + "__id_": IDMapper().forward(instance.id_), "name": instance.name, "color": ColorMapper().forward(instance.color), "hotkey": instance.hotkey, @@ -73,13 +73,13 @@ def forward( def backward(instance: dict) -> LabelEntity: """Deserializes from dict.""" - label_id = IDMapper().backward(instance["_id"]) + label_id = IDMapper().backward(instance["__id_"]) domain = str(instance.get("domain")) label_domain = Domain[domain] label = LabelEntity( - id=label_id, + id_=label_id, name=instance["name"], color=ColorMapper().backward(instance["color"]), hotkey=instance.get("hotkey", ""), @@ -100,9 +100,9 @@ def forward(instance: LabelGroup) -> dict: """Serializes to dict.""" return { - "_id": IDMapper().forward(instance.id), + "__id_": IDMapper().forward(instance.id_), "name": instance.name, - "label_ids": [IDMapper().forward(label.id) for label in instance.labels], + "label_ids": [IDMapper().forward(label.id_) for label in instance.labels], "relation_type": instance.group_type.name, } @@ -111,7 +111,7 @@ def backward(instance: dict, all_labels: Dict[ID, LabelEntity]) -> LabelGroup: """Deserializes from dict.""" return LabelGroup( - id=IDMapper().backward(instance["_id"]), + id_=IDMapper().backward(instance["__id_"]), name=instance["name"], group_type=LabelGroupType[instance["relation_type"]], labels=[ @@ -133,9 +133,9 @@ def forward(instance: Union[LabelGraph, LabelTree]) -> dict: return { "type": instance.type, "directed": instance.directed, - "nodes": [IDMapper().forward(label.id) for label in instance.nodes], + "nodes": [IDMapper().forward(label.id_) for label in instance.nodes], "edges": [ - (IDMapper().forward(edge[0].id), IDMapper().forward(edge[1].id)) + (IDMapper().forward(edge[0].id_), IDMapper().forward(edge[1].id_)) for edge in instance.edges ], } @@ -188,7 +188,7 @@ def forward( "label_tree": LabelGraphMapper().forward(instance.label_tree), "label_groups": label_groups, "all_labels": { - IDMapper().forward(label.id): LabelMapper().forward(label) + IDMapper().forward(label.id_): LabelMapper().forward(label) for label in instance.get_labels(True) }, } diff --git a/ote_sdk/ote_sdk/test_suite/fixtures.py b/ote_sdk/ote_sdk/test_suite/fixtures.py index 484931e46d5..ccde68293a5 100644 --- a/ote_sdk/ote_sdk/test_suite/fixtures.py +++ b/ote_sdk/ote_sdk/test_suite/fixtures.py @@ -183,7 +183,7 @@ def expected_metrics_all_tests_fx(request): """ Return expected metrics for reallife tests read from a YAML file passed as the parameter --expected-metrics-file. Note that the structure of expected metrics should be a dict that maps tests to the expected metric numbers. - The keys of the dict are the parameters' part of the test id-s -- see the function + The keys of the dict are the parameters' part of the test id_-s -- see the function OTETestHelper._generate_test_id, also see the fixture current_test_parameters_string_fx below. The value for each key is a structure that stores a requirement on some metric. @@ -272,8 +272,8 @@ def current_test_parameters_fx(request, force_logging_fx): def current_test_parameters_string_fx(request, force_logging_fx): # pylint: disable=unused-argument """ - This fixture returns the part of the test id between square brackets - (i.e. the part of id that corresponds to the test parameters) + This fixture returns the part of the test id_ between square brackets + (i.e. the part of id_ that corresponds to the test parameters) """ node_name = request.node.name assert "[" in node_name, f"Wrong format of node name {node_name}" @@ -358,13 +358,13 @@ def _get_expected_metrics_callback(): ) if current_test_parameters_string not in expected_metrics_all_tests: raise ValueError( - f"The parameters id string {current_test_parameters_string} is not inside " + f"The parameters id_ string {current_test_parameters_string} is not inside " f"the dict with expected metrics -- cannot make validation, so test is failed" ) expected_metrics = expected_metrics_all_tests[current_test_parameters_string] if not isinstance(expected_metrics, dict): raise ValueError( - f"The expected metric for parameters id string {current_test_parameters_string} " + f"The expected metric for parameters id_ string {current_test_parameters_string} " f"should be a dict, whereas it is: {pformat(expected_metrics)}" ) return expected_metrics diff --git a/ote_sdk/ote_sdk/test_suite/training_tests_helper.py b/ote_sdk/ote_sdk/test_suite/training_tests_helper.py index c2fcc8467ea..41fffaa587d 100644 --- a/ote_sdk/ote_sdk/test_suite/training_tests_helper.py +++ b/ote_sdk/ote_sdk/test_suite/training_tests_helper.py @@ -86,10 +86,10 @@ def test_case_class(self) -> Type[OTETestCaseInterface]: @abstractmethod def short_test_parameters_names_for_generating_id(self) -> OrderedDict: """ - The method returns an OrderedDict that is used for generating string id-s of tests + The method returns an OrderedDict that is used for generating string id_-s of tests by test parameters, received from test bunches dicts: * keys of the OrderedDict should be the string keys of test bunches dict-s that should be - used for generating id-s + used for generating id_-s * values of the OrderedDict should be the strings that will be used as names of test parameters See the function OTETestHelper._generate_test_id below. @@ -272,7 +272,7 @@ def get_list_of_tests(self, usecase: Optional[str] = None): at the moment it is a one-element tuple with the dict `test_parameters` that stores the parameters of the test * ids -- list of strings with ids corresponding the parameters of the tests - each id is a string generated from the corresponding test_parameters + each id_ is a string generated from the corresponding test_parameters value -- see the functions _generate_test_id The lists argvalues and ids will have the same length. diff --git a/ote_sdk/ote_sdk/tests/configuration/test_configurable_parameters.py b/ote_sdk/ote_sdk/tests/configuration/test_configurable_parameters.py index 62dc331b3e9..fb107439e61 100644 --- a/ote_sdk/ote_sdk/tests/configuration/test_configurable_parameters.py +++ b/ote_sdk/ote_sdk/tests/configuration/test_configurable_parameters.py @@ -46,7 +46,7 @@ def check_configurable_parameters_attributes( == ConfigElementType.CONFIGURABLE_PARAMETERS ) assert configurable_parameters.groups == [] - assert configurable_parameters.id == expected_id + assert configurable_parameters.id_ == expected_id assert configurable_parameters.visible_in_ui == expected_visible_in_ui header = "Test Header" @@ -66,7 +66,7 @@ def check_configurable_parameters_attributes( configurable_parameters=ConfigurableParameters( header=header, description=description, - id=config_id, + id_=config_id, visible_in_ui=visible_in_ui, ), expected_header=header, diff --git a/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py b/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py index cbe18e4a0b4..05f05e294b0 100644 --- a/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py +++ b/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py @@ -41,13 +41,13 @@ def rectangle_labels() -> list: name="Rectangle label", domain=Domain.DETECTION, color=Color(red=100, green=50, blue=200), - id=ID("rectangle_label_1"), + id_=ID("rectangle_label_1"), ) other_rectangle_label = LabelEntity( name="Other rectangle label", domain=Domain.SEGMENTATION, color=Color(red=200, green=80, blue=100), - id=ID("rectangle_label_2"), + id_=ID("rectangle_label_2"), ) return [ ScoredLabel(label=rectangle_label), @@ -238,7 +238,7 @@ def test_rectangle_eq(self): assert rectangle != str # Check for unequal labels parameters. Expected that different labels are not affecting equality unequal_label = LabelEntity( - name="Unequal label", domain=Domain.SEGMENTATION, id=ID("unequal_label_1") + name="Unequal label", domain=Domain.SEGMENTATION, id_=ID("unequal_label_1") ) unequal_scored_label = ScoredLabel(label=unequal_label) equal_rectangle._labels.append(unequal_scored_label) diff --git a/ote_sdk/ote_sdk/tests/entities/test_annotation.py b/ote_sdk/ote_sdk/tests/entities/test_annotation.py index 38c0eae60c2..0574e7c523d 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_annotation.py +++ b/ote_sdk/ote_sdk/tests/entities/test_annotation.py @@ -43,14 +43,14 @@ class TestAnnotation: annotation = Annotation(shape=rectangle, labels=labels) car = LabelEntity( - id=ID(123456789), + id_=ID(123456789), name="car", domain=Domain.DETECTION, color=Color(red=16, green=15, blue=56, alpha=255), is_empty=True, ) person = LabelEntity( - id=ID(987654321), + id_=ID(987654321), name="person", domain=Domain.DETECTION, color=Color(red=11, green=18, blue=38, alpha=200), @@ -81,8 +81,8 @@ def test_annotation_default_property(self): annotation = self.annotation - assert type(annotation.id) == ID - assert annotation.id is not None + assert type(annotation.id_) == ID + assert annotation.id_ is not None assert str(annotation.shape) == "Rectangle(x=0.5, y=0.0, width=0.5, height=0.5)" assert annotation.get_labels() == [] @@ -109,9 +109,9 @@ def test_annotation_setters(self): annotation = self.annotation ellipse = Ellipse(x1=0.5, y1=0.1, x2=0.8, y2=0.3) annotation.shape = ellipse - annotation.id = ID(123456789) + annotation.id_ = ID(123456789) - assert annotation.id == ID(123456789) + assert annotation.id_ == ID(123456789) assert annotation.shape == ellipse @pytest.mark.priority_medium @@ -144,7 +144,7 @@ def test_annotation_magic_methods(self): assert ( repr(annotation) - == "Annotation(shape=Ellipse(x1=0.5, y1=0.1, x2=0.8, y2=0.3), labels=[], id=123456789)" + == "Annotation(shape=Ellipse(x1=0.5, y1=0.1, x2=0.8, y2=0.3), labels=[], id_=123456789)" ) assert annotation == other_annotation assert annotation != third_annotation @@ -353,7 +353,7 @@ def test_annotation_scene_entity_default_value(self): annotation_scene_entity = self.annotation_scene_entity - assert annotation_scene_entity.id == ID() + assert annotation_scene_entity.id_ == ID() assert annotation_scene_entity.kind == AnnotationSceneKind.ANNOTATION assert annotation_scene_entity.editor_name == "" assert type(annotation_scene_entity.creation_date) == datetime.datetime @@ -384,13 +384,13 @@ def test_annotation_scene_entity_setters(self): annotation_scene_entity = self.annotation_scene_entity creation_date = self.creation_date - annotation_scene_entity.id = ID(123456789) + annotation_scene_entity.id_ = ID(123456789) annotation_scene_entity.kind = AnnotationSceneKind.PREDICTION annotation_scene_entity.editor_name = "editor" annotation_scene_entity.creation_date = creation_date annotation_scene_entity.annotations = self.annotation - assert annotation_scene_entity.id == ID(123456789) + assert annotation_scene_entity.id_ == ID(123456789) assert annotation_scene_entity.kind == AnnotationSceneKind.PREDICTION assert annotation_scene_entity.editor_name == "editor" assert annotation_scene_entity.creation_date == creation_date @@ -423,7 +423,7 @@ def test_annotation_scene_entity_magic_methods(self): f"kind={annotation_scene_entity.kind}, " f"editor={annotation_scene_entity.editor_name}, " f"creation_date={annotation_scene_entity.creation_date}, " - f"id={annotation_scene_entity.id})" + f"id_={annotation_scene_entity.id_})" ] for i in annotation_scene_entity_repr: @@ -572,7 +572,7 @@ def test_annotation_scene_entity_get_label_ids(self): assert annotation_scene_entity.get_label_ids() == {ID()} - bus = LabelEntity(id=ID(123456789), name="bus", domain=Domain.DETECTION) + bus = LabelEntity(id_=ID(123456789), name="bus", domain=Domain.DETECTION) bus_label = ScoredLabel(bus) labels = [bus_label] annotation = Annotation(shape=self.rectangle, labels=labels) @@ -604,7 +604,7 @@ def test_null_annotation_scene_entity(self): null_annotation = NullAnnotationSceneEntity() - assert null_annotation.id == ID() + assert null_annotation.id_ == ID() assert null_annotation.kind == AnnotationSceneKind.NONE assert null_annotation.editor_name == "" assert type(null_annotation.creation_date) == datetime.datetime diff --git a/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py b/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py index 7bece021844..95c33cec7a1 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py +++ b/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py @@ -47,7 +47,7 @@ def labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(red=100, green=200, blue=150), creation_date=creation_date, - id=ID("detection_label"), + id_=ID("detection_label"), ) segmentation_label = LabelEntity( name="Label for Segmentation", @@ -55,7 +55,7 @@ def labels() -> List[LabelEntity]: color=Color(red=50, green=80, blue=200), creation_date=creation_date, is_empty=True, - id=ID("segmentation_label"), + id_=ID("segmentation_label"), ) return [detection_label, segmentation_label] @@ -66,12 +66,12 @@ def annotations(self) -> List[Annotation]: detection_annotation = Annotation( shape=rectangle, labels=[ScoredLabel(label=labels[0])], - id=ID("detection_annotation_1"), + id_=ID("detection_annotation_1"), ) segmentation_annotation = Annotation( shape=other_rectangle, labels=[ScoredLabel(label=labels[1])], - id=ID("segmentation_annotation_1"), + id_=ID("segmentation_annotation_1"), ) return [detection_annotation, segmentation_annotation] @@ -83,7 +83,7 @@ def roi_labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(red=40, green=180, blue=80), creation_date=creation_date, - id=ID("roi_label_1"), + id_=ID("roi_label_1"), ) other_roi_label = LabelEntity( name="Second ROI label", @@ -91,7 +91,7 @@ def roi_labels() -> List[LabelEntity]: color=Color(red=80, green=90, blue=70), creation_date=creation_date, is_empty=True, - id=ID("roi_label_2"), + id_=ID("roi_label_2"), ) return [roi_label, other_roi_label] @@ -109,7 +109,7 @@ def roi(self): modification_date=datetime.datetime(year=2021, month=12, day=9), ), labels=self.roi_scored_labels(), - id=ID("roi_annotation"), + id_=ID("roi_annotation"), ) return roi @@ -130,7 +130,7 @@ def annotations_entity(self) -> AnnotationSceneEntity: annotations=self.annotations(), kind=AnnotationSceneKind.ANNOTATION, creation_date=datetime.datetime(year=2021, month=12, day=19), - id=ID("annotation_entity_1"), + id_=ID("annotation_entity_1"), ) def default_values_dataset_item(self) -> DatasetItemEntity: @@ -158,9 +158,9 @@ def compare_denormalized_annotations( for index in range(len(expected_annotations)): actual_annotation = actual_annotations[index] expected_annotation = expected_annotations[index] - # Redefining id and modification_date required because of new Annotation objects created after shape + # Redefining id_ and modification_date required because of new Annotation objects created after shape # denormalize - actual_annotation.id = expected_annotation.id + actual_annotation.id_ = expected_annotation.id_ actual_annotation.shape.modification_date = ( expected_annotation.shape.modification_date ) @@ -173,7 +173,7 @@ def labels_to_add() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(red=60, green=120, blue=70), creation_date=datetime.datetime(year=2021, month=12, day=12), - id=ID("label_to_add_1"), + id_=ID("label_to_add_1"), ) other_label_to_add = LabelEntity( name="Other label to add", @@ -181,7 +181,7 @@ def labels_to_add() -> List[LabelEntity]: color=Color(red=80, green=70, blue=100), creation_date=datetime.datetime(year=2021, month=12, day=11), is_empty=True, - id=ID("label_to_add_2"), + id_=ID("label_to_add_2"), ) return [label_to_add, other_label_to_add] @@ -190,12 +190,12 @@ def annotations_to_add(self) -> List[Annotation]: annotation_to_add = Annotation( shape=Rectangle(x1=0.1, y1=0.1, x2=0.7, y2=0.8), labels=[ScoredLabel(label=labels_to_add[0])], - id=ID("added_annotation_1"), + id_=ID("added_annotation_1"), ) other_annotation_to_add = Annotation( shape=Rectangle(x1=0.2, y1=0.3, x2=0.8, y2=0.9), labels=[ScoredLabel(label=labels_to_add[1])], - id=ID("added_annotation_2"), + id_=ID("added_annotation_2"), ) return [annotation_to_add, other_annotation_to_add] @@ -348,7 +348,7 @@ def test_dataset_item_roi(self): # Checking that "roi" property will be equal to full_box for DatasetItemEntity with not specified "roi" but one # of Annotation objects in annotation_scene is equal to full Rectangle full_box_label = LabelEntity( - "Full-box label", Domain.DETECTION, id=ID("full_box_label") + "Full-box label", Domain.DETECTION, id_=ID("full_box_label") ) full_box_annotation = Annotation( Rectangle.generate_full_box(), [ScoredLabel(full_box_label)] @@ -386,7 +386,7 @@ def test_dataset_item_roi_numpy(self): """ media = DatasetItemParameters.generate_random_image() annotation_scene = DatasetItemParameters().annotations_entity() - roi_label = LabelEntity("ROI label", Domain.DETECTION, id=ID("roi_label")) + roi_label = LabelEntity("ROI label", Domain.DETECTION, id_=ID("roi_label")) dataset_item = DatasetItemEntity(media, annotation_scene) # Checking array returned by "roi_numpy" method with non-specified "roi" parameter for DatasetItemEntity # "roi" attribute is "None" @@ -421,7 +421,7 @@ def test_dataset_item_roi_numpy(self): ] ), labels=[], - id=ID("polygon_roi"), + id_=ID("polygon_roi"), ) assert np.array_equal( dataset_item.roi_numpy(polygon_roi), media.numpy[4:8, 5:13] @@ -610,9 +610,9 @@ def test_dataset_item_append_annotations(self): ) ) dataset_item.append_annotations(annotations_to_add) - # Random id is generated for normalized annotations - normalized_annotations[0].id = dataset_item.annotation_scene.annotations[2].id - normalized_annotations[1].id = dataset_item.annotation_scene.annotations[3].id + # Random id_ is generated for normalized annotations + normalized_annotations[0].id_ = dataset_item.annotation_scene.annotations[2].id_ + normalized_annotations[1].id_ = dataset_item.annotation_scene.annotations[3].id_ assert ( dataset_item.annotation_scene.annotations == full_box_annotations + normalized_annotations @@ -622,7 +622,7 @@ def test_dataset_item_append_annotations(self): name="Label for incorrect shape", domain=Domain.CLASSIFICATION, color=Color(red=80, green=70, blue=155), - id=ID("incorrect_shape_label"), + id_=ID("incorrect_shape_label"), ) incorrect_polygon = Polygon( [Point(x=0.01, y=0.1), Point(x=0.35, y=0.1), Point(x=0.35, y=0.1)] @@ -630,7 +630,7 @@ def test_dataset_item_append_annotations(self): incorrect_shape_annotation = Annotation( shape=incorrect_polygon, labels=[ScoredLabel(incorrect_shape_label)], - id=ID("incorrect_shape_annotation"), + id_=ID("incorrect_shape_annotation"), ) dataset_item.append_annotations([incorrect_shape_annotation]) assert ( @@ -884,7 +884,7 @@ def test_dataset_item_deepcopy(self): dataset_item.annotation_scene.editor_name == copy_dataset.annotation_scene.editor_name ) - assert dataset_item.annotation_scene.id == copy_dataset.annotation_scene.id + assert dataset_item.annotation_scene.id_ == copy_dataset.annotation_scene.id_ assert dataset_item.annotation_scene.kind == copy_dataset.annotation_scene.kind assert ( dataset_item.annotation_scene.shapes == copy_dataset.annotation_scene.shapes diff --git a/ote_sdk/ote_sdk/tests/entities/test_datasets.py b/ote_sdk/ote_sdk/tests/entities/test_datasets.py index e4cead21060..c5c0522c2de 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_datasets.py +++ b/ote_sdk/ote_sdk/tests/entities/test_datasets.py @@ -454,7 +454,7 @@ def check_empty_annotations_dataset( assert actual_item.media is expected_item.media assert actual_item.annotation_scene.annotations == [] assert actual_item.annotation_scene.kind == expected_kind - assert actual_item.roi.id != expected_item.roi.id + assert actual_item.roi.id_ != expected_item.roi.id_ assert actual_item.roi.shape is expected_item.roi.shape assert actual_item.roi.get_labels() == [] assert actual_item.subset is expected_item.subset diff --git a/ote_sdk/ote_sdk/tests/entities/test_label.py b/ote_sdk/ote_sdk/tests/entities/test_label.py index fd0d9840303..daf853017ad 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_label.py +++ b/ote_sdk/ote_sdk/tests/entities/test_label.py @@ -51,7 +51,7 @@ class TestLabelEntity: "hotkey": "ctrl+1", "creation_date": creation_date, "is_empty": False, - "id": ID(123456789), + "id_": ID(123456789), } label_person_params = { @@ -61,7 +61,7 @@ class TestLabelEntity: "hotkey": "ctrl+2", "creation_date": creation_date, "is_empty": False, - "id": ID(987654321), + "id_": ID(987654321), } car = LabelEntity(**label_car_params) # type: ignore empty = LabelEntity(name="empty", domain=Domain.SEGMENTATION, is_empty=True) @@ -98,7 +98,7 @@ def test_label_entity(self): "hotkey", "creation_date", "is_empty", - "id", + "id_", ]: assert getattr(self.car, attr) == self.label_car_params[attr] @@ -112,16 +112,16 @@ def test_label_entity(self): setattr(self.car, "domain", label_car_new_domain) setattr(self.car, "color", label_car_new_color) setattr(self.car, "hotkey", label_car_new_hotkey) - setattr(self.car, "id", label_car_new_id) + setattr(self.car, "id_", label_car_new_id) assert self.car.name == label_car_new_name assert self.car.domain == label_car_new_domain assert self.car.color == label_car_new_color assert self.car.hotkey == label_car_new_hotkey - assert self.car.id == label_car_new_id + assert self.car.id_ == label_car_new_id test_label_entity_repr = [ - f"{self.car.id}", + f"{self.car.id_}", f"name={self.car.name}", f"hotkey={self.car.hotkey}", f"domain={self.car.domain}", @@ -155,7 +155,7 @@ def test_empty_label_entity(self): """ assert self.empty.hotkey == "" - assert self.empty.id == ID() + assert self.empty.id_ == ID() assert type(self.empty.color) == Color @pytest.mark.priority_medium @@ -164,7 +164,7 @@ def test_empty_label_entity(self): def test_label_comparison(self): """ Description: - Check the LabelEntity __lt__, __gt__ methods with changed id + Check the LabelEntity __lt__, __gt__ methods with changed id_ Input data: Dummy data @@ -174,9 +174,9 @@ def test_label_comparison(self): Steps 1. Use already created dummy data - 2. Check the processing of changed id + 2. Check the processing of changed id_ """ - self.empty.id = ID(999999999) + self.empty.id_ = ID(999999999) assert self.empty > self.car assert self.car < self.empty diff --git a/ote_sdk/ote_sdk/tests/entities/test_label_schema.py b/ote_sdk/ote_sdk/tests/entities/test_label_schema.py index bcb991ddfb9..d1703041df0 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_label_schema.py +++ b/ote_sdk/ote_sdk/tests/entities/test_label_schema.py @@ -393,37 +393,37 @@ def __init__(self): self.label_0 = LabelEntity( name="Label 0", domain=Domain.CLASSIFICATION, - id=ID("0"), + id_=ID("0"), color=Color(25, 200, 166), ) self.label_0_1 = LabelEntity( name="Label 0_1", domain=Domain.DETECTION, - id=ID("0_1"), + id_=ID("0_1"), color=Color(40, 100, 17), ) self.label_0_2 = LabelEntity( name="Label 0_2", domain=Domain.SEGMENTATION, - id=ID("0_2"), + id_=ID("0_2"), color=Color(30, 80, 40), ) self.label_0_1_3 = LabelEntity( name="Label_0_1_3", domain=Domain.SEGMENTATION, - id=ID("0_1_3"), + id_=ID("0_1_3"), color=Color(40, 100, 17), ) self.label_0_2_4 = LabelEntity( name="Label_0_2_4", domain=Domain.SEGMENTATION, - id=ID("0_2_4"), + id_=ID("0_2_4"), color=Color(30, 80, 40), ) self.label_0_2_5 = LabelEntity( name="Label_0_2_5", domain=Domain.SEGMENTATION, - id=ID("0_2_5"), + id_=ID("0_2_5"), color=Color(30, 80, 40), ) self.no_id_label = LabelEntity(name="No ID Label", domain=Domain.SEGMENTATION) @@ -449,19 +449,20 @@ def test_label_group_initialization(self): LabelGroup object with specified name, labels, group type and ID parameters Expected results: - Test passes if LabelGroup object id, labels, name and group_type attributes return expected values + Test passes if LabelGroup object id_, labels, name and group_type attributes return expected values Steps - 1. Check id, labels, name and group_type attributes of LabelGroup object with not specified group_type parameter - 2. Check id, labels, name and group_type attributes of LabelGroup object with not specified id parameter + 1. Check id_, labels, name and group_type attributes of LabelGroup object with not specified group_type + parameter + 2. Check id_, labels, name and group_type attributes of LabelGroup object with not specified id_ parameter """ - # Checking attributes of LabelGroup object with specified id and not specified group_type parameters + # Checking attributes of LabelGroup object with specified id_ and not specified group_type parameters no_group_type_label_group = LabelGroup( name="Type non-specified specified label group", labels=[labels.label_0_1, labels.no_id_label, labels.label_0], - id=ID("1"), + id_=ID("1"), ) - assert no_group_type_label_group.id == "1" + assert no_group_type_label_group.id_ == "1" # Expected ascending sorting of labels assert no_group_type_label_group.labels == [ labels.no_id_label, @@ -474,15 +475,15 @@ def test_label_group_initialization(self): assert no_group_type_label_group.group_type == LabelGroupType.EXCLUSIVE assert isinstance(no_group_type_label_group.minimum_label_id, ID) assert no_group_type_label_group.minimum_label_id == "" - # Checking attributes of LabelGroup object with specified group_type and not specified id parameters + # Checking attributes of LabelGroup object with specified group_type and not specified id_ parameters no_id_label_group = LabelGroup( name="ID non-specified Label Group", labels=[labels.label_0_1, labels.label_0], group_type=LabelGroupType.EMPTY_LABEL, ) - # Expected randomly generated ID object with 24 characters as "id" attribute - assert isinstance(no_id_label_group.id, ID) - assert len(no_id_label_group.id) == 24 + # Expected randomly generated ID object with 24 characters as "id_" attribute + assert isinstance(no_id_label_group.id_, ID) + assert len(no_id_label_group.id_) == 24 # Expected ascending sorting of labels assert no_id_label_group.labels == [labels.label_0, labels.label_0_1] assert no_id_label_group.name == "ID non-specified Label Group" @@ -542,44 +543,44 @@ def test_label_group_magic_methods(self): group_labels = [labels.label_0, labels.label_0_1] name = "Test Label Group" group_id = ID("1") - label_group = LabelGroup(name=name, labels=group_labels, id=group_id) - equal_label_group = LabelGroup(name=name, labels=group_labels, id=group_id) + label_group = LabelGroup(name=name, labels=group_labels, id_=group_id) + equal_label_group = LabelGroup(name=name, labels=group_labels, id_=group_id) no_id_specified_label_group = LabelGroup(name=name, labels=group_labels) # Checking __eq__ method for equal LabelGroup objects assert label_group == equal_label_group # Checking equality of LabelGroups with different "name" attributes assert label_group == LabelGroup( - name="Different name LabelGroup", labels=group_labels, id=group_id + name="Different name LabelGroup", labels=group_labels, id_=group_id ) - # Checking inequality of LabelGroups with different "id" attributes + # Checking inequality of LabelGroups with different "id_" attributes assert not label_group == no_id_specified_label_group # Checking inequality of LabelGroups with different "labels" attributes assert not label_group == LabelGroup( - name=name, labels=[labels.label_0], id=group_id + name=name, labels=[labels.label_0], id_=group_id ) # Checking inequality of LabelGroups with different "group_type" attributes assert not label_group == LabelGroup( name=name, labels=group_labels, - id=group_id, + id_=group_id, group_type=LabelGroupType.EMPTY_LABEL, ) # Checking inequality of LabelGroups with different object of different type assert not label_group == str - # Checking __repr__ method for LabelGroup object with specified id + # Checking __repr__ method for LabelGroup object with specified id_ assert repr(label_group) == ( - "LabelGroup(id=1, name=Test Label Group, group_type=LabelGroupType.EXCLUSIVE, " + "LabelGroup(id_=1, name=Test Label Group, group_type=LabelGroupType.EXCLUSIVE, " f"labels={group_labels})" ) - # Checking __repr__ method for LabelGroup object with [] labels and not specified id + # Checking __repr__ method for LabelGroup object with [] labels and not specified id_ no_labels_no_id_label_group = LabelGroup( - name="Null labels, random id group", + name="Null labels, random id_ group", labels=[], group_type=LabelGroupType.EMPTY_LABEL, ) - generated_id = no_labels_no_id_label_group.id + generated_id = no_labels_no_id_label_group.id_ assert repr(no_labels_no_id_label_group) == ( - f"LabelGroup(id={generated_id}, name=Null labels, random id group," + f"LabelGroup(id_={generated_id}, name=Null labels, random id_ group," f" group_type=LabelGroupType.EMPTY_LABEL, labels=[])" ) @@ -1295,7 +1296,7 @@ def previous_vertexes(vert_id): returned_vertexes = set() for label in labels_topological_order: - previous, curent = previous_vertexes(label.id) + previous, curent = previous_vertexes(label.id_) for vertex in previous: assert vertex in returned_vertexes returned_vertexes.add(curent) @@ -1309,7 +1310,7 @@ def previous_vertexes(vert_id): labels_topological_order = label_tree.get_labels_in_topological_order() returned_vertexes = set() for label in labels_topological_order: - previous, curent = previous_vertexes(label.id) + previous, curent = previous_vertexes(label.id_) for vertex in previous: if ( curent != "3" @@ -1496,12 +1497,12 @@ def label_groups() -> list: group_1 = LabelGroup( name="Exclusive group 1", labels=[labels.label_0_1, labels.label_0_2], - id=ID("Exclusive group 1"), + id_=ID("Exclusive group 1"), ) group_2 = LabelGroup( name="Exclusive group 2", labels=[labels.label_0_2_4, labels.label_0_2_5], - id=ID("Exclusive group 2"), + id_=ID("Exclusive group 2"), ) return [group_1, group_2] @@ -1512,14 +1513,14 @@ def empty_labels() -> list: domain=Domain.SEGMENTATION, color=Color(255, 255, 255), is_empty=True, - id=ID("empty_label_1"), + id_=ID("empty_label_1"), ) empty_non_exclusive_label = LabelEntity( name="Empty non-exclusive label", domain=Domain.DETECTION, color=Color(255, 255, 255), is_empty=True, - id=ID("empty_non_excl_label_1"), + id_=ID("empty_non_excl_label_1"), ) return [empty_label, empty_non_exclusive_label] @@ -1528,13 +1529,13 @@ def empty_labels_groups(self) -> list: empty_group_1 = LabelGroup( name="Exclusive group with empty label", labels=[empty_labels[0]], - id=ID("Exclusive group with empty label"), + id_=ID("Exclusive group with empty label"), ) empty_group_2 = LabelGroup( name="Empty label group with empty label", labels=[empty_labels[1]], group_type=LabelGroupType.EMPTY_LABEL, - id=ID("Empty label group with empty label"), + id_=ID("Empty label group with empty label"), ) return [empty_group_1, empty_group_2] @@ -1663,15 +1664,15 @@ def test_label_schema_entity_add_group(self): label_schema_entity = self.label_schema_entity() # Scenario for adding exclusive group with new labels new_exclusive_label = LabelEntity( - name="New label", domain=Domain.DETECTION, id=ID("new_ex_1") + name="New label", domain=Domain.DETECTION, id_=ID("new_ex_1") ) other_new_exclusive_label = LabelEntity( - name="Other new label", domain=Domain.DETECTION, id=ID("new_ex_2") + name="Other new label", domain=Domain.DETECTION, id_=ID("new_ex_2") ) new_exclusive_group = LabelGroup( name="New exclusive labels group", labels=[new_exclusive_label, other_new_exclusive_label], - id=ID("new_ex_group"), + id_=ID("new_ex_group"), ) label_schema_entity.add_group(new_exclusive_group) assert label_schema_entity.get_exclusive_groups() == ( @@ -1682,7 +1683,7 @@ def test_label_schema_entity_add_group(self): new_exclusive_group = LabelGroup( name="Exclusive group with one label", labels=[new_exclusive_label], - id=ID("single_excl_group"), + id_=ID("single_excl_group"), ) label_schema_entity.add_group(new_exclusive_group) assert label_schema_entity.get_exclusive_groups() == ( @@ -1693,7 +1694,7 @@ def test_label_schema_entity_add_group(self): new_exclusive_group = LabelGroup( name="Exclusive group to link with existing", labels=[labels.label_0_1, new_exclusive_label], - id=ID("new_ex_group"), + id_=ID("new_ex_group"), ) label_schema_entity.add_group(new_exclusive_group) assert label_schema_entity.get_exclusive_groups() == ( @@ -1705,7 +1706,7 @@ def test_label_schema_entity_add_group(self): name="Non exclusive label group", labels=[new_exclusive_label], group_type=LabelGroupType.EMPTY_LABEL, - id=ID("non_exclusive_group"), + id_=ID("non_exclusive_group"), ) label_schema_entity.add_group(new_exclusive_group) assert label_schema_entity.get_exclusive_groups() == exclusive_groups @@ -1849,10 +1850,12 @@ def test_label_schema_get_exclusive_groups(self): name="New label", domain=Domain.DETECTION, color=Color(100, 16, 25), - id=ID("new_ex_1"), + id_=ID("new_ex_1"), ) new_labels_group = LabelGroup( - name="New exclusive labels group", labels=[new_label], id=ID("new_ex_group") + name="New exclusive labels group", + labels=[new_label], + id_=ID("new_ex_group"), ) label_schema_entity.add_group(new_labels_group) exclusive_groups.append(new_labels_group) @@ -1862,7 +1865,7 @@ def test_label_schema_get_exclusive_groups(self): name="New non-exclusive labels group", labels=[new_label], group_type=LabelGroupType.EMPTY_LABEL, - id=ID("new_ex_group"), + id_=ID("new_ex_group"), ) label_schema_entity.add_group(empty_label_group) assert label_schema_entity.get_exclusive_groups() == exclusive_groups @@ -1894,13 +1897,13 @@ def test_label_schema_add_labels_to_group_by_group_name(self): name="New label", domain=Domain.DETECTION, color=Color(100, 16, 25), - id=ID("new_ex_1"), + id_=ID("new_ex_1"), ) new_empty_label = LabelEntity( name="New empty label", domain=Domain.DETECTION, color=Color(81, 100, 10), - id=ID("new_ex_2"), + id_=ID("new_ex_2"), ) exclusive_group_name = "Exclusive group 1" label_schema_entity.add_labels_to_group_by_group_name( @@ -1914,7 +1917,7 @@ def test_label_schema_add_labels_to_group_by_group_name(self): name="New non-exclusive empty_label", domain=Domain.SEGMENTATION, is_empty=True, - id=ID("empty_label_1"), + id_=ID("empty_label_1"), ) empty_label_group_name = "Empty label group with empty label" label_schema_entity.add_labels_to_group_by_group_name( @@ -2029,7 +2032,7 @@ def test_label_schema_get_label(self): name="Scored label", domain=Domain.DETECTION, color=Color(red=100, green=50, blue=200), - id=ID("scored_label_1"), + id_=ID("scored_label_1"), ) scored_label = ScoredLabel(label=label_to_set_scored) scored_labels_group = LabelGroup( diff --git a/ote_sdk/ote_sdk/tests/entities/test_model.py b/ote_sdk/ote_sdk/tests/entities/test_model.py index e2e00c6d5ff..4287bba9123 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_model.py +++ b/ote_sdk/ote_sdk/tests/entities/test_model.py @@ -204,7 +204,7 @@ def test_model_entity_default_values(self): train_dataset=self.dataset(), configuration=self.configuration() ) - assert model_entity.id == ID() + assert model_entity.id_ == ID() assert type(model_entity.configuration) == ModelConfiguration assert type(model_entity.creation_date) == datetime assert type(model_entity.train_dataset) == DatasetEntity @@ -286,7 +286,7 @@ def __get_path_to_file(filename: str): set_params = { "configuration": environment.get_model_configuration(), "train_dataset": dataset, - "id": ID(1234567890), + "id_": ID(1234567890), "creation_date": self.creation_date, "previous_trained_revision": 5, "previous_revision": 2, diff --git a/ote_sdk/ote_sdk/tests/entities/test_result_media.py b/ote_sdk/ote_sdk/tests/entities/test_result_media.py index 2bddc58ccbf..3022322bfa0 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_result_media.py +++ b/ote_sdk/ote_sdk/tests/entities/test_result_media.py @@ -33,18 +33,18 @@ def default_result_media_parameters() -> dict: domain=Domain.DETECTION, color=Color(100, 200, 60), creation_date=datetime.datetime(year=2021, month=12, day=16), - id=ID("rectangle_label_1"), + id_=ID("rectangle_label_1"), ) rectangle_annotation = Annotation( shape=Rectangle(x1=0.1, y1=0.4, x2=0.4, y2=0.9), labels=[ScoredLabel(rectangle_label)], - id=ID("rectangle_annotation"), + id_=ID("rectangle_annotation"), ) annotation_scene = AnnotationSceneEntity( annotations=[rectangle_annotation], kind=AnnotationSceneKind.ANNOTATION, creation_date=datetime.datetime(year=2021, month=12, day=16), - id=ID("annotation_scene"), + id_=ID("annotation_scene"), ) return { "name": "ResultMedia name", @@ -60,19 +60,19 @@ def optional_result_media_parameters(self) -> dict: Domain.DETECTION, Color(10, 200, 40), creation_date=datetime.datetime(year=2021, month=12, day=18), - id=ID("roi_label_1"), + id_=ID("roi_label_1"), ) roi = Annotation( shape=Rectangle(x1=0.3, y1=0.2, x2=0.7, y2=0.6), labels=[ScoredLabel(roi_label)], - id=ID("roi_annotation"), + id_=ID("roi_annotation"), ) result_media_label = LabelEntity( "ResultMedia label", Domain.CLASSIFICATION, Color(200, 60, 100), creation_date=datetime.datetime(year=2021, month=12, day=20), - id=ID("result_media_1"), + id_=ID("result_media_1"), ) optional_result_media_parameters["roi"] = roi optional_result_media_parameters["label"] = result_media_label diff --git a/ote_sdk/ote_sdk/tests/entities/test_resultset.py b/ote_sdk/ote_sdk/tests/entities/test_resultset.py index 80c0d345d21..fcec35687de 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_resultset.py +++ b/ote_sdk/ote_sdk/tests/entities/test_resultset.py @@ -81,7 +81,7 @@ def test_resultset_entity(self): "purpose": None, "performance": None, "creation_date": None, - "id": None, + "id_": None, } result_set = ResultSetEntity(**test_data) @@ -100,7 +100,7 @@ def test_resultset_entity(self): assert result_set.performance == NullPerformance() assert type(result_set.creation_date) == datetime.datetime - assert result_set.id == ID() + assert result_set.id_ == ID() assert result_set.has_score_metric() is False result_set.performance = "test_performance" @@ -112,8 +112,8 @@ def test_resultset_entity(self): assert result_set.creation_date == creation_date set_attr_id = ID(123456789) - result_set.id = set_attr_id - assert result_set.id == set_attr_id + result_set.id_ = set_attr_id + assert result_set.id_ == set_attr_id test_result_set_repr = [ f"model={result_set.model}", @@ -122,7 +122,7 @@ def test_resultset_entity(self): f"purpose={result_set.purpose}", f"performance={result_set.performance}", f"creation_date={result_set.creation_date}", - f"id={result_set.id}", + f"id_={result_set.id_}", ] for i in test_result_set_repr: diff --git a/ote_sdk/ote_sdk/tests/entities/test_scored_label.py b/ote_sdk/ote_sdk/tests/entities/test_scored_label.py index b57c3990ee2..47bdc6c8916 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_scored_label.py +++ b/ote_sdk/ote_sdk/tests/entities/test_scored_label.py @@ -39,15 +39,15 @@ def test_scored_label(self): Test passes if the results match """ car = LabelEntity( - id=ID(123456789), name="car", domain=Domain.DETECTION, is_empty=False + id_=ID(123456789), name="car", domain=Domain.DETECTION, is_empty=False ) person = LabelEntity( - id=ID(987654321), name="person", domain=Domain.DETECTION, is_empty=False + id_=ID(987654321), name="person", domain=Domain.DETECTION, is_empty=False ) car_label = ScoredLabel(car) person_label = ScoredLabel(person) - for attr in ["id", "name", "color", "hotkey", "creation_date", "is_empty"]: + for attr in ["id_", "name", "color", "hotkey", "creation_date", "is_empty"]: assert getattr(car_label, attr) == getattr(car, attr) assert car_label.get_label() == car diff --git a/ote_sdk/ote_sdk/tests/entities/test_task_environment.py b/ote_sdk/ote_sdk/tests/entities/test_task_environment.py index 27a1b69d76e..ad6fc72ce12 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_task_environment.py +++ b/ote_sdk/ote_sdk/tests/entities/test_task_environment.py @@ -49,10 +49,10 @@ def environment(): Return TaskEnvironment """ car = LabelEntity( - id=ID(123456789), name="car", domain=Domain.DETECTION, is_empty=False + id_=ID(123456789), name="car", domain=Domain.DETECTION, is_empty=False ) person = LabelEntity( - id=ID(987654321), name="person", domain=Domain.DETECTION, is_empty=False + id_=ID(987654321), name="person", domain=Domain.DETECTION, is_empty=False ) labels_list = [car, person] dummy_template = __get_path_to_file("./dummy_template.yaml") @@ -109,15 +109,15 @@ def test_task_environment(self): == __dummy_config[i] ) - assert env.get_model_configuration().configurable_parameters.id == ID() + assert env.get_model_configuration().configurable_parameters.id_ == ID() for param in __dummy_config: getattr(env.get_hyper_parameters(), param) == __dummy_config[param] - assert env.get_hyper_parameters().id == ID() + assert env.get_hyper_parameters().id_ == ID() assert "model=None" in repr(env) - assert "label_schema=LabelSchemaEntity(label_groups=[LabelGroup(id=" in repr( + assert "label_schema=LabelSchemaEntity(label_groups=[LabelGroup(id_=" in repr( env ) assert "name=from_label_list" in repr(env) @@ -138,7 +138,7 @@ def test_task_environment(self): in repr(env) ) assert "visible_in_ui=True" in repr(env) - assert "id=ID()" in repr(env) + assert "id_=ID()" in repr(env) @pytest.mark.priority_medium @pytest.mark.unit @@ -436,16 +436,16 @@ def test_set_hyper_parameters(self): header = "Test header" description = "Test description" visible_in_ui = False - id = ID(123456789) + id_ = ID(123456789) hyper_parameters = ConfigurableParameters( - header=header, description=description, visible_in_ui=visible_in_ui, id=id + header=header, description=description, visible_in_ui=visible_in_ui, id_=id_ ) env.set_hyper_parameters(hyper_parameters=hyper_parameters) assert env.get_hyper_parameters().header == header assert env.get_hyper_parameters().description == description assert env.get_hyper_parameters().visible_in_ui == visible_in_ui - assert env.get_hyper_parameters().id == id + assert env.get_hyper_parameters().id_ == id_ assert env.get_model_configuration().configurable_parameters.header == header assert ( @@ -456,7 +456,7 @@ def test_set_hyper_parameters(self): env.get_model_configuration().configurable_parameters.visible_in_ui == visible_in_ui ) - assert env.get_model_configuration().configurable_parameters.id == id + assert env.get_model_configuration().configurable_parameters.id_ == id_ with pytest.raises(ValueError): # ValueError: Unable to set hyper parameters, invalid input: 123 diff --git a/ote_sdk/ote_sdk/tests/serialization/test_id_mapper.py b/ote_sdk/ote_sdk/tests/serialization/test_id_mapper.py index dbb2c4f1424..a55c943de64 100644 --- a/ote_sdk/ote_sdk/tests/serialization/test_id_mapper.py +++ b/ote_sdk/ote_sdk/tests/serialization/test_id_mapper.py @@ -23,8 +23,8 @@ def test_serialized_representiaton(self): This test serializes ID and checks serialized representation. """ - id = ID("21434231456") - serialized_id = IDMapper.forward(id) + id_ = ID("21434231456") + serialized_id = IDMapper.forward(id_) assert serialized_id == "21434231456" @pytest.mark.priority_medium @@ -35,7 +35,7 @@ def test_serialization_deserialization(self): This test serializes ID, deserializes serialized ID and compare with original. """ - id = ID("21434231456") - serialized_id = IDMapper.forward(id) + id_ = ID("21434231456") + serialized_id = IDMapper.forward(id_) deserialized_id = IDMapper.backward(serialized_id) - assert id == deserialized_id + assert id_ == deserialized_id diff --git a/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py b/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py index a0988674db7..25638eddfe1 100644 --- a/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py +++ b/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py @@ -79,12 +79,12 @@ def test_label_entity_serialization(self): hotkey="ctrl+1", creation_date=cur_date, is_empty=False, - id=ID("0000213"), + id_=ID("0000213"), ) serialized = LabelMapper.forward(label) assert serialized == { - "_id": "0000213", + "__id_": "0000213", "name": "my_label", "color": {"red": red, "green": green, "blue": blue, "alpha": alpha}, "hotkey": "ctrl+1", @@ -124,7 +124,7 @@ def test_flat_label_schema_serialization(self): name=name, domain=Domain.CLASSIFICATION, creation_date=cur_date, - id=ID(i), + id_=ID(i), color=colors[i], ) for i, name in enumerate(names) @@ -136,7 +136,7 @@ def test_flat_label_schema_serialization(self): "label_tree": {"type": "tree", "directed": True, "nodes": [], "edges": []}, "label_groups": [ { - "_id": label_schema.get_groups()[0].id, + "__id_": label_schema.get_groups()[0].id_, "name": "from_label_list", "label_ids": ["0", "1", "2"], "relation_type": "EXCLUSIVE", @@ -144,7 +144,7 @@ def test_flat_label_schema_serialization(self): ], "all_labels": { "0": { - "_id": "0", + "__id_": "0", "name": "cat", "color": ColorMapper.forward(colors[0]), "hotkey": "", @@ -153,7 +153,7 @@ def test_flat_label_schema_serialization(self): "is_empty": False, }, "1": { - "_id": "1", + "__id_": "1", "name": "dog", "color": ColorMapper.forward(colors[1]), "hotkey": "", @@ -162,7 +162,7 @@ def test_flat_label_schema_serialization(self): "is_empty": False, }, "2": { - "_id": "2", + "__id_": "2", "name": "mouse", "color": ColorMapper.forward(colors[2]), "hotkey": "", @@ -198,7 +198,7 @@ def test_label_group_serialization(self): LabelEntity( name=name, domain=Domain.CLASSIFICATION, - id=ID(str(i)), + id_=ID(str(i)), ) for i, name in enumerate(names) ] @@ -207,7 +207,7 @@ def test_label_group_serialization(self): ) serialized = LabelGroupMapper.forward(label_group) assert serialized == { - "_id": label_group.id, + "__id_": label_group.id_, "name": "Test LabelGroup", "label_ids": ["0", "1", "2"], "relation_type": "EMPTY_LABEL", @@ -222,17 +222,17 @@ def test_label_group_serialization(self): @pytest.mark.components(OteSdkComponent.OTE_SDK) class TestLabelGraphMapper: - label_0 = LabelEntity(name="label_0", domain=Domain.SEGMENTATION, id=ID("0")) - label_0_1 = LabelEntity(name="label_0_1", domain=Domain.SEGMENTATION, id=ID("0_1")) - label_0_2 = LabelEntity(name="label_0_2", domain=Domain.SEGMENTATION, id=ID("0_2")) + label_0 = LabelEntity(name="label_0", domain=Domain.SEGMENTATION, id_=ID("0")) + label_0_1 = LabelEntity(name="label_0_1", domain=Domain.SEGMENTATION, id_=ID("0_1")) + label_0_2 = LabelEntity(name="label_0_2", domain=Domain.SEGMENTATION, id_=ID("0_2")) label_0_1_1 = LabelEntity( - name="label_0_1_1", domain=Domain.SEGMENTATION, id=ID("0_1_1") + name="label_0_1_1", domain=Domain.SEGMENTATION, id_=ID("0_1_1") ) label_0_1_2 = LabelEntity( - name="label_0_1_2", domain=Domain.SEGMENTATION, id=ID("0_1_2") + name="label_0_1_2", domain=Domain.SEGMENTATION, id_=ID("0_1_2") ) label_0_2_1 = LabelEntity( - name="label_0_2_1", domain=Domain.SEGMENTATION, id=ID("0_2_1") + name="label_0_2_1", domain=Domain.SEGMENTATION, id_=ID("0_2_1") ) @pytest.mark.priority_medium diff --git a/ote_sdk/ote_sdk/tests/test_helpers.py b/ote_sdk/ote_sdk/tests/test_helpers.py index 707e7fc5755..5a9facc94d9 100644 --- a/ote_sdk/ote_sdk/tests/test_helpers.py +++ b/ote_sdk/ote_sdk/tests/test_helpers.py @@ -66,7 +66,7 @@ def new_label_by_name(self, name: str, is_empty: bool = False) -> LabelEntity: label = LabelEntity( name=name, color=Color.random(), domain=self.label_domain, is_empty=is_empty ) - label.id = generate_unique_id() + label.id_ = generate_unique_id() return label def add_hierarchy( diff --git a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_accuracy.py b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_accuracy.py index bf06acc3908..37bbef9bf02 100644 --- a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_accuracy.py +++ b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_accuracy.py @@ -56,7 +56,7 @@ def car(self) -> LabelEntity: domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("car_label"), + id_=ID("car_label"), ) def human(self) -> LabelEntity: @@ -65,7 +65,7 @@ def human(self) -> LabelEntity: domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("human_label"), + id_=ID("human_label"), ) def dog(self) -> LabelEntity: @@ -74,7 +74,7 @@ def dog(self) -> LabelEntity: domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("dog_label"), + id_=ID("dog_label"), ) def human_1_dataset_item(self) -> DatasetItemEntity: diff --git a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_dice.py b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_dice.py index c9df8a08ebb..d8b216f2cae 100644 --- a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_dice.py +++ b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_dice.py @@ -49,28 +49,28 @@ class TestDice: domain=Domain.DETECTION, color=color, creation_date=creation_date, - id=ID("car_label"), + id_=ID("car_label"), ) human_label = LabelEntity( name="human", domain=Domain.DETECTION, color=color, creation_date=creation_date, - id=ID("human_label"), + id_=ID("human_label"), ) dog_label = LabelEntity( name="dog", domain=Domain.DETECTION, color=color, creation_date=creation_date, - id=ID("dog_label"), + id_=ID("dog_label"), ) cat_label = LabelEntity( name="cat", domain=Domain.DETECTION, color=color, creation_date=creation_date, - id=ID("cat_label"), + id_=ID("cat_label"), ) configurable_params = ConfigurableParameters( header="Test model configurable params" diff --git a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_f_measure.py b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_f_measure.py index 80ee3eca81b..a1725a4961b 100644 --- a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_f_measure.py +++ b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_f_measure.py @@ -1224,7 +1224,7 @@ def model(self): ) model_label_group = LabelGroup( - name="model_labels", labels=self.model_labels(), id=ID("model_label") + name="model_labels", labels=self.model_labels(), id_=ID("model_label") ) model_configuration = ModelConfiguration( @@ -1246,7 +1246,7 @@ def roi(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("image_roi"), + id_=ID("image_roi"), ) ) ], @@ -1262,7 +1262,7 @@ def image_1_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_1_image_1"), + id_=ID("class_1_image_1"), ), probability=0.95, ) @@ -1278,7 +1278,7 @@ def image_1_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_2_image_1"), + id_=ID("class_2_image_1"), ), probability=0.93, ) @@ -1294,7 +1294,7 @@ def image_1_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_2_image_1"), + id_=ID("class_2_image_1"), ), probability=0.91, ) @@ -1323,7 +1323,7 @@ def image_2_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_1_image_2"), + id_=ID("class_1_image_2"), ), probability=0.9, ) @@ -1339,7 +1339,7 @@ def image_2_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_1_image_2"), + id_=ID("class_1_image_2"), ), probability=0.88, ) @@ -1355,7 +1355,7 @@ def image_2_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_3_image_2"), + id_=ID("class_3_image_2"), ), probability=0.94, ) @@ -1371,7 +1371,7 @@ def image_2_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_3_image_2"), + id_=ID("class_3_image_2"), ), probability=0.92, ) @@ -1405,7 +1405,7 @@ def image_1_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_1_image_1"), + id_=ID("class_1_image_1"), ), probability=0.92, ) @@ -1421,7 +1421,7 @@ def image_1_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_1_image_1"), + id_=ID("class_1_image_1"), ), probability=0.93, ) @@ -1437,7 +1437,7 @@ def image_1_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_2_image_1"), + id_=ID("class_2_image_1"), ), probability=0.92, ) @@ -1453,7 +1453,7 @@ def image_1_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_2_image_1"), + id_=ID("class_2_image_1"), ), probability=0.91, ) @@ -1487,7 +1487,7 @@ def image_2_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_1_image_2"), + id_=ID("class_1_image_2"), ), probability=0.89, ) @@ -1503,7 +1503,7 @@ def image_2_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_1_image_2"), + id_=ID("class_1_image_2"), ), probability=0.85, ) @@ -1519,7 +1519,7 @@ def image_2_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_3_image_2"), + id_=ID("class_3_image_2"), ), probability=0.95, ) @@ -1535,7 +1535,7 @@ def image_2_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id=ID("class_3_image_2"), + id_=ID("class_3_image_2"), ), probability=0.94, ) diff --git a/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_prediction_to_annotation_converter.py b/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_prediction_to_annotation_converter.py index fca687932f0..9368438c6c6 100644 --- a/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_prediction_to_annotation_converter.py +++ b/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_prediction_to_annotation_converter.py @@ -232,9 +232,9 @@ def test_create_converter(self): # Checking "DetectionBoxToAnnotationConverter" returned by "create_converter" function when "DETECTION" is # specified as "converter_type" labels = [ - LabelEntity(name="Detection label", domain=Domain.DETECTION, id=ID("1")), + LabelEntity(name="Detection label", domain=Domain.DETECTION, id_=ID("1")), LabelEntity( - name="Other Detection label", domain=Domain.DETECTION, id=ID("2") + name="Other Detection label", domain=Domain.DETECTION, id_=ID("2") ), ] label_group = LabelGroup(name="Detection labels group", labels=labels) @@ -248,12 +248,12 @@ def test_create_converter(self): # specified as "converter_type" labels = [ LabelEntity( - name="Segmentation label", domain=Domain.SEGMENTATION, id=ID("1") + name="Segmentation label", domain=Domain.SEGMENTATION, id_=ID("1") ), LabelEntity( name="Other Segmentation label", domain=Domain.SEGMENTATION, - id=ID("2"), + id_=ID("2"), ), ] label_group = LabelGroup(name="Segmentation labels group", labels=labels) @@ -269,12 +269,12 @@ def test_create_converter(self): LabelEntity( name="Classification label", domain=Domain.CLASSIFICATION, - id=ID("1"), + id_=ID("1"), ), LabelEntity( name="Other Classification label", domain=Domain.CLASSIFICATION, - id=ID("2"), + id_=ID("2"), ), ] label_group = LabelGroup(name="Classification labels group", labels=labels) @@ -288,10 +288,10 @@ def test_create_converter(self): # "ANOMALY_CLASSIFICATION" is specified as "converter_type" labels = [ LabelEntity( - name="Normal", domain=Domain.ANOMALY_CLASSIFICATION, id=ID("1") + name="Normal", domain=Domain.ANOMALY_CLASSIFICATION, id_=ID("1") ), LabelEntity( - name="Anomalous", domain=Domain.ANOMALY_CLASSIFICATION, id=ID("2") + name="Anomalous", domain=Domain.ANOMALY_CLASSIFICATION, id_=ID("2") ), ] label_group = LabelGroup( @@ -329,14 +329,14 @@ class TestDetectionBoxToAnnotation: domain=Domain.DETECTION, color=color, creation_date=creation_date, - id=ID("1"), + id_=ID("1"), ), LabelEntity( name="Other Detection label", domain=Domain.DETECTION, color=color, creation_date=creation_date, - id=ID("2"), + id_=ID("2"), ), ] @@ -373,13 +373,13 @@ def test_detection_box_to_annotation_init(self): name="empty label", domain=Domain.DETECTION, is_empty=True, - id=ID("3"), + id_=ID("3"), ), LabelEntity( name="other empty label", domain=Domain.DETECTION, is_empty=True, - id=ID("4"), + id_=ID("4"), ), ] label_group = LabelGroup(name="Detection labels group", labels=empty_labels) @@ -478,14 +478,14 @@ class TestSegmentationToAnnotation: domain=Domain.SEGMENTATION, color=color, creation_date=creation_date, - id=ID("0"), + id_=ID("0"), ), LabelEntity( name="Other Segmentation label", domain=Domain.SEGMENTATION, color=color, creation_date=creation_date, - id=ID("1"), + id_=ID("1"), ), ] @@ -529,13 +529,13 @@ def test_segmentation_to_annotation_init(self): name="empty label", domain=Domain.SEGMENTATION, is_empty=True, - id=ID("3"), + id_=ID("3"), ), LabelEntity( name="other empty label", domain=Domain.SEGMENTATION, is_empty=True, - id=ID("4"), + id_=ID("4"), ), ] label_group = LabelGroup(name="Segmentation labels group", labels=empty_labels) @@ -691,16 +691,16 @@ def test_classification_to_annotation_init(self): with several labels in each """ label_0 = LabelEntity( - name="label_0", domain=Domain.CLASSIFICATION, id=ID("0") + name="label_0", domain=Domain.CLASSIFICATION, id_=ID("0") ) label_0_1 = LabelEntity( - name="label_0_1", domain=Domain.CLASSIFICATION, id=ID("0_1") + name="label_0_1", domain=Domain.CLASSIFICATION, id_=ID("0_1") ) label_0_2 = LabelEntity( - name="label_0_2", domain=Domain.CLASSIFICATION, id=ID("0_2") + name="label_0_2", domain=Domain.CLASSIFICATION, id_=ID("0_2") ) label_0_1_1 = LabelEntity( - name="label_0_1_1", domain=Domain.CLASSIFICATION, id=ID("0_1_1") + name="label_0_1_1", domain=Domain.CLASSIFICATION, id_=ID("0_1_1") ) non_empty_labels = [label_0, label_0_1, label_0_1_1, label_0_2] @@ -709,7 +709,7 @@ def test_classification_to_annotation_init(self): name="empty label", domain=Domain.CLASSIFICATION, is_empty=True, - id=ID("3"), + id_=ID("3"), ) ] # Checking attributes of "ClassificationToAnnotationConverter" initialized with one label group with @@ -754,9 +754,9 @@ def test_classification_to_annotation_init(self): # Checking attributes of "ClassificationToAnnotationConverter" initialized with two label groups with # several labels in each other_non_empty_labels = [ - LabelEntity(name="label", domain=Domain.CLASSIFICATION, id=ID("3")), + LabelEntity(name="label", domain=Domain.CLASSIFICATION, id_=ID("3")), LabelEntity( - name="other label", domain=Domain.CLASSIFICATION, id=ID("4") + name="other label", domain=Domain.CLASSIFICATION, id_=ID("4") ), ] label_group = LabelGroup( @@ -808,16 +808,16 @@ def check_annotation(actual_annotation: Annotation, expected_labels: list): assert Rectangle.is_full_box(rectangle=actual_annotation.shape) label_0 = LabelEntity( - name="label_0", domain=Domain.CLASSIFICATION, id=ID("0") + name="label_0", domain=Domain.CLASSIFICATION, id_=ID("0") ) label_0_1 = LabelEntity( - name="label_0_1", domain=Domain.CLASSIFICATION, id=ID("0_1") + name="label_0_1", domain=Domain.CLASSIFICATION, id_=ID("0_1") ) label_0_2 = LabelEntity( - name="label_0_2", domain=Domain.CLASSIFICATION, id=ID("0_2") + name="label_0_2", domain=Domain.CLASSIFICATION, id_=ID("0_2") ) label_0_1_1 = LabelEntity( - name="label_0_1_1", domain=Domain.CLASSIFICATION, id=ID("0_1_1") + name="label_0_1_1", domain=Domain.CLASSIFICATION, id_=ID("0_1_1") ) non_empty_labels = [label_0, label_0_1, label_0_1_1, label_0_2] empty_labels = [ @@ -825,7 +825,7 @@ def check_annotation(actual_annotation: Annotation, expected_labels: list): name="empty label", domain=Domain.CLASSIFICATION, is_empty=True, - id=ID("3"), + id_=ID("3"), ) ] # Checking "AnnotationSceneEntity" returned by "convert_to_annotation" for @@ -925,10 +925,14 @@ def test_anomaly_classification_to_annotation_init( # Checking attributes of "AnomalyClassificationToAnnotationConverter" initialized with non-empty labels # list non_empty_labels = [ - LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id=ID("1")), - LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id=ID("2")), - LabelEntity(name="Anomalous", domain=Domain.CLASSIFICATION, id=ID("1")), - LabelEntity(name="Anomalous", domain=Domain.CLASSIFICATION, id=ID("2")), + LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id_=ID("1")), + LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id_=ID("2")), + LabelEntity( + name="Anomalous", domain=Domain.CLASSIFICATION, id_=ID("1") + ), + LabelEntity( + name="Anomalous", domain=Domain.CLASSIFICATION, id_=ID("2") + ), ] label_group = LabelGroup( name="Classification labels group", labels=non_empty_labels @@ -946,25 +950,25 @@ def test_anomaly_classification_to_annotation_init( name="Normal", domain=Domain.CLASSIFICATION, is_empty=True, - id=ID("3"), + id_=ID("3"), ), LabelEntity( name="Normal", domain=Domain.CLASSIFICATION, is_empty=True, - id=ID("4"), + id_=ID("4"), ), LabelEntity( name="Anomalous", domain=Domain.CLASSIFICATION, is_empty=True, - id=ID("3"), + id_=ID("3"), ), LabelEntity( name="Anomalous", domain=Domain.CLASSIFICATION, is_empty=True, - id=ID("4"), + id_=ID("4"), ), ] label_group = LabelGroup( @@ -1009,8 +1013,8 @@ def check_annotation(actual_annotation: Annotation, expected_labels: list): assert Rectangle.is_full_box(rectangle=actual_annotation.shape) non_empty_labels = [ - LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id=ID("1")), - LabelEntity(name="Anomalous", domain=Domain.CLASSIFICATION, id=ID("2")), + LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id_=ID("1")), + LabelEntity(name="Anomalous", domain=Domain.CLASSIFICATION, id_=ID("2")), ] label_group = LabelGroup( name="Anomaly classification labels group", labels=non_empty_labels diff --git a/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_visualization.py b/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_visualization.py index 4841a63f429..456407a4874 100644 --- a/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_visualization.py +++ b/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_visualization.py @@ -39,14 +39,14 @@ def annotation_scene() -> AnnotationSceneEntity: domain=Domain.DETECTION, color=annotation_color, creation_date=creation_date, - id=ID("detection_1"), + id_=ID("detection_1"), ) segmentation_label = LabelEntity( name="segmentation label", domain=Domain.SEGMENTATION, color=annotation_color, creation_date=creation_date, - id=ID("segmentation_1"), + id_=ID("segmentation_1"), ) annotation = Annotation( shape=Rectangle(x1=0.1, y1=0.1, x2=0.4, y2=0.5), @@ -61,14 +61,14 @@ def annotation_scene() -> AnnotationSceneEntity: domain=Domain.CLASSIFICATION, color=other_annotation_color, creation_date=creation_date, - id=ID("classification_1"), + id_=ID("classification_1"), ) anomaly_segmentation_label = LabelEntity( name="anomaly_segmentation label", domain=Domain.ANOMALY_SEGMENTATION, color=other_annotation_color, creation_date=creation_date, - id=ID("anomaly_segmentation_1"), + id_=ID("anomaly_segmentation_1"), ) other_annotation = Annotation( shape=Ellipse(x1=0.6, y1=0.4, x2=0.7, y2=0.9), diff --git a/ote_sdk/ote_sdk/tests/utils/test_segmentation_utils.py b/ote_sdk/ote_sdk/tests/utils/test_segmentation_utils.py index 97485687a5d..8e9faab4cb0 100644 --- a/ote_sdk/ote_sdk/tests/utils/test_segmentation_utils.py +++ b/ote_sdk/ote_sdk/tests/utils/test_segmentation_utils.py @@ -38,19 +38,19 @@ def rectangle_label(): return LabelEntity( name="Rectangle label", domain=Domain.SEGMENTATION, - id=ID("1_rectangle_label"), + id_=ID("1_rectangle_label"), ) @staticmethod def ellipse_label(): return LabelEntity( - name="Ellipse label", domain=Domain.SEGMENTATION, id=ID("3_ellipse_label") + name="Ellipse label", domain=Domain.SEGMENTATION, id_=ID("3_ellipse_label") ) @staticmethod def polygon_label(): return LabelEntity( - name="Polygon label", domain=Domain.SEGMENTATION, id=ID("6_polygon_label") + name="Polygon label", domain=Domain.SEGMENTATION, id_=ID("6_polygon_label") ) @pytest.mark.priority_medium @@ -74,24 +74,24 @@ def test_mask_from_annotation(self): name="Empty Rectangle label", domain=Domain.SEGMENTATION, is_empty=True, - id=ID("2_empty_rectangle_label"), + id_=ID("2_empty_rectangle_label"), ) empty_ellipse_label = LabelEntity( name="Empty Ellipse label", domain=Domain.SEGMENTATION, is_empty=True, - id=ID("5_empty_ellipse_label"), + id_=ID("5_empty_ellipse_label"), ) empty_polygon_label = LabelEntity( name="Empty Polygon label", domain=Domain.SEGMENTATION, is_empty=True, - id=ID("7_empty_polygon_label"), + id_=ID("7_empty_polygon_label"), ) non_annotation_label = LabelEntity( name="Non-annotation label", domain=Domain.SEGMENTATION, - id=ID("4_empty_annotation_label"), + id_=ID("4_empty_annotation_label"), ) rectangle_annotation = Annotation( shape=Rectangle(x1=0.5, y1=0.7, x2=0.9, y2=0.9), diff --git a/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py b/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py index 495ade86f6b..1b8a55bd3aa 100644 --- a/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py +++ b/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py @@ -40,7 +40,7 @@ def labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(red=100, green=200, blue=150), creation_date=creation_date, - id=ID("detection_label"), + id_=ID("detection_label"), ) segmentation_label = LabelEntity( name="Label for Segmentation", @@ -48,7 +48,7 @@ def labels() -> List[LabelEntity]: color=Color(red=50, green=80, blue=200), creation_date=creation_date, is_empty=True, - id=ID("segmentation_label"), + id_=ID("segmentation_label"), ) return [detection_label, segmentation_label] @@ -60,7 +60,7 @@ def scored_labels() -> List[ScoredLabel]: domain=Domain.CLASSIFICATION, color=Color(red=200, green=170, blue=90), creation_date=creation_date, - id=ID("classification_label"), + id_=ID("classification_label"), ) anomaly_detection_label = LabelEntity( name="Label for Anomaly Detection", @@ -68,7 +68,7 @@ def scored_labels() -> List[ScoredLabel]: color=Color(red=100, green=200, blue=190), creation_date=creation_date, is_empty=True, - id=ID("anomaly_detection_label"), + id_=ID("anomaly_detection_label"), ) return [ScoredLabel(classification_label), ScoredLabel(anomaly_detection_label)] @@ -581,14 +581,14 @@ def full_rectangle_labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(100, 200, 60), creation_date=datetime.datetime(year=2021, month=12, day=16), - id=ID("full_rectangle_label_1"), + id_=ID("full_rectangle_label_1"), ) other_rectangle_label = LabelEntity( name="other Full-Rectangle Annotation Label", domain=Domain.SEGMENTATION, color=Color(80, 160, 200), creation_date=datetime.datetime(year=2021, month=12, day=15), - id=ID("full_rectangle_label_2"), + id_=ID("full_rectangle_label_2"), ) return [rectangle_label, other_rectangle_label] @@ -600,7 +600,7 @@ def full_rectangle_annotation(self) -> Annotation: return Annotation( shape=Rectangle(x1=0, y1=0, x2=1, y2=1), labels=self.full_rectangle_scored_labels(), - id=ID("full_rectangle_annotation"), + id_=ID("full_rectangle_annotation"), ) @staticmethod @@ -610,14 +610,14 @@ def rectangle_labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(100, 200, 60), creation_date=datetime.datetime(year=2021, month=12, day=16), - id=ID("rectangle_label_1"), + id_=ID("rectangle_label_1"), ) other_rectangle_label = LabelEntity( name="other Rectangle Annotation Label", domain=Domain.SEGMENTATION, color=Color(80, 160, 200), creation_date=datetime.datetime(year=2021, month=12, day=15), - id=ID("rectangle_label_2"), + id_=ID("rectangle_label_2"), ) return [rectangle_label, other_rectangle_label] @@ -629,7 +629,7 @@ def rectangle_annotation(self) -> Annotation: return Annotation( shape=Rectangle(x1=0.1, y1=0.4, x2=0.4, y2=0.9), labels=self.rectangle_scored_labels(), - id=ID("rectangle_annotation"), + id_=ID("rectangle_annotation"), ) @staticmethod @@ -639,14 +639,14 @@ def polygon_labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(200, 200, 100), creation_date=datetime.datetime(year=2021, month=12, day=16), - id=ID("polygon_label_1"), + id_=ID("polygon_label_1"), ) other_polygon_label = LabelEntity( name="other Polygon Annotation Label", domain=Domain.SEGMENTATION, color=Color(100, 100, 150), creation_date=datetime.datetime(year=2021, month=12, day=15), - id=ID("polygon_label_2"), + id_=ID("polygon_label_2"), ) return [polygon_label, other_polygon_label] @@ -666,7 +666,7 @@ def polygon_annotation(self) -> Annotation: ] ), labels=self.polygon_scored_labels(), - id=ID("polygon_annotation"), + id_=ID("polygon_annotation"), ) @staticmethod @@ -676,14 +676,14 @@ def ellipse_labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(100, 100, 200), creation_date=datetime.datetime(year=2021, month=12, day=16), - id=ID("ellipse_label_1"), + id_=ID("ellipse_label_1"), ) other_ellipse_label = LabelEntity( name="other Ellipse Annotation Label", domain=Domain.SEGMENTATION, color=Color(200, 80, 150), creation_date=datetime.datetime(year=2021, month=12, day=15), - id=ID("ellipse_label_2"), + id_=ID("ellipse_label_2"), ) return [ellipse_label, other_ellipse_label] @@ -695,7 +695,7 @@ def ellipse_annotation(self) -> Annotation: return Annotation( shape=Ellipse(x1=0.5, y1=0.0, x2=1.0, y2=0.5), labels=self.ellipse_scored_labels(), - id=ID("ellipse_annotation"), + id_=ID("ellipse_annotation"), ) def annotation_scene(self) -> AnnotationSceneEntity: @@ -708,7 +708,7 @@ def annotation_scene(self) -> AnnotationSceneEntity: ], kind=AnnotationSceneKind.ANNOTATION, creation_date=datetime.datetime(year=2021, month=12, day=16), - id=ID("annotation_scene"), + id_=ID("annotation_scene"), ) diff --git a/ote_sdk/ote_sdk/usecases/exportable_code/demo/demo.py b/ote_sdk/ote_sdk/usecases/exportable_code/demo/demo.py index 43eef700182..22571b44f1b 100644 --- a/ote_sdk/ote_sdk/usecases/exportable_code/demo/demo.py +++ b/ote_sdk/ote_sdk/usecases/exportable_code/demo/demo.py @@ -34,7 +34,7 @@ def build_argparser(): "--input", required=True, help="Required. An input to process. The input must be a single image, " - "a folder of images, video file or camera id.", + "a folder of images, video file or camera id_.", ) args.add_argument( "-m", diff --git a/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py b/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py index 08b67172898..6c26b2b82a2 100644 --- a/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py +++ b/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py @@ -84,7 +84,7 @@ def convert_to_annotation( annotations = self.__convert_to_annotations(predictions) # media_identifier = ImageIdentifier(image_id=ID()) annotation_scene = AnnotationSceneEntity( - id=ID(), + id_=ID(), kind=AnnotationSceneKind.PREDICTION, editor="ote", creation_date=now(), @@ -175,7 +175,7 @@ def convert_to_annotation( annotations = [] image_size = metadata["original_shape"][1::-1] for box in predictions: - scored_label = ScoredLabel(self.labels[int(box.id)], float(box.score)) + scored_label = ScoredLabel(self.labels[int(box.id_)], float(box.score)) coords = np.array(box.get_coords(), dtype=float) / np.tile(image_size, 2) annotations.append( Annotation( diff --git a/ote_sdk/ote_sdk/utils/segmentation_utils.py b/ote_sdk/ote_sdk/utils/segmentation_utils.py index 48faa7acbc1..cb04649cf6f 100644 --- a/ote_sdk/ote_sdk/utils/segmentation_utils.py +++ b/ote_sdk/ote_sdk/utils/segmentation_utils.py @@ -256,7 +256,7 @@ def create_annotation_from_segmentation_map( Annotation( shape=polygon, labels=[ScoredLabel(label, probability)], - id=ID(ObjectId()), + id_=ID(ObjectId()), ) ) else: From dd1f48c3423f5175b1de103ee8d3232e13cb471f Mon Sep 17 00:00:00 2001 From: Harmjan Date: Wed, 16 Feb 2022 10:23:53 +0100 Subject: [PATCH 02/11] minor fixes --- .../ote_sdk/configuration/configurable_parameters.py | 2 +- ote_sdk/ote_sdk/configuration/helper/convert.py | 2 +- ote_sdk/ote_sdk/entities/annotation.py | 4 ++-- ote_sdk/ote_sdk/entities/resultset.py | 2 +- ote_sdk/ote_sdk/test_suite/fixtures.py | 10 +++++----- ote_sdk/ote_sdk/test_suite/training_tests_helper.py | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ote_sdk/ote_sdk/configuration/configurable_parameters.py b/ote_sdk/ote_sdk/configuration/configurable_parameters.py index 232472aec18..dc641e12823 100644 --- a/ote_sdk/ote_sdk/configuration/configurable_parameters.py +++ b/ote_sdk/ote_sdk/configuration/configurable_parameters.py @@ -17,7 +17,7 @@ class ConfigurableParameters(ParameterGroup): """ Base class representing a generic set of configurable parameters. A - ConfigurableParameters instance is essentially a parameter group with an id_ + ConfigurableParameters instance is essentially a parameter group with an id attached to it, so that it can be uniquely identified in the repositories. :var id_: ID that uniquely identifies the ConfigurableParameters diff --git a/ote_sdk/ote_sdk/configuration/helper/convert.py b/ote_sdk/ote_sdk/configuration/helper/convert.py index 29c9d36c103..7cd37c757df 100644 --- a/ote_sdk/ote_sdk/configuration/helper/convert.py +++ b/ote_sdk/ote_sdk/configuration/helper/convert.py @@ -111,7 +111,7 @@ def convert( :param enum_to_str: Boolean specifying whether to convert enums within the config to their string representation. For conversion to yaml, enums are automatically converted and this option is disregarded. - :param id_to_str: True to convert the id_ of the configurable parameters to a string + :param id_to_str: True to convert the id of the configurable parameters to a string representation, False to leave it as an ID object :param values_only: True to keep only the parameter values, and remove all meta data from the target output diff --git a/ote_sdk/ote_sdk/entities/annotation.py b/ote_sdk/ote_sdk/entities/annotation.py index c9525ce2b10..9fdf1119337 100644 --- a/ote_sdk/ote_sdk/entities/annotation.py +++ b/ote_sdk/ote_sdk/entities/annotation.py @@ -41,7 +41,7 @@ def __repr__(self): @property def id_(self): """ - Returns the id_ for the annotation + Returns the id for the annotation """ return self.__id_ @@ -76,7 +76,7 @@ def get_label_ids(self, include_empty: bool = False) -> Set[ID]: Get a set of ID's of labels that are assigned to this annotation :param include_empty: set to True to include empty label (if exists) in the output. - :return: Set of label id_'s in annotation + :return: Set of label id's in annotation """ return { label.id_ diff --git a/ote_sdk/ote_sdk/entities/resultset.py b/ote_sdk/ote_sdk/entities/resultset.py index 56c5df044e0..3180849d496 100644 --- a/ote_sdk/ote_sdk/entities/resultset.py +++ b/ote_sdk/ote_sdk/entities/resultset.py @@ -90,7 +90,7 @@ def __init__( @property def id_(self) -> ID: - """Returns the id_ of the ResultSet""" + """Returns the id of the ResultSet""" return self.__id_ @id_.setter diff --git a/ote_sdk/ote_sdk/test_suite/fixtures.py b/ote_sdk/ote_sdk/test_suite/fixtures.py index ccde68293a5..484931e46d5 100644 --- a/ote_sdk/ote_sdk/test_suite/fixtures.py +++ b/ote_sdk/ote_sdk/test_suite/fixtures.py @@ -183,7 +183,7 @@ def expected_metrics_all_tests_fx(request): """ Return expected metrics for reallife tests read from a YAML file passed as the parameter --expected-metrics-file. Note that the structure of expected metrics should be a dict that maps tests to the expected metric numbers. - The keys of the dict are the parameters' part of the test id_-s -- see the function + The keys of the dict are the parameters' part of the test id-s -- see the function OTETestHelper._generate_test_id, also see the fixture current_test_parameters_string_fx below. The value for each key is a structure that stores a requirement on some metric. @@ -272,8 +272,8 @@ def current_test_parameters_fx(request, force_logging_fx): def current_test_parameters_string_fx(request, force_logging_fx): # pylint: disable=unused-argument """ - This fixture returns the part of the test id_ between square brackets - (i.e. the part of id_ that corresponds to the test parameters) + This fixture returns the part of the test id between square brackets + (i.e. the part of id that corresponds to the test parameters) """ node_name = request.node.name assert "[" in node_name, f"Wrong format of node name {node_name}" @@ -358,13 +358,13 @@ def _get_expected_metrics_callback(): ) if current_test_parameters_string not in expected_metrics_all_tests: raise ValueError( - f"The parameters id_ string {current_test_parameters_string} is not inside " + f"The parameters id string {current_test_parameters_string} is not inside " f"the dict with expected metrics -- cannot make validation, so test is failed" ) expected_metrics = expected_metrics_all_tests[current_test_parameters_string] if not isinstance(expected_metrics, dict): raise ValueError( - f"The expected metric for parameters id_ string {current_test_parameters_string} " + f"The expected metric for parameters id string {current_test_parameters_string} " f"should be a dict, whereas it is: {pformat(expected_metrics)}" ) return expected_metrics diff --git a/ote_sdk/ote_sdk/test_suite/training_tests_helper.py b/ote_sdk/ote_sdk/test_suite/training_tests_helper.py index 41fffaa587d..c2fcc8467ea 100644 --- a/ote_sdk/ote_sdk/test_suite/training_tests_helper.py +++ b/ote_sdk/ote_sdk/test_suite/training_tests_helper.py @@ -86,10 +86,10 @@ def test_case_class(self) -> Type[OTETestCaseInterface]: @abstractmethod def short_test_parameters_names_for_generating_id(self) -> OrderedDict: """ - The method returns an OrderedDict that is used for generating string id_-s of tests + The method returns an OrderedDict that is used for generating string id-s of tests by test parameters, received from test bunches dicts: * keys of the OrderedDict should be the string keys of test bunches dict-s that should be - used for generating id_-s + used for generating id-s * values of the OrderedDict should be the strings that will be used as names of test parameters See the function OTETestHelper._generate_test_id below. @@ -272,7 +272,7 @@ def get_list_of_tests(self, usecase: Optional[str] = None): at the moment it is a one-element tuple with the dict `test_parameters` that stores the parameters of the test * ids -- list of strings with ids corresponding the parameters of the tests - each id_ is a string generated from the corresponding test_parameters + each id is a string generated from the corresponding test_parameters value -- see the functions _generate_test_id The lists argvalues and ids will have the same length. From 5a04ef4a5ed1b1cadd544f241a1a985a7293565b Mon Sep 17 00:00:00 2001 From: Harmjan Date: Wed, 16 Feb 2022 10:29:19 +0100 Subject: [PATCH 03/11] minor fixes --- ote_cli/ote_cli/registry/registry.py | 2 +- ote_cli/ote_cli/utils/hpo.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ote_cli/ote_cli/registry/registry.py b/ote_cli/ote_cli/registry/registry.py index 180dc0dd425..1c7d63813e2 100644 --- a/ote_cli/ote_cli/registry/registry.py +++ b/ote_cli/ote_cli/registry/registry.py @@ -95,7 +95,7 @@ def __str__(self): templates_infos = [ { "name": t.name, - "id_": t.model_template_id, + "id": t.model_template_id, "path": t.model_template_path, "task_type": str(t.task_type), } diff --git a/ote_cli/ote_cli/utils/hpo.py b/ote_cli/ote_cli/utils/hpo.py index 39dc657a6f8..91838d8fb48 100644 --- a/ote_cli/ote_cli/utils/hpo.py +++ b/ote_cli/ote_cli/utils/hpo.py @@ -584,7 +584,7 @@ class HpoUnpickler(pickle.Unpickler): "LabelSchemaEntity", "LabelGraph", }, - "ote_sdk.entities.id_": { + "ote_sdk.entities.id": { "ID", }, "ote_sdk.entities.label": { From a708a1678bd80df18b1a1a9142163a6dc7519160 Mon Sep 17 00:00:00 2001 From: Harmjan Date: Wed, 16 Feb 2022 12:36:08 +0100 Subject: [PATCH 04/11] no longer refactor init functions --- external/anomaly/ote_anomalib/data/mvtec.py | 4 +- ote_cli/ote_cli/datasets/anomaly/dataset.py | 4 +- .../configuration/configurable_parameters.py | 2 +- .../ote_sdk/configuration/helper/convert.py | 4 +- ote_sdk/ote_sdk/entities/annotation.py | 16 ++-- ote_sdk/ote_sdk/entities/datasets.py | 2 +- ote_sdk/ote_sdk/entities/label.py | 10 +-- ote_sdk/ote_sdk/entities/label_schema.py | 10 +-- ote_sdk/ote_sdk/entities/model.py | 8 +- ote_sdk/ote_sdk/entities/resultset.py | 10 +-- ote_sdk/ote_sdk/entities/scored_label.py | 2 +- ote_sdk/ote_sdk/serialization/label_mapper.py | 4 +- .../tests/entities/shapes/test_rectangle.py | 6 +- .../ote_sdk/tests/entities/test_annotation.py | 10 +-- .../tests/entities/test_dataset_item.py | 38 ++++---- ote_sdk/ote_sdk/tests/entities/test_label.py | 12 +-- .../tests/entities/test_label_schema.py | 86 +++++++++---------- ote_sdk/ote_sdk/tests/entities/test_model.py | 2 +- .../tests/entities/test_result_media.py | 12 +-- .../ote_sdk/tests/entities/test_resultset.py | 4 +- .../tests/entities/test_scored_label.py | 6 +- .../tests/entities/test_task_environment.py | 8 +- .../tests/serialization/test_label_mapper.py | 18 ++-- .../usecases/evaluation/test_accuracy.py | 6 +- .../tests/usecases/evaluation/test_dice.py | 8 +- .../usecases/evaluation/test_f_measure.py | 34 ++++---- ...test_prediction_to_annotation_converter.py | 80 ++++++++--------- .../exportable_code/test_visualization.py | 8 +- .../tests/utils/test_segmentation_utils.py | 14 +-- .../ote_sdk/tests/utils/test_shape_drawer.py | 34 ++++---- .../usecases/exportable_code/demo/demo.py | 2 +- .../prediction_to_annotation_converter.py | 2 +- ote_sdk/ote_sdk/utils/segmentation_utils.py | 2 +- 33 files changed, 232 insertions(+), 236 deletions(-) diff --git a/external/anomaly/ote_anomalib/data/mvtec.py b/external/anomaly/ote_anomalib/data/mvtec.py index 40b2b6b2659..9ffc669700c 100644 --- a/external/anomaly/ote_anomalib/data/mvtec.py +++ b/external/anomaly/ote_anomalib/data/mvtec.py @@ -66,10 +66,10 @@ def __init__( self.create_validation_set = create_validation_set self.normal_label = LabelEntity( - name=LabelNames.normal, domain=Domain.ANOMALY_CLASSIFICATION, id_=ID(LabelNames.normal) + name=LabelNames.normal, domain=Domain.ANOMALY_CLASSIFICATION, id=ID(LabelNames.normal) ) self.abnormal_label = LabelEntity( - name=LabelNames.anomalous, domain=Domain.ANOMALY_CLASSIFICATION, id_=ID(LabelNames.anomalous) + name=LabelNames.anomalous, domain=Domain.ANOMALY_CLASSIFICATION, id=ID(LabelNames.anomalous) ) def get_samples(self) -> DataFrame: diff --git a/ote_cli/ote_cli/datasets/anomaly/dataset.py b/ote_cli/ote_cli/datasets/anomaly/dataset.py index d4c5695d6ab..5dc4800213d 100644 --- a/ote_cli/ote_cli/datasets/anomaly/dataset.py +++ b/ote_cli/ote_cli/datasets/anomaly/dataset.py @@ -65,10 +65,10 @@ def __init__( items: List[DatasetItemEntity] = [] self.normal_label = LabelEntity( - id_=ID(0), name="Normal", domain=Domain.ANOMALY_CLASSIFICATION + id=ID(0), name="Normal", domain=Domain.ANOMALY_CLASSIFICATION ) self.abnormal_label = LabelEntity( - id_=ID(1), name="Anomalous", domain=Domain.ANOMALY_CLASSIFICATION + id=ID(1), name="Anomalous", domain=Domain.ANOMALY_CLASSIFICATION ) if train_subset is not None: diff --git a/ote_sdk/ote_sdk/configuration/configurable_parameters.py b/ote_sdk/ote_sdk/configuration/configurable_parameters.py index dc641e12823..4f4414b2ff6 100644 --- a/ote_sdk/ote_sdk/configuration/configurable_parameters.py +++ b/ote_sdk/ote_sdk/configuration/configurable_parameters.py @@ -20,7 +20,7 @@ class ConfigurableParameters(ParameterGroup): ConfigurableParameters instance is essentially a parameter group with an id attached to it, so that it can be uniquely identified in the repositories. - :var id_: ID that uniquely identifies the ConfigurableParameters + :var id: ID that uniquely identifies the ConfigurableParameters :var header: User friendly name for the ConfigurableParameters, that will be displayed in the UI diff --git a/ote_sdk/ote_sdk/configuration/helper/convert.py b/ote_sdk/ote_sdk/configuration/helper/convert.py index 7cd37c757df..49c313b19ca 100644 --- a/ote_sdk/ote_sdk/configuration/helper/convert.py +++ b/ote_sdk/ote_sdk/configuration/helper/convert.py @@ -127,8 +127,8 @@ def convert( ) if id_to_str or target == str or target == DictConfig: - config_id = config_dict.get("id_", None) - config_dict["id_"] = str(config_id) if config_id is not None else None + config_id = config_dict.get("id", None) + config_dict["id"] = str(config_id) if config_id is not None else None if target == str: result = yaml.dump(config_dict) diff --git a/ote_sdk/ote_sdk/entities/annotation.py b/ote_sdk/ote_sdk/entities/annotation.py index 9fdf1119337..27bbce2df45 100644 --- a/ote_sdk/ote_sdk/entities/annotation.py +++ b/ote_sdk/ote_sdk/entities/annotation.py @@ -24,9 +24,9 @@ class Annotation(metaclass=abc.ABCMeta): # pylint: disable=redefined-builtin; def __init__( - self, shape: ShapeEntity, labels: List[ScoredLabel], id_: Optional[ID] = None + self, shape: ShapeEntity, labels: List[ScoredLabel], id: Optional[ID] = None ): - self.__id_ = ID(ObjectId()) if id_ is None else id_ + self.__id_ = ID(ObjectId()) if id is None else id self.__shape = shape self.__labels = labels @@ -35,7 +35,7 @@ def __repr__(self): f"{self.__class__.__name__}(" f"shape={self.shape}, " f"labels={self.get_labels(True)}, " - f"id_={self.id_})" + f"id={self.id_})" ) @property @@ -149,7 +149,7 @@ class AnnotationSceneEntity(metaclass=abc.ABCMeta): :param kind: Kind of annotation scene `AnnotationSceneKind`. E.g. `AnnotationSceneKind.ANNOTATION`. :param editor: The user that made this annotation scene object :param creation_date: Creation date of annotation scene entity. - :param id_: ID of AnnotationSceneEntity. + :param id: ID of AnnotationSceneEntity. """ # pylint: disable=too-many-arguments, redefined-builtin @@ -159,13 +159,13 @@ def __init__( kind: AnnotationSceneKind, editor: str = "", creation_date: Optional[datetime.datetime] = None, - id_: Optional[ID] = None, + id: Optional[ID] = None, ): self.__annotations = annotations self.__kind = kind self.__editor = editor self.__creation_date = now() if creation_date is None else creation_date - self.__id_ = ID() if id_ is None else id_ + self.__id_ = ID() if id is None else id def __repr__(self): return ( @@ -174,7 +174,7 @@ def __repr__(self): f"kind={self.kind}, " f"editor={self.editor_name}, " f"creation_date={self.creation_date}, " - f"id_={self.id_})" + f"id={self.id_})" ) @property @@ -306,7 +306,7 @@ class NullAnnotationSceneEntity(AnnotationSceneEntity): def __init__(self) -> None: super().__init__( - id_=ID(), + id=ID(), kind=AnnotationSceneKind.NONE, editor="", creation_date=datetime.datetime.now(), diff --git a/ote_sdk/ote_sdk/entities/datasets.py b/ote_sdk/ote_sdk/entities/datasets.py index edc329e2962..59953cb25ed 100644 --- a/ote_sdk/ote_sdk/entities/datasets.py +++ b/ote_sdk/ote_sdk/entities/datasets.py @@ -95,7 +95,7 @@ class DatasetEntity: DatasetItemEntity( media=Image(image.jpg, width=640, height=480), annotation_scene=NullAnnotationSceneEntity(), - roi=Annotation(shape=Rectangle(x=0.0, y=0.0, width=1.0, height=1.0), labels=[], id_=6149e454893b7ebbe3a8faf6), + roi=Annotation(shape=Rectangle(x=0.0, y=0.0, width=1.0, height=1.0), labels=[], id=6149e454893b7ebbe3a8faf6), subset=NONE ) diff --git a/ote_sdk/ote_sdk/entities/label.py b/ote_sdk/ote_sdk/entities/label.py index cc4aa81483f..b349f19d32a 100644 --- a/ote_sdk/ote_sdk/entities/label.py +++ b/ote_sdk/ote_sdk/entities/label.py @@ -74,7 +74,7 @@ class LabelEntity: :param hotkey: key or combination of keys to select this label in the UI :param creation_date: the date time of the label creation :param is_empty: set to True if the label is an empty label. - :param id_: the ID of the label. Set to ID() so that a new unique ID + :param id: the ID of the label. Set to ID() so that a new unique ID will be assigned upon saving. If the argument is None, it will be set to ID() """ @@ -87,9 +87,9 @@ def __init__( hotkey: str = "", creation_date: Optional[datetime.datetime] = None, is_empty: bool = False, - id_: Optional[ID] = None, + id: Optional[ID] = None, ): - id_ = ID() if id_ is None else id_ + id = ID() if id is None else id color = Color.random() if color is None else color creation_date = now() if creation_date is None else creation_date @@ -99,7 +99,7 @@ def __init__( self._domain = domain self._is_empty = is_empty self._creation_date = creation_date - self.__id_ = id_ + self.__id_ = id @property def name(self): @@ -162,7 +162,7 @@ def creation_date(self) -> datetime.datetime: @property def id_(self) -> ID: """ - Returns the label id_. + Returns the label id. """ return self.__id_ diff --git a/ote_sdk/ote_sdk/entities/label_schema.py b/ote_sdk/ote_sdk/entities/label_schema.py index beac819c6b2..6b407bc650d 100644 --- a/ote_sdk/ote_sdk/entities/label_schema.py +++ b/ote_sdk/ote_sdk/entities/label_schema.py @@ -38,7 +38,7 @@ class LabelGroup: The labels have to be from one task. - :param id_: ID of the LabelGroup. If no ID is provided, a new ObjectId() will be + :param id: ID of the LabelGroup. If no ID is provided, a new ObjectId() will be assigned :param name: Descriptive name of the label group :param labels: Labels that form the group @@ -51,9 +51,9 @@ def __init__( name: str, labels: Sequence[LabelEntity], group_type: LabelGroupType = LabelGroupType.EXCLUSIVE, - id_: ID = None, + id: ID = None, ): - self.id_ = ID(ObjectId()) if id_ is None else id_ + self.id_ = ID(ObjectId()) if id is None else id self.labels = sorted(labels, key=lambda x: x.id_) self.name = name @@ -94,7 +94,7 @@ def __eq__(self, other: object): def __repr__(self) -> str: return ( - f"LabelGroup(id_={self.id_}, name={self.name}, group_type={self.group_type}," + f"LabelGroup(id={self.id_}, name={self.name}, group_type={self.group_type}," f" labels={self.labels})" ) @@ -368,7 +368,7 @@ def get_parent(self, label: LabelEntity) -> Optional[LabelEntity]: def get_label_ids(self, include_empty) -> List[ID]: """ Returns a list of label ids that are in the LabelSchema - :param include_empty: Include empty label id_ or not + :param include_empty: Include empty label id or not """ label_ids = { label.id_ diff --git a/ote_sdk/ote_sdk/entities/model.py b/ote_sdk/ote_sdk/entities/model.py index 52d86c4c17f..bad719b38da 100644 --- a/ote_sdk/ote_sdk/entities/model.py +++ b/ote_sdk/ote_sdk/entities/model.py @@ -113,9 +113,9 @@ def __init__( optimization_objectives: Dict[str, str] = None, performance_improvement: Dict[str, float] = None, model_size_reduction: float = 0.0, - id_: Optional[ID] = None, + _id: Optional[ID] = None, ): - id_ = ID() if id_ is None else id_ + _id = ID() if _id is None else _id performance = NullPerformance() if performance is None else performance creation_date = now() if creation_date is None else creation_date @@ -135,7 +135,7 @@ def __init__( if model_adapters is None: model_adapters = {} - self.__id_ = id_ + self.__id_ = _id self.__creation_date = creation_date self.__train_dataset = train_dataset self.__previous_trained_revision = previous_trained_revision @@ -162,7 +162,7 @@ def __init__( @property def id_(self) -> ID: - """Gets or sets the id_ of a Model""" + """Gets or sets the id of a Model""" return self.__id_ @id_.setter diff --git a/ote_sdk/ote_sdk/entities/resultset.py b/ote_sdk/ote_sdk/entities/resultset.py index 3180849d496..d2d7c955f73 100644 --- a/ote_sdk/ote_sdk/entities/resultset.py +++ b/ote_sdk/ote_sdk/entities/resultset.py @@ -62,7 +62,7 @@ class ResultSetEntity(metaclass=abc.ABCMeta): :param performance: the performance of the model on the ground truth dataset :param creation_date: the date time which the resultset is created. Set to None to set this to datetime.now(datetime.timezone.utc) - :param id_: the id_ of the resultset. Set to ID() so that a new unique ID will be assigned upon saving. + :param id: the id of the resultset. Set to ID() so that a new unique ID will be assigned upon saving. If the argument is None, it will be set to ID() """ @@ -75,12 +75,12 @@ def __init__( purpose: ResultsetPurpose = ResultsetPurpose.EVALUATION, performance: Optional[Performance] = None, creation_date: Optional[datetime.datetime] = None, - id_: Optional[ID] = None, + id: Optional[ID] = None, ): - id_ = ID() if id_ is None else id_ + id = ID() if id is None else id performance = NullPerformance() if performance is None else performance creation_date = now() if creation_date is None else creation_date - self.__id_ = id_ + self.__id_ = id self.__model = model self.__prediction_dataset = prediction_dataset self.__ground_truth_dataset = ground_truth_dataset @@ -170,5 +170,5 @@ def __repr__(self): f"purpose={self.purpose}, " f"performance={self.performance}, " f"creation_date={self.creation_date}, " - f"id_={self.id_})" + f"id={self.id_})" ) diff --git a/ote_sdk/ote_sdk/entities/scored_label.py b/ote_sdk/ote_sdk/entities/scored_label.py index 632573aa624..b87aec70272 100644 --- a/ote_sdk/ote_sdk/entities/scored_label.py +++ b/ote_sdk/ote_sdk/entities/scored_label.py @@ -33,7 +33,7 @@ def name(self) -> str: @property def id_(self) -> ID: """ - Returns the label id_. + Returns the label id. """ return self.label.id_ diff --git a/ote_sdk/ote_sdk/serialization/label_mapper.py b/ote_sdk/ote_sdk/serialization/label_mapper.py index 8e1c22f9a7f..6481f1cf47e 100644 --- a/ote_sdk/ote_sdk/serialization/label_mapper.py +++ b/ote_sdk/ote_sdk/serialization/label_mapper.py @@ -79,7 +79,7 @@ def backward(instance: dict) -> LabelEntity: label_domain = Domain[domain] label = LabelEntity( - id_=label_id, + id=label_id, name=instance["name"], color=ColorMapper().backward(instance["color"]), hotkey=instance.get("hotkey", ""), @@ -111,7 +111,7 @@ def backward(instance: dict, all_labels: Dict[ID, LabelEntity]) -> LabelGroup: """Deserializes from dict.""" return LabelGroup( - id_=IDMapper().backward(instance["__id_"]), + id=IDMapper().backward(instance["__id_"]), name=instance["name"], group_type=LabelGroupType[instance["relation_type"]], labels=[ diff --git a/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py b/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py index 05f05e294b0..cbe18e4a0b4 100644 --- a/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py +++ b/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py @@ -41,13 +41,13 @@ def rectangle_labels() -> list: name="Rectangle label", domain=Domain.DETECTION, color=Color(red=100, green=50, blue=200), - id_=ID("rectangle_label_1"), + id=ID("rectangle_label_1"), ) other_rectangle_label = LabelEntity( name="Other rectangle label", domain=Domain.SEGMENTATION, color=Color(red=200, green=80, blue=100), - id_=ID("rectangle_label_2"), + id=ID("rectangle_label_2"), ) return [ ScoredLabel(label=rectangle_label), @@ -238,7 +238,7 @@ def test_rectangle_eq(self): assert rectangle != str # Check for unequal labels parameters. Expected that different labels are not affecting equality unequal_label = LabelEntity( - name="Unequal label", domain=Domain.SEGMENTATION, id_=ID("unequal_label_1") + name="Unequal label", domain=Domain.SEGMENTATION, id=ID("unequal_label_1") ) unequal_scored_label = ScoredLabel(label=unequal_label) equal_rectangle._labels.append(unequal_scored_label) diff --git a/ote_sdk/ote_sdk/tests/entities/test_annotation.py b/ote_sdk/ote_sdk/tests/entities/test_annotation.py index 0574e7c523d..4d2177a23f8 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_annotation.py +++ b/ote_sdk/ote_sdk/tests/entities/test_annotation.py @@ -43,14 +43,14 @@ class TestAnnotation: annotation = Annotation(shape=rectangle, labels=labels) car = LabelEntity( - id_=ID(123456789), + id=ID(123456789), name="car", domain=Domain.DETECTION, color=Color(red=16, green=15, blue=56, alpha=255), is_empty=True, ) person = LabelEntity( - id_=ID(987654321), + id=ID(987654321), name="person", domain=Domain.DETECTION, color=Color(red=11, green=18, blue=38, alpha=200), @@ -144,7 +144,7 @@ def test_annotation_magic_methods(self): assert ( repr(annotation) - == "Annotation(shape=Ellipse(x1=0.5, y1=0.1, x2=0.8, y2=0.3), labels=[], id_=123456789)" + == "Annotation(shape=Ellipse(x1=0.5, y1=0.1, x2=0.8, y2=0.3), labels=[], id=123456789)" ) assert annotation == other_annotation assert annotation != third_annotation @@ -423,7 +423,7 @@ def test_annotation_scene_entity_magic_methods(self): f"kind={annotation_scene_entity.kind}, " f"editor={annotation_scene_entity.editor_name}, " f"creation_date={annotation_scene_entity.creation_date}, " - f"id_={annotation_scene_entity.id_})" + f"id={annotation_scene_entity.id_})" ] for i in annotation_scene_entity_repr: @@ -572,7 +572,7 @@ def test_annotation_scene_entity_get_label_ids(self): assert annotation_scene_entity.get_label_ids() == {ID()} - bus = LabelEntity(id_=ID(123456789), name="bus", domain=Domain.DETECTION) + bus = LabelEntity(id=ID(123456789), name="bus", domain=Domain.DETECTION) bus_label = ScoredLabel(bus) labels = [bus_label] annotation = Annotation(shape=self.rectangle, labels=labels) diff --git a/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py b/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py index 95c33cec7a1..0d32564e5b9 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py +++ b/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py @@ -47,7 +47,7 @@ def labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(red=100, green=200, blue=150), creation_date=creation_date, - id_=ID("detection_label"), + id=ID("detection_label"), ) segmentation_label = LabelEntity( name="Label for Segmentation", @@ -55,7 +55,7 @@ def labels() -> List[LabelEntity]: color=Color(red=50, green=80, blue=200), creation_date=creation_date, is_empty=True, - id_=ID("segmentation_label"), + id=ID("segmentation_label"), ) return [detection_label, segmentation_label] @@ -66,12 +66,12 @@ def annotations(self) -> List[Annotation]: detection_annotation = Annotation( shape=rectangle, labels=[ScoredLabel(label=labels[0])], - id_=ID("detection_annotation_1"), + id=ID("detection_annotation_1"), ) segmentation_annotation = Annotation( shape=other_rectangle, labels=[ScoredLabel(label=labels[1])], - id_=ID("segmentation_annotation_1"), + id=ID("segmentation_annotation_1"), ) return [detection_annotation, segmentation_annotation] @@ -83,7 +83,7 @@ def roi_labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(red=40, green=180, blue=80), creation_date=creation_date, - id_=ID("roi_label_1"), + id=ID("roi_label_1"), ) other_roi_label = LabelEntity( name="Second ROI label", @@ -91,7 +91,7 @@ def roi_labels() -> List[LabelEntity]: color=Color(red=80, green=90, blue=70), creation_date=creation_date, is_empty=True, - id_=ID("roi_label_2"), + id=ID("roi_label_2"), ) return [roi_label, other_roi_label] @@ -109,7 +109,7 @@ def roi(self): modification_date=datetime.datetime(year=2021, month=12, day=9), ), labels=self.roi_scored_labels(), - id_=ID("roi_annotation"), + id=ID("roi_annotation"), ) return roi @@ -130,7 +130,7 @@ def annotations_entity(self) -> AnnotationSceneEntity: annotations=self.annotations(), kind=AnnotationSceneKind.ANNOTATION, creation_date=datetime.datetime(year=2021, month=12, day=19), - id_=ID("annotation_entity_1"), + id=ID("annotation_entity_1"), ) def default_values_dataset_item(self) -> DatasetItemEntity: @@ -158,7 +158,7 @@ def compare_denormalized_annotations( for index in range(len(expected_annotations)): actual_annotation = actual_annotations[index] expected_annotation = expected_annotations[index] - # Redefining id_ and modification_date required because of new Annotation objects created after shape + # Redefining id and modification_date required because of new Annotation objects created after shape # denormalize actual_annotation.id_ = expected_annotation.id_ actual_annotation.shape.modification_date = ( @@ -173,7 +173,7 @@ def labels_to_add() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(red=60, green=120, blue=70), creation_date=datetime.datetime(year=2021, month=12, day=12), - id_=ID("label_to_add_1"), + id=ID("label_to_add_1"), ) other_label_to_add = LabelEntity( name="Other label to add", @@ -181,7 +181,7 @@ def labels_to_add() -> List[LabelEntity]: color=Color(red=80, green=70, blue=100), creation_date=datetime.datetime(year=2021, month=12, day=11), is_empty=True, - id_=ID("label_to_add_2"), + id=ID("label_to_add_2"), ) return [label_to_add, other_label_to_add] @@ -190,12 +190,12 @@ def annotations_to_add(self) -> List[Annotation]: annotation_to_add = Annotation( shape=Rectangle(x1=0.1, y1=0.1, x2=0.7, y2=0.8), labels=[ScoredLabel(label=labels_to_add[0])], - id_=ID("added_annotation_1"), + id=ID("added_annotation_1"), ) other_annotation_to_add = Annotation( shape=Rectangle(x1=0.2, y1=0.3, x2=0.8, y2=0.9), labels=[ScoredLabel(label=labels_to_add[1])], - id_=ID("added_annotation_2"), + id=ID("added_annotation_2"), ) return [annotation_to_add, other_annotation_to_add] @@ -348,7 +348,7 @@ def test_dataset_item_roi(self): # Checking that "roi" property will be equal to full_box for DatasetItemEntity with not specified "roi" but one # of Annotation objects in annotation_scene is equal to full Rectangle full_box_label = LabelEntity( - "Full-box label", Domain.DETECTION, id_=ID("full_box_label") + "Full-box label", Domain.DETECTION, id=ID("full_box_label") ) full_box_annotation = Annotation( Rectangle.generate_full_box(), [ScoredLabel(full_box_label)] @@ -386,7 +386,7 @@ def test_dataset_item_roi_numpy(self): """ media = DatasetItemParameters.generate_random_image() annotation_scene = DatasetItemParameters().annotations_entity() - roi_label = LabelEntity("ROI label", Domain.DETECTION, id_=ID("roi_label")) + roi_label = LabelEntity("ROI label", Domain.DETECTION, id=ID("roi_label")) dataset_item = DatasetItemEntity(media, annotation_scene) # Checking array returned by "roi_numpy" method with non-specified "roi" parameter for DatasetItemEntity # "roi" attribute is "None" @@ -421,7 +421,7 @@ def test_dataset_item_roi_numpy(self): ] ), labels=[], - id_=ID("polygon_roi"), + id=ID("polygon_roi"), ) assert np.array_equal( dataset_item.roi_numpy(polygon_roi), media.numpy[4:8, 5:13] @@ -610,7 +610,7 @@ def test_dataset_item_append_annotations(self): ) ) dataset_item.append_annotations(annotations_to_add) - # Random id_ is generated for normalized annotations + # Random id is generated for normalized annotations normalized_annotations[0].id_ = dataset_item.annotation_scene.annotations[2].id_ normalized_annotations[1].id_ = dataset_item.annotation_scene.annotations[3].id_ assert ( @@ -622,7 +622,7 @@ def test_dataset_item_append_annotations(self): name="Label for incorrect shape", domain=Domain.CLASSIFICATION, color=Color(red=80, green=70, blue=155), - id_=ID("incorrect_shape_label"), + id=ID("incorrect_shape_label"), ) incorrect_polygon = Polygon( [Point(x=0.01, y=0.1), Point(x=0.35, y=0.1), Point(x=0.35, y=0.1)] @@ -630,7 +630,7 @@ def test_dataset_item_append_annotations(self): incorrect_shape_annotation = Annotation( shape=incorrect_polygon, labels=[ScoredLabel(incorrect_shape_label)], - id_=ID("incorrect_shape_annotation"), + id=ID("incorrect_shape_annotation"), ) dataset_item.append_annotations([incorrect_shape_annotation]) assert ( diff --git a/ote_sdk/ote_sdk/tests/entities/test_label.py b/ote_sdk/ote_sdk/tests/entities/test_label.py index daf853017ad..886c8e6b9b2 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_label.py +++ b/ote_sdk/ote_sdk/tests/entities/test_label.py @@ -51,7 +51,7 @@ class TestLabelEntity: "hotkey": "ctrl+1", "creation_date": creation_date, "is_empty": False, - "id_": ID(123456789), + "id": ID(123456789), } label_person_params = { @@ -61,7 +61,7 @@ class TestLabelEntity: "hotkey": "ctrl+2", "creation_date": creation_date, "is_empty": False, - "id_": ID(987654321), + "id": ID(987654321), } car = LabelEntity(**label_car_params) # type: ignore empty = LabelEntity(name="empty", domain=Domain.SEGMENTATION, is_empty=True) @@ -98,7 +98,7 @@ def test_label_entity(self): "hotkey", "creation_date", "is_empty", - "id_", + "id", ]: assert getattr(self.car, attr) == self.label_car_params[attr] @@ -112,7 +112,7 @@ def test_label_entity(self): setattr(self.car, "domain", label_car_new_domain) setattr(self.car, "color", label_car_new_color) setattr(self.car, "hotkey", label_car_new_hotkey) - setattr(self.car, "id_", label_car_new_id) + setattr(self.car, "id", label_car_new_id) assert self.car.name == label_car_new_name assert self.car.domain == label_car_new_domain @@ -164,7 +164,7 @@ def test_empty_label_entity(self): def test_label_comparison(self): """ Description: - Check the LabelEntity __lt__, __gt__ methods with changed id_ + Check the LabelEntity __lt__, __gt__ methods with changed id Input data: Dummy data @@ -174,7 +174,7 @@ def test_label_comparison(self): Steps 1. Use already created dummy data - 2. Check the processing of changed id_ + 2. Check the processing of changed id """ self.empty.id_ = ID(999999999) diff --git a/ote_sdk/ote_sdk/tests/entities/test_label_schema.py b/ote_sdk/ote_sdk/tests/entities/test_label_schema.py index d1703041df0..1a1f4a1fc0a 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_label_schema.py +++ b/ote_sdk/ote_sdk/tests/entities/test_label_schema.py @@ -393,37 +393,37 @@ def __init__(self): self.label_0 = LabelEntity( name="Label 0", domain=Domain.CLASSIFICATION, - id_=ID("0"), + id=ID("0"), color=Color(25, 200, 166), ) self.label_0_1 = LabelEntity( name="Label 0_1", domain=Domain.DETECTION, - id_=ID("0_1"), + id=ID("0_1"), color=Color(40, 100, 17), ) self.label_0_2 = LabelEntity( name="Label 0_2", domain=Domain.SEGMENTATION, - id_=ID("0_2"), + id=ID("0_2"), color=Color(30, 80, 40), ) self.label_0_1_3 = LabelEntity( name="Label_0_1_3", domain=Domain.SEGMENTATION, - id_=ID("0_1_3"), + id=ID("0_1_3"), color=Color(40, 100, 17), ) self.label_0_2_4 = LabelEntity( name="Label_0_2_4", domain=Domain.SEGMENTATION, - id_=ID("0_2_4"), + id=ID("0_2_4"), color=Color(30, 80, 40), ) self.label_0_2_5 = LabelEntity( name="Label_0_2_5", domain=Domain.SEGMENTATION, - id_=ID("0_2_5"), + id=ID("0_2_5"), color=Color(30, 80, 40), ) self.no_id_label = LabelEntity(name="No ID Label", domain=Domain.SEGMENTATION) @@ -449,18 +449,18 @@ def test_label_group_initialization(self): LabelGroup object with specified name, labels, group type and ID parameters Expected results: - Test passes if LabelGroup object id_, labels, name and group_type attributes return expected values + Test passes if LabelGroup object id, labels, name and group_type attributes return expected values Steps - 1. Check id_, labels, name and group_type attributes of LabelGroup object with not specified group_type + 1. Check id, labels, name and group_type attributes of LabelGroup object with not specified group_type parameter - 2. Check id_, labels, name and group_type attributes of LabelGroup object with not specified id_ parameter + 2. Check id, labels, name and group_type attributes of LabelGroup object with not specified id parameter """ - # Checking attributes of LabelGroup object with specified id_ and not specified group_type parameters + # Checking attributes of LabelGroup object with specified id and not specified group_type parameters no_group_type_label_group = LabelGroup( name="Type non-specified specified label group", labels=[labels.label_0_1, labels.no_id_label, labels.label_0], - id_=ID("1"), + id=ID("1"), ) assert no_group_type_label_group.id_ == "1" # Expected ascending sorting of labels @@ -475,13 +475,13 @@ def test_label_group_initialization(self): assert no_group_type_label_group.group_type == LabelGroupType.EXCLUSIVE assert isinstance(no_group_type_label_group.minimum_label_id, ID) assert no_group_type_label_group.minimum_label_id == "" - # Checking attributes of LabelGroup object with specified group_type and not specified id_ parameters + # Checking attributes of LabelGroup object with specified group_type and not specified id parameters no_id_label_group = LabelGroup( name="ID non-specified Label Group", labels=[labels.label_0_1, labels.label_0], group_type=LabelGroupType.EMPTY_LABEL, ) - # Expected randomly generated ID object with 24 characters as "id_" attribute + # Expected randomly generated ID object with 24 characters as "id" attribute assert isinstance(no_id_label_group.id_, ID) assert len(no_id_label_group.id_) == 24 # Expected ascending sorting of labels @@ -543,44 +543,44 @@ def test_label_group_magic_methods(self): group_labels = [labels.label_0, labels.label_0_1] name = "Test Label Group" group_id = ID("1") - label_group = LabelGroup(name=name, labels=group_labels, id_=group_id) - equal_label_group = LabelGroup(name=name, labels=group_labels, id_=group_id) + label_group = LabelGroup(name=name, labels=group_labels, id=group_id) + equal_label_group = LabelGroup(name=name, labels=group_labels, id=group_id) no_id_specified_label_group = LabelGroup(name=name, labels=group_labels) # Checking __eq__ method for equal LabelGroup objects assert label_group == equal_label_group # Checking equality of LabelGroups with different "name" attributes assert label_group == LabelGroup( - name="Different name LabelGroup", labels=group_labels, id_=group_id + name="Different name LabelGroup", labels=group_labels, id=group_id ) - # Checking inequality of LabelGroups with different "id_" attributes + # Checking inequality of LabelGroups with different "id" attributes assert not label_group == no_id_specified_label_group # Checking inequality of LabelGroups with different "labels" attributes assert not label_group == LabelGroup( - name=name, labels=[labels.label_0], id_=group_id + name=name, labels=[labels.label_0], id=group_id ) # Checking inequality of LabelGroups with different "group_type" attributes assert not label_group == LabelGroup( name=name, labels=group_labels, - id_=group_id, + id=group_id, group_type=LabelGroupType.EMPTY_LABEL, ) # Checking inequality of LabelGroups with different object of different type assert not label_group == str - # Checking __repr__ method for LabelGroup object with specified id_ + # Checking __repr__ method for LabelGroup object with specified id assert repr(label_group) == ( - "LabelGroup(id_=1, name=Test Label Group, group_type=LabelGroupType.EXCLUSIVE, " + "LabelGroup(id=1, name=Test Label Group, group_type=LabelGroupType.EXCLUSIVE, " f"labels={group_labels})" ) - # Checking __repr__ method for LabelGroup object with [] labels and not specified id_ + # Checking __repr__ method for LabelGroup object with [] labels and not specified id no_labels_no_id_label_group = LabelGroup( - name="Null labels, random id_ group", + name="Null labels, random id group", labels=[], group_type=LabelGroupType.EMPTY_LABEL, ) generated_id = no_labels_no_id_label_group.id_ assert repr(no_labels_no_id_label_group) == ( - f"LabelGroup(id_={generated_id}, name=Null labels, random id_ group," + f"LabelGroup(id={generated_id}, name=Null labels, random id group," f" group_type=LabelGroupType.EMPTY_LABEL, labels=[])" ) @@ -1497,12 +1497,12 @@ def label_groups() -> list: group_1 = LabelGroup( name="Exclusive group 1", labels=[labels.label_0_1, labels.label_0_2], - id_=ID("Exclusive group 1"), + id=ID("Exclusive group 1"), ) group_2 = LabelGroup( name="Exclusive group 2", labels=[labels.label_0_2_4, labels.label_0_2_5], - id_=ID("Exclusive group 2"), + id=ID("Exclusive group 2"), ) return [group_1, group_2] @@ -1513,14 +1513,14 @@ def empty_labels() -> list: domain=Domain.SEGMENTATION, color=Color(255, 255, 255), is_empty=True, - id_=ID("empty_label_1"), + id=ID("empty_label_1"), ) empty_non_exclusive_label = LabelEntity( name="Empty non-exclusive label", domain=Domain.DETECTION, color=Color(255, 255, 255), is_empty=True, - id_=ID("empty_non_excl_label_1"), + id=ID("empty_non_excl_label_1"), ) return [empty_label, empty_non_exclusive_label] @@ -1529,13 +1529,13 @@ def empty_labels_groups(self) -> list: empty_group_1 = LabelGroup( name="Exclusive group with empty label", labels=[empty_labels[0]], - id_=ID("Exclusive group with empty label"), + id=ID("Exclusive group with empty label"), ) empty_group_2 = LabelGroup( name="Empty label group with empty label", labels=[empty_labels[1]], group_type=LabelGroupType.EMPTY_LABEL, - id_=ID("Empty label group with empty label"), + id=ID("Empty label group with empty label"), ) return [empty_group_1, empty_group_2] @@ -1664,15 +1664,15 @@ def test_label_schema_entity_add_group(self): label_schema_entity = self.label_schema_entity() # Scenario for adding exclusive group with new labels new_exclusive_label = LabelEntity( - name="New label", domain=Domain.DETECTION, id_=ID("new_ex_1") + name="New label", domain=Domain.DETECTION, id=ID("new_ex_1") ) other_new_exclusive_label = LabelEntity( - name="Other new label", domain=Domain.DETECTION, id_=ID("new_ex_2") + name="Other new label", domain=Domain.DETECTION, id=ID("new_ex_2") ) new_exclusive_group = LabelGroup( name="New exclusive labels group", labels=[new_exclusive_label, other_new_exclusive_label], - id_=ID("new_ex_group"), + id=ID("new_ex_group"), ) label_schema_entity.add_group(new_exclusive_group) assert label_schema_entity.get_exclusive_groups() == ( @@ -1683,7 +1683,7 @@ def test_label_schema_entity_add_group(self): new_exclusive_group = LabelGroup( name="Exclusive group with one label", labels=[new_exclusive_label], - id_=ID("single_excl_group"), + id=ID("single_excl_group"), ) label_schema_entity.add_group(new_exclusive_group) assert label_schema_entity.get_exclusive_groups() == ( @@ -1694,7 +1694,7 @@ def test_label_schema_entity_add_group(self): new_exclusive_group = LabelGroup( name="Exclusive group to link with existing", labels=[labels.label_0_1, new_exclusive_label], - id_=ID("new_ex_group"), + id=ID("new_ex_group"), ) label_schema_entity.add_group(new_exclusive_group) assert label_schema_entity.get_exclusive_groups() == ( @@ -1706,7 +1706,7 @@ def test_label_schema_entity_add_group(self): name="Non exclusive label group", labels=[new_exclusive_label], group_type=LabelGroupType.EMPTY_LABEL, - id_=ID("non_exclusive_group"), + id=ID("non_exclusive_group"), ) label_schema_entity.add_group(new_exclusive_group) assert label_schema_entity.get_exclusive_groups() == exclusive_groups @@ -1850,12 +1850,12 @@ def test_label_schema_get_exclusive_groups(self): name="New label", domain=Domain.DETECTION, color=Color(100, 16, 25), - id_=ID("new_ex_1"), + id=ID("new_ex_1"), ) new_labels_group = LabelGroup( name="New exclusive labels group", labels=[new_label], - id_=ID("new_ex_group"), + id=ID("new_ex_group"), ) label_schema_entity.add_group(new_labels_group) exclusive_groups.append(new_labels_group) @@ -1865,7 +1865,7 @@ def test_label_schema_get_exclusive_groups(self): name="New non-exclusive labels group", labels=[new_label], group_type=LabelGroupType.EMPTY_LABEL, - id_=ID("new_ex_group"), + id=ID("new_ex_group"), ) label_schema_entity.add_group(empty_label_group) assert label_schema_entity.get_exclusive_groups() == exclusive_groups @@ -1897,13 +1897,13 @@ def test_label_schema_add_labels_to_group_by_group_name(self): name="New label", domain=Domain.DETECTION, color=Color(100, 16, 25), - id_=ID("new_ex_1"), + id=ID("new_ex_1"), ) new_empty_label = LabelEntity( name="New empty label", domain=Domain.DETECTION, color=Color(81, 100, 10), - id_=ID("new_ex_2"), + id=ID("new_ex_2"), ) exclusive_group_name = "Exclusive group 1" label_schema_entity.add_labels_to_group_by_group_name( @@ -1917,7 +1917,7 @@ def test_label_schema_add_labels_to_group_by_group_name(self): name="New non-exclusive empty_label", domain=Domain.SEGMENTATION, is_empty=True, - id_=ID("empty_label_1"), + id=ID("empty_label_1"), ) empty_label_group_name = "Empty label group with empty label" label_schema_entity.add_labels_to_group_by_group_name( @@ -2032,7 +2032,7 @@ def test_label_schema_get_label(self): name="Scored label", domain=Domain.DETECTION, color=Color(red=100, green=50, blue=200), - id_=ID("scored_label_1"), + id=ID("scored_label_1"), ) scored_label = ScoredLabel(label=label_to_set_scored) scored_labels_group = LabelGroup( diff --git a/ote_sdk/ote_sdk/tests/entities/test_model.py b/ote_sdk/ote_sdk/tests/entities/test_model.py index 4287bba9123..818c8db5ee5 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_model.py +++ b/ote_sdk/ote_sdk/tests/entities/test_model.py @@ -286,7 +286,7 @@ def __get_path_to_file(filename: str): set_params = { "configuration": environment.get_model_configuration(), "train_dataset": dataset, - "id_": ID(1234567890), + "id": ID(1234567890), "creation_date": self.creation_date, "previous_trained_revision": 5, "previous_revision": 2, diff --git a/ote_sdk/ote_sdk/tests/entities/test_result_media.py b/ote_sdk/ote_sdk/tests/entities/test_result_media.py index 3022322bfa0..2bddc58ccbf 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_result_media.py +++ b/ote_sdk/ote_sdk/tests/entities/test_result_media.py @@ -33,18 +33,18 @@ def default_result_media_parameters() -> dict: domain=Domain.DETECTION, color=Color(100, 200, 60), creation_date=datetime.datetime(year=2021, month=12, day=16), - id_=ID("rectangle_label_1"), + id=ID("rectangle_label_1"), ) rectangle_annotation = Annotation( shape=Rectangle(x1=0.1, y1=0.4, x2=0.4, y2=0.9), labels=[ScoredLabel(rectangle_label)], - id_=ID("rectangle_annotation"), + id=ID("rectangle_annotation"), ) annotation_scene = AnnotationSceneEntity( annotations=[rectangle_annotation], kind=AnnotationSceneKind.ANNOTATION, creation_date=datetime.datetime(year=2021, month=12, day=16), - id_=ID("annotation_scene"), + id=ID("annotation_scene"), ) return { "name": "ResultMedia name", @@ -60,19 +60,19 @@ def optional_result_media_parameters(self) -> dict: Domain.DETECTION, Color(10, 200, 40), creation_date=datetime.datetime(year=2021, month=12, day=18), - id_=ID("roi_label_1"), + id=ID("roi_label_1"), ) roi = Annotation( shape=Rectangle(x1=0.3, y1=0.2, x2=0.7, y2=0.6), labels=[ScoredLabel(roi_label)], - id_=ID("roi_annotation"), + id=ID("roi_annotation"), ) result_media_label = LabelEntity( "ResultMedia label", Domain.CLASSIFICATION, Color(200, 60, 100), creation_date=datetime.datetime(year=2021, month=12, day=20), - id_=ID("result_media_1"), + id=ID("result_media_1"), ) optional_result_media_parameters["roi"] = roi optional_result_media_parameters["label"] = result_media_label diff --git a/ote_sdk/ote_sdk/tests/entities/test_resultset.py b/ote_sdk/ote_sdk/tests/entities/test_resultset.py index fcec35687de..d1c7cabfcc3 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_resultset.py +++ b/ote_sdk/ote_sdk/tests/entities/test_resultset.py @@ -81,7 +81,7 @@ def test_resultset_entity(self): "purpose": None, "performance": None, "creation_date": None, - "id_": None, + "id": None, } result_set = ResultSetEntity(**test_data) @@ -122,7 +122,7 @@ def test_resultset_entity(self): f"purpose={result_set.purpose}", f"performance={result_set.performance}", f"creation_date={result_set.creation_date}", - f"id_={result_set.id_}", + f"id={result_set.id_}", ] for i in test_result_set_repr: diff --git a/ote_sdk/ote_sdk/tests/entities/test_scored_label.py b/ote_sdk/ote_sdk/tests/entities/test_scored_label.py index 47bdc6c8916..b57c3990ee2 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_scored_label.py +++ b/ote_sdk/ote_sdk/tests/entities/test_scored_label.py @@ -39,15 +39,15 @@ def test_scored_label(self): Test passes if the results match """ car = LabelEntity( - id_=ID(123456789), name="car", domain=Domain.DETECTION, is_empty=False + id=ID(123456789), name="car", domain=Domain.DETECTION, is_empty=False ) person = LabelEntity( - id_=ID(987654321), name="person", domain=Domain.DETECTION, is_empty=False + id=ID(987654321), name="person", domain=Domain.DETECTION, is_empty=False ) car_label = ScoredLabel(car) person_label = ScoredLabel(person) - for attr in ["id_", "name", "color", "hotkey", "creation_date", "is_empty"]: + for attr in ["id", "name", "color", "hotkey", "creation_date", "is_empty"]: assert getattr(car_label, attr) == getattr(car, attr) assert car_label.get_label() == car diff --git a/ote_sdk/ote_sdk/tests/entities/test_task_environment.py b/ote_sdk/ote_sdk/tests/entities/test_task_environment.py index ad6fc72ce12..76f89ff6202 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_task_environment.py +++ b/ote_sdk/ote_sdk/tests/entities/test_task_environment.py @@ -49,10 +49,10 @@ def environment(): Return TaskEnvironment """ car = LabelEntity( - id_=ID(123456789), name="car", domain=Domain.DETECTION, is_empty=False + id=ID(123456789), name="car", domain=Domain.DETECTION, is_empty=False ) person = LabelEntity( - id_=ID(987654321), name="person", domain=Domain.DETECTION, is_empty=False + id=ID(987654321), name="person", domain=Domain.DETECTION, is_empty=False ) labels_list = [car, person] dummy_template = __get_path_to_file("./dummy_template.yaml") @@ -117,7 +117,7 @@ def test_task_environment(self): assert env.get_hyper_parameters().id_ == ID() assert "model=None" in repr(env) - assert "label_schema=LabelSchemaEntity(label_groups=[LabelGroup(id_=" in repr( + assert "label_schema=LabelSchemaEntity(label_groups=[LabelGroup(id=" in repr( env ) assert "name=from_label_list" in repr(env) @@ -138,7 +138,7 @@ def test_task_environment(self): in repr(env) ) assert "visible_in_ui=True" in repr(env) - assert "id_=ID()" in repr(env) + assert "id=ID()" in repr(env) @pytest.mark.priority_medium @pytest.mark.unit diff --git a/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py b/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py index 25638eddfe1..d0dc8beb82b 100644 --- a/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py +++ b/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py @@ -79,7 +79,7 @@ def test_label_entity_serialization(self): hotkey="ctrl+1", creation_date=cur_date, is_empty=False, - id_=ID("0000213"), + id=ID("0000213"), ) serialized = LabelMapper.forward(label) @@ -124,7 +124,7 @@ def test_flat_label_schema_serialization(self): name=name, domain=Domain.CLASSIFICATION, creation_date=cur_date, - id_=ID(i), + id=ID(i), color=colors[i], ) for i, name in enumerate(names) @@ -198,7 +198,7 @@ def test_label_group_serialization(self): LabelEntity( name=name, domain=Domain.CLASSIFICATION, - id_=ID(str(i)), + id=ID(str(i)), ) for i, name in enumerate(names) ] @@ -222,17 +222,17 @@ def test_label_group_serialization(self): @pytest.mark.components(OteSdkComponent.OTE_SDK) class TestLabelGraphMapper: - label_0 = LabelEntity(name="label_0", domain=Domain.SEGMENTATION, id_=ID("0")) - label_0_1 = LabelEntity(name="label_0_1", domain=Domain.SEGMENTATION, id_=ID("0_1")) - label_0_2 = LabelEntity(name="label_0_2", domain=Domain.SEGMENTATION, id_=ID("0_2")) + label_0 = LabelEntity(name="label_0", domain=Domain.SEGMENTATION, id=ID("0")) + label_0_1 = LabelEntity(name="label_0_1", domain=Domain.SEGMENTATION, id=ID("0_1")) + label_0_2 = LabelEntity(name="label_0_2", domain=Domain.SEGMENTATION, id=ID("0_2")) label_0_1_1 = LabelEntity( - name="label_0_1_1", domain=Domain.SEGMENTATION, id_=ID("0_1_1") + name="label_0_1_1", domain=Domain.SEGMENTATION, id=ID("0_1_1") ) label_0_1_2 = LabelEntity( - name="label_0_1_2", domain=Domain.SEGMENTATION, id_=ID("0_1_2") + name="label_0_1_2", domain=Domain.SEGMENTATION, id=ID("0_1_2") ) label_0_2_1 = LabelEntity( - name="label_0_2_1", domain=Domain.SEGMENTATION, id_=ID("0_2_1") + name="label_0_2_1", domain=Domain.SEGMENTATION, id=ID("0_2_1") ) @pytest.mark.priority_medium diff --git a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_accuracy.py b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_accuracy.py index 37bbef9bf02..bf06acc3908 100644 --- a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_accuracy.py +++ b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_accuracy.py @@ -56,7 +56,7 @@ def car(self) -> LabelEntity: domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("car_label"), + id=ID("car_label"), ) def human(self) -> LabelEntity: @@ -65,7 +65,7 @@ def human(self) -> LabelEntity: domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("human_label"), + id=ID("human_label"), ) def dog(self) -> LabelEntity: @@ -74,7 +74,7 @@ def dog(self) -> LabelEntity: domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("dog_label"), + id=ID("dog_label"), ) def human_1_dataset_item(self) -> DatasetItemEntity: diff --git a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_dice.py b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_dice.py index d8b216f2cae..c9df8a08ebb 100644 --- a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_dice.py +++ b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_dice.py @@ -49,28 +49,28 @@ class TestDice: domain=Domain.DETECTION, color=color, creation_date=creation_date, - id_=ID("car_label"), + id=ID("car_label"), ) human_label = LabelEntity( name="human", domain=Domain.DETECTION, color=color, creation_date=creation_date, - id_=ID("human_label"), + id=ID("human_label"), ) dog_label = LabelEntity( name="dog", domain=Domain.DETECTION, color=color, creation_date=creation_date, - id_=ID("dog_label"), + id=ID("dog_label"), ) cat_label = LabelEntity( name="cat", domain=Domain.DETECTION, color=color, creation_date=creation_date, - id_=ID("cat_label"), + id=ID("cat_label"), ) configurable_params = ConfigurableParameters( header="Test model configurable params" diff --git a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_f_measure.py b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_f_measure.py index a1725a4961b..80ee3eca81b 100644 --- a/ote_sdk/ote_sdk/tests/usecases/evaluation/test_f_measure.py +++ b/ote_sdk/ote_sdk/tests/usecases/evaluation/test_f_measure.py @@ -1224,7 +1224,7 @@ def model(self): ) model_label_group = LabelGroup( - name="model_labels", labels=self.model_labels(), id_=ID("model_label") + name="model_labels", labels=self.model_labels(), id=ID("model_label") ) model_configuration = ModelConfiguration( @@ -1246,7 +1246,7 @@ def roi(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("image_roi"), + id=ID("image_roi"), ) ) ], @@ -1262,7 +1262,7 @@ def image_1_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_1_image_1"), + id=ID("class_1_image_1"), ), probability=0.95, ) @@ -1278,7 +1278,7 @@ def image_1_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_2_image_1"), + id=ID("class_2_image_1"), ), probability=0.93, ) @@ -1294,7 +1294,7 @@ def image_1_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_2_image_1"), + id=ID("class_2_image_1"), ), probability=0.91, ) @@ -1323,7 +1323,7 @@ def image_2_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_1_image_2"), + id=ID("class_1_image_2"), ), probability=0.9, ) @@ -1339,7 +1339,7 @@ def image_2_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_1_image_2"), + id=ID("class_1_image_2"), ), probability=0.88, ) @@ -1355,7 +1355,7 @@ def image_2_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_3_image_2"), + id=ID("class_3_image_2"), ), probability=0.94, ) @@ -1371,7 +1371,7 @@ def image_2_ground_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_3_image_2"), + id=ID("class_3_image_2"), ), probability=0.92, ) @@ -1405,7 +1405,7 @@ def image_1_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_1_image_1"), + id=ID("class_1_image_1"), ), probability=0.92, ) @@ -1421,7 +1421,7 @@ def image_1_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_1_image_1"), + id=ID("class_1_image_1"), ), probability=0.93, ) @@ -1437,7 +1437,7 @@ def image_1_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_2_image_1"), + id=ID("class_2_image_1"), ), probability=0.92, ) @@ -1453,7 +1453,7 @@ def image_1_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_2_image_1"), + id=ID("class_2_image_1"), ), probability=0.91, ) @@ -1487,7 +1487,7 @@ def image_2_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_1_image_2"), + id=ID("class_1_image_2"), ), probability=0.89, ) @@ -1503,7 +1503,7 @@ def image_2_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_1_image_2"), + id=ID("class_1_image_2"), ), probability=0.85, ) @@ -1519,7 +1519,7 @@ def image_2_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_3_image_2"), + id=ID("class_3_image_2"), ), probability=0.95, ) @@ -1535,7 +1535,7 @@ def image_2_prediction_boxes(self): domain=Domain.DETECTION, color=self.color, creation_date=self.creation_date, - id_=ID("class_3_image_2"), + id=ID("class_3_image_2"), ), probability=0.94, ) diff --git a/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_prediction_to_annotation_converter.py b/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_prediction_to_annotation_converter.py index 9368438c6c6..fca687932f0 100644 --- a/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_prediction_to_annotation_converter.py +++ b/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_prediction_to_annotation_converter.py @@ -232,9 +232,9 @@ def test_create_converter(self): # Checking "DetectionBoxToAnnotationConverter" returned by "create_converter" function when "DETECTION" is # specified as "converter_type" labels = [ - LabelEntity(name="Detection label", domain=Domain.DETECTION, id_=ID("1")), + LabelEntity(name="Detection label", domain=Domain.DETECTION, id=ID("1")), LabelEntity( - name="Other Detection label", domain=Domain.DETECTION, id_=ID("2") + name="Other Detection label", domain=Domain.DETECTION, id=ID("2") ), ] label_group = LabelGroup(name="Detection labels group", labels=labels) @@ -248,12 +248,12 @@ def test_create_converter(self): # specified as "converter_type" labels = [ LabelEntity( - name="Segmentation label", domain=Domain.SEGMENTATION, id_=ID("1") + name="Segmentation label", domain=Domain.SEGMENTATION, id=ID("1") ), LabelEntity( name="Other Segmentation label", domain=Domain.SEGMENTATION, - id_=ID("2"), + id=ID("2"), ), ] label_group = LabelGroup(name="Segmentation labels group", labels=labels) @@ -269,12 +269,12 @@ def test_create_converter(self): LabelEntity( name="Classification label", domain=Domain.CLASSIFICATION, - id_=ID("1"), + id=ID("1"), ), LabelEntity( name="Other Classification label", domain=Domain.CLASSIFICATION, - id_=ID("2"), + id=ID("2"), ), ] label_group = LabelGroup(name="Classification labels group", labels=labels) @@ -288,10 +288,10 @@ def test_create_converter(self): # "ANOMALY_CLASSIFICATION" is specified as "converter_type" labels = [ LabelEntity( - name="Normal", domain=Domain.ANOMALY_CLASSIFICATION, id_=ID("1") + name="Normal", domain=Domain.ANOMALY_CLASSIFICATION, id=ID("1") ), LabelEntity( - name="Anomalous", domain=Domain.ANOMALY_CLASSIFICATION, id_=ID("2") + name="Anomalous", domain=Domain.ANOMALY_CLASSIFICATION, id=ID("2") ), ] label_group = LabelGroup( @@ -329,14 +329,14 @@ class TestDetectionBoxToAnnotation: domain=Domain.DETECTION, color=color, creation_date=creation_date, - id_=ID("1"), + id=ID("1"), ), LabelEntity( name="Other Detection label", domain=Domain.DETECTION, color=color, creation_date=creation_date, - id_=ID("2"), + id=ID("2"), ), ] @@ -373,13 +373,13 @@ def test_detection_box_to_annotation_init(self): name="empty label", domain=Domain.DETECTION, is_empty=True, - id_=ID("3"), + id=ID("3"), ), LabelEntity( name="other empty label", domain=Domain.DETECTION, is_empty=True, - id_=ID("4"), + id=ID("4"), ), ] label_group = LabelGroup(name="Detection labels group", labels=empty_labels) @@ -478,14 +478,14 @@ class TestSegmentationToAnnotation: domain=Domain.SEGMENTATION, color=color, creation_date=creation_date, - id_=ID("0"), + id=ID("0"), ), LabelEntity( name="Other Segmentation label", domain=Domain.SEGMENTATION, color=color, creation_date=creation_date, - id_=ID("1"), + id=ID("1"), ), ] @@ -529,13 +529,13 @@ def test_segmentation_to_annotation_init(self): name="empty label", domain=Domain.SEGMENTATION, is_empty=True, - id_=ID("3"), + id=ID("3"), ), LabelEntity( name="other empty label", domain=Domain.SEGMENTATION, is_empty=True, - id_=ID("4"), + id=ID("4"), ), ] label_group = LabelGroup(name="Segmentation labels group", labels=empty_labels) @@ -691,16 +691,16 @@ def test_classification_to_annotation_init(self): with several labels in each """ label_0 = LabelEntity( - name="label_0", domain=Domain.CLASSIFICATION, id_=ID("0") + name="label_0", domain=Domain.CLASSIFICATION, id=ID("0") ) label_0_1 = LabelEntity( - name="label_0_1", domain=Domain.CLASSIFICATION, id_=ID("0_1") + name="label_0_1", domain=Domain.CLASSIFICATION, id=ID("0_1") ) label_0_2 = LabelEntity( - name="label_0_2", domain=Domain.CLASSIFICATION, id_=ID("0_2") + name="label_0_2", domain=Domain.CLASSIFICATION, id=ID("0_2") ) label_0_1_1 = LabelEntity( - name="label_0_1_1", domain=Domain.CLASSIFICATION, id_=ID("0_1_1") + name="label_0_1_1", domain=Domain.CLASSIFICATION, id=ID("0_1_1") ) non_empty_labels = [label_0, label_0_1, label_0_1_1, label_0_2] @@ -709,7 +709,7 @@ def test_classification_to_annotation_init(self): name="empty label", domain=Domain.CLASSIFICATION, is_empty=True, - id_=ID("3"), + id=ID("3"), ) ] # Checking attributes of "ClassificationToAnnotationConverter" initialized with one label group with @@ -754,9 +754,9 @@ def test_classification_to_annotation_init(self): # Checking attributes of "ClassificationToAnnotationConverter" initialized with two label groups with # several labels in each other_non_empty_labels = [ - LabelEntity(name="label", domain=Domain.CLASSIFICATION, id_=ID("3")), + LabelEntity(name="label", domain=Domain.CLASSIFICATION, id=ID("3")), LabelEntity( - name="other label", domain=Domain.CLASSIFICATION, id_=ID("4") + name="other label", domain=Domain.CLASSIFICATION, id=ID("4") ), ] label_group = LabelGroup( @@ -808,16 +808,16 @@ def check_annotation(actual_annotation: Annotation, expected_labels: list): assert Rectangle.is_full_box(rectangle=actual_annotation.shape) label_0 = LabelEntity( - name="label_0", domain=Domain.CLASSIFICATION, id_=ID("0") + name="label_0", domain=Domain.CLASSIFICATION, id=ID("0") ) label_0_1 = LabelEntity( - name="label_0_1", domain=Domain.CLASSIFICATION, id_=ID("0_1") + name="label_0_1", domain=Domain.CLASSIFICATION, id=ID("0_1") ) label_0_2 = LabelEntity( - name="label_0_2", domain=Domain.CLASSIFICATION, id_=ID("0_2") + name="label_0_2", domain=Domain.CLASSIFICATION, id=ID("0_2") ) label_0_1_1 = LabelEntity( - name="label_0_1_1", domain=Domain.CLASSIFICATION, id_=ID("0_1_1") + name="label_0_1_1", domain=Domain.CLASSIFICATION, id=ID("0_1_1") ) non_empty_labels = [label_0, label_0_1, label_0_1_1, label_0_2] empty_labels = [ @@ -825,7 +825,7 @@ def check_annotation(actual_annotation: Annotation, expected_labels: list): name="empty label", domain=Domain.CLASSIFICATION, is_empty=True, - id_=ID("3"), + id=ID("3"), ) ] # Checking "AnnotationSceneEntity" returned by "convert_to_annotation" for @@ -925,14 +925,10 @@ def test_anomaly_classification_to_annotation_init( # Checking attributes of "AnomalyClassificationToAnnotationConverter" initialized with non-empty labels # list non_empty_labels = [ - LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id_=ID("1")), - LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id_=ID("2")), - LabelEntity( - name="Anomalous", domain=Domain.CLASSIFICATION, id_=ID("1") - ), - LabelEntity( - name="Anomalous", domain=Domain.CLASSIFICATION, id_=ID("2") - ), + LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id=ID("1")), + LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id=ID("2")), + LabelEntity(name="Anomalous", domain=Domain.CLASSIFICATION, id=ID("1")), + LabelEntity(name="Anomalous", domain=Domain.CLASSIFICATION, id=ID("2")), ] label_group = LabelGroup( name="Classification labels group", labels=non_empty_labels @@ -950,25 +946,25 @@ def test_anomaly_classification_to_annotation_init( name="Normal", domain=Domain.CLASSIFICATION, is_empty=True, - id_=ID("3"), + id=ID("3"), ), LabelEntity( name="Normal", domain=Domain.CLASSIFICATION, is_empty=True, - id_=ID("4"), + id=ID("4"), ), LabelEntity( name="Anomalous", domain=Domain.CLASSIFICATION, is_empty=True, - id_=ID("3"), + id=ID("3"), ), LabelEntity( name="Anomalous", domain=Domain.CLASSIFICATION, is_empty=True, - id_=ID("4"), + id=ID("4"), ), ] label_group = LabelGroup( @@ -1013,8 +1009,8 @@ def check_annotation(actual_annotation: Annotation, expected_labels: list): assert Rectangle.is_full_box(rectangle=actual_annotation.shape) non_empty_labels = [ - LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id_=ID("1")), - LabelEntity(name="Anomalous", domain=Domain.CLASSIFICATION, id_=ID("2")), + LabelEntity(name="Normal", domain=Domain.CLASSIFICATION, id=ID("1")), + LabelEntity(name="Anomalous", domain=Domain.CLASSIFICATION, id=ID("2")), ] label_group = LabelGroup( name="Anomaly classification labels group", labels=non_empty_labels diff --git a/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_visualization.py b/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_visualization.py index 456407a4874..4841a63f429 100644 --- a/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_visualization.py +++ b/ote_sdk/ote_sdk/tests/usecases/exportable_code/test_visualization.py @@ -39,14 +39,14 @@ def annotation_scene() -> AnnotationSceneEntity: domain=Domain.DETECTION, color=annotation_color, creation_date=creation_date, - id_=ID("detection_1"), + id=ID("detection_1"), ) segmentation_label = LabelEntity( name="segmentation label", domain=Domain.SEGMENTATION, color=annotation_color, creation_date=creation_date, - id_=ID("segmentation_1"), + id=ID("segmentation_1"), ) annotation = Annotation( shape=Rectangle(x1=0.1, y1=0.1, x2=0.4, y2=0.5), @@ -61,14 +61,14 @@ def annotation_scene() -> AnnotationSceneEntity: domain=Domain.CLASSIFICATION, color=other_annotation_color, creation_date=creation_date, - id_=ID("classification_1"), + id=ID("classification_1"), ) anomaly_segmentation_label = LabelEntity( name="anomaly_segmentation label", domain=Domain.ANOMALY_SEGMENTATION, color=other_annotation_color, creation_date=creation_date, - id_=ID("anomaly_segmentation_1"), + id=ID("anomaly_segmentation_1"), ) other_annotation = Annotation( shape=Ellipse(x1=0.6, y1=0.4, x2=0.7, y2=0.9), diff --git a/ote_sdk/ote_sdk/tests/utils/test_segmentation_utils.py b/ote_sdk/ote_sdk/tests/utils/test_segmentation_utils.py index 8e9faab4cb0..97485687a5d 100644 --- a/ote_sdk/ote_sdk/tests/utils/test_segmentation_utils.py +++ b/ote_sdk/ote_sdk/tests/utils/test_segmentation_utils.py @@ -38,19 +38,19 @@ def rectangle_label(): return LabelEntity( name="Rectangle label", domain=Domain.SEGMENTATION, - id_=ID("1_rectangle_label"), + id=ID("1_rectangle_label"), ) @staticmethod def ellipse_label(): return LabelEntity( - name="Ellipse label", domain=Domain.SEGMENTATION, id_=ID("3_ellipse_label") + name="Ellipse label", domain=Domain.SEGMENTATION, id=ID("3_ellipse_label") ) @staticmethod def polygon_label(): return LabelEntity( - name="Polygon label", domain=Domain.SEGMENTATION, id_=ID("6_polygon_label") + name="Polygon label", domain=Domain.SEGMENTATION, id=ID("6_polygon_label") ) @pytest.mark.priority_medium @@ -74,24 +74,24 @@ def test_mask_from_annotation(self): name="Empty Rectangle label", domain=Domain.SEGMENTATION, is_empty=True, - id_=ID("2_empty_rectangle_label"), + id=ID("2_empty_rectangle_label"), ) empty_ellipse_label = LabelEntity( name="Empty Ellipse label", domain=Domain.SEGMENTATION, is_empty=True, - id_=ID("5_empty_ellipse_label"), + id=ID("5_empty_ellipse_label"), ) empty_polygon_label = LabelEntity( name="Empty Polygon label", domain=Domain.SEGMENTATION, is_empty=True, - id_=ID("7_empty_polygon_label"), + id=ID("7_empty_polygon_label"), ) non_annotation_label = LabelEntity( name="Non-annotation label", domain=Domain.SEGMENTATION, - id_=ID("4_empty_annotation_label"), + id=ID("4_empty_annotation_label"), ) rectangle_annotation = Annotation( shape=Rectangle(x1=0.5, y1=0.7, x2=0.9, y2=0.9), diff --git a/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py b/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py index 1b8a55bd3aa..495ade86f6b 100644 --- a/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py +++ b/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py @@ -40,7 +40,7 @@ def labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(red=100, green=200, blue=150), creation_date=creation_date, - id_=ID("detection_label"), + id=ID("detection_label"), ) segmentation_label = LabelEntity( name="Label for Segmentation", @@ -48,7 +48,7 @@ def labels() -> List[LabelEntity]: color=Color(red=50, green=80, blue=200), creation_date=creation_date, is_empty=True, - id_=ID("segmentation_label"), + id=ID("segmentation_label"), ) return [detection_label, segmentation_label] @@ -60,7 +60,7 @@ def scored_labels() -> List[ScoredLabel]: domain=Domain.CLASSIFICATION, color=Color(red=200, green=170, blue=90), creation_date=creation_date, - id_=ID("classification_label"), + id=ID("classification_label"), ) anomaly_detection_label = LabelEntity( name="Label for Anomaly Detection", @@ -68,7 +68,7 @@ def scored_labels() -> List[ScoredLabel]: color=Color(red=100, green=200, blue=190), creation_date=creation_date, is_empty=True, - id_=ID("anomaly_detection_label"), + id=ID("anomaly_detection_label"), ) return [ScoredLabel(classification_label), ScoredLabel(anomaly_detection_label)] @@ -581,14 +581,14 @@ def full_rectangle_labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(100, 200, 60), creation_date=datetime.datetime(year=2021, month=12, day=16), - id_=ID("full_rectangle_label_1"), + id=ID("full_rectangle_label_1"), ) other_rectangle_label = LabelEntity( name="other Full-Rectangle Annotation Label", domain=Domain.SEGMENTATION, color=Color(80, 160, 200), creation_date=datetime.datetime(year=2021, month=12, day=15), - id_=ID("full_rectangle_label_2"), + id=ID("full_rectangle_label_2"), ) return [rectangle_label, other_rectangle_label] @@ -600,7 +600,7 @@ def full_rectangle_annotation(self) -> Annotation: return Annotation( shape=Rectangle(x1=0, y1=0, x2=1, y2=1), labels=self.full_rectangle_scored_labels(), - id_=ID("full_rectangle_annotation"), + id=ID("full_rectangle_annotation"), ) @staticmethod @@ -610,14 +610,14 @@ def rectangle_labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(100, 200, 60), creation_date=datetime.datetime(year=2021, month=12, day=16), - id_=ID("rectangle_label_1"), + id=ID("rectangle_label_1"), ) other_rectangle_label = LabelEntity( name="other Rectangle Annotation Label", domain=Domain.SEGMENTATION, color=Color(80, 160, 200), creation_date=datetime.datetime(year=2021, month=12, day=15), - id_=ID("rectangle_label_2"), + id=ID("rectangle_label_2"), ) return [rectangle_label, other_rectangle_label] @@ -629,7 +629,7 @@ def rectangle_annotation(self) -> Annotation: return Annotation( shape=Rectangle(x1=0.1, y1=0.4, x2=0.4, y2=0.9), labels=self.rectangle_scored_labels(), - id_=ID("rectangle_annotation"), + id=ID("rectangle_annotation"), ) @staticmethod @@ -639,14 +639,14 @@ def polygon_labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(200, 200, 100), creation_date=datetime.datetime(year=2021, month=12, day=16), - id_=ID("polygon_label_1"), + id=ID("polygon_label_1"), ) other_polygon_label = LabelEntity( name="other Polygon Annotation Label", domain=Domain.SEGMENTATION, color=Color(100, 100, 150), creation_date=datetime.datetime(year=2021, month=12, day=15), - id_=ID("polygon_label_2"), + id=ID("polygon_label_2"), ) return [polygon_label, other_polygon_label] @@ -666,7 +666,7 @@ def polygon_annotation(self) -> Annotation: ] ), labels=self.polygon_scored_labels(), - id_=ID("polygon_annotation"), + id=ID("polygon_annotation"), ) @staticmethod @@ -676,14 +676,14 @@ def ellipse_labels() -> List[LabelEntity]: domain=Domain.DETECTION, color=Color(100, 100, 200), creation_date=datetime.datetime(year=2021, month=12, day=16), - id_=ID("ellipse_label_1"), + id=ID("ellipse_label_1"), ) other_ellipse_label = LabelEntity( name="other Ellipse Annotation Label", domain=Domain.SEGMENTATION, color=Color(200, 80, 150), creation_date=datetime.datetime(year=2021, month=12, day=15), - id_=ID("ellipse_label_2"), + id=ID("ellipse_label_2"), ) return [ellipse_label, other_ellipse_label] @@ -695,7 +695,7 @@ def ellipse_annotation(self) -> Annotation: return Annotation( shape=Ellipse(x1=0.5, y1=0.0, x2=1.0, y2=0.5), labels=self.ellipse_scored_labels(), - id_=ID("ellipse_annotation"), + id=ID("ellipse_annotation"), ) def annotation_scene(self) -> AnnotationSceneEntity: @@ -708,7 +708,7 @@ def annotation_scene(self) -> AnnotationSceneEntity: ], kind=AnnotationSceneKind.ANNOTATION, creation_date=datetime.datetime(year=2021, month=12, day=16), - id_=ID("annotation_scene"), + id=ID("annotation_scene"), ) diff --git a/ote_sdk/ote_sdk/usecases/exportable_code/demo/demo.py b/ote_sdk/ote_sdk/usecases/exportable_code/demo/demo.py index 22571b44f1b..43eef700182 100644 --- a/ote_sdk/ote_sdk/usecases/exportable_code/demo/demo.py +++ b/ote_sdk/ote_sdk/usecases/exportable_code/demo/demo.py @@ -34,7 +34,7 @@ def build_argparser(): "--input", required=True, help="Required. An input to process. The input must be a single image, " - "a folder of images, video file or camera id_.", + "a folder of images, video file or camera id.", ) args.add_argument( "-m", diff --git a/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py b/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py index 6c26b2b82a2..bffeb85f810 100644 --- a/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py +++ b/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py @@ -84,7 +84,7 @@ def convert_to_annotation( annotations = self.__convert_to_annotations(predictions) # media_identifier = ImageIdentifier(image_id=ID()) annotation_scene = AnnotationSceneEntity( - id_=ID(), + id=ID(), kind=AnnotationSceneKind.PREDICTION, editor="ote", creation_date=now(), diff --git a/ote_sdk/ote_sdk/utils/segmentation_utils.py b/ote_sdk/ote_sdk/utils/segmentation_utils.py index cb04649cf6f..48faa7acbc1 100644 --- a/ote_sdk/ote_sdk/utils/segmentation_utils.py +++ b/ote_sdk/ote_sdk/utils/segmentation_utils.py @@ -256,7 +256,7 @@ def create_annotation_from_segmentation_map( Annotation( shape=polygon, labels=[ScoredLabel(label, probability)], - id_=ID(ObjectId()), + id=ID(ObjectId()), ) ) else: From c8edd6faa9b32c3f117e16090451c9aa4968719d Mon Sep 17 00:00:00 2001 From: Harmjan Date: Wed, 16 Feb 2022 12:54:55 +0100 Subject: [PATCH 05/11] minor-fixes --- .../ote_sdk/configuration/configurable_parameters.py | 6 +++++- ote_sdk/ote_sdk/entities/annotation.py | 10 ++++++++++ ote_sdk/ote_sdk/entities/label.py | 10 ++++++++++ ote_sdk/ote_sdk/entities/label_schema.py | 10 ++++++++++ ote_sdk/ote_sdk/entities/model.py | 10 ++++++++++ ote_sdk/ote_sdk/entities/resultset.py | 9 +++++++++ ote_sdk/ote_sdk/entities/scored_label.py | 5 +++++ ote_sdk/ote_sdk/serialization/label_mapper.py | 8 ++++---- .../ote_sdk/tests/serialization/test_label_mapper.py | 12 ++++++------ 9 files changed, 69 insertions(+), 11 deletions(-) diff --git a/ote_sdk/ote_sdk/configuration/configurable_parameters.py b/ote_sdk/ote_sdk/configuration/configurable_parameters.py index 4f4414b2ff6..b174d2e2d6a 100644 --- a/ote_sdk/ote_sdk/configuration/configurable_parameters.py +++ b/ote_sdk/ote_sdk/configuration/configurable_parameters.py @@ -20,13 +20,17 @@ class ConfigurableParameters(ParameterGroup): ConfigurableParameters instance is essentially a parameter group with an id attached to it, so that it can be uniquely identified in the repositories. - :var id: ID that uniquely identifies the ConfigurableParameters + :var id_: ID that uniquely identifies the ConfigurableParameters + :var id: DEPRECATED :var header: User friendly name for the ConfigurableParameters, that will be displayed in the UI """ id_: ID = attrib(default=ID(), kw_only=True, converter=convert_string_to_id) + id: ID = attrib( + default=ID(), kw_only=True, converter=convert_string_to_id + ) # DEPRECATED type: ConfigElementType = attrib( default=ConfigElementType.CONFIGURABLE_PARAMETERS, repr=False, diff --git a/ote_sdk/ote_sdk/entities/annotation.py b/ote_sdk/ote_sdk/entities/annotation.py index 27bbce2df45..ac636ef4170 100644 --- a/ote_sdk/ote_sdk/entities/annotation.py +++ b/ote_sdk/ote_sdk/entities/annotation.py @@ -49,6 +49,16 @@ def id_(self): def id_(self, value): self.__id_ = value + @property + def id(self): + """DEPRECATED""" + return self.__id_ + + @id.setter + def id(self, value): + """DEPRECATED""" + self.__id_ = value + @property def shape(self): """ diff --git a/ote_sdk/ote_sdk/entities/label.py b/ote_sdk/ote_sdk/entities/label.py index b349f19d32a..733ea0c0452 100644 --- a/ote_sdk/ote_sdk/entities/label.py +++ b/ote_sdk/ote_sdk/entities/label.py @@ -170,6 +170,16 @@ def id_(self) -> ID: def id_(self, value: ID): self.__id_ = value + @property + def id(self) -> ID: + """DEPRECATED""" + return self.__id_ + + @id.setter + def id(self, value: ID): + """DEPRECATED""" + self.__id_ = value + def __repr__(self): return ( f"LabelEntity({self.id_}, name={self.name}, hotkey={self.hotkey}, " diff --git a/ote_sdk/ote_sdk/entities/label_schema.py b/ote_sdk/ote_sdk/entities/label_schema.py index 6b407bc650d..061ebdec55c 100644 --- a/ote_sdk/ote_sdk/entities/label_schema.py +++ b/ote_sdk/ote_sdk/entities/label_schema.py @@ -59,6 +59,16 @@ def __init__( self.name = name self.group_type = group_type + @property + def id(self) -> ID: + """DEPRECATED""" + return self.id_ + + @id.setter + def id(self, value: ID): + """DEPRECATED""" + self.id_ = value + @property def minimum_label_id(self) -> ID: """ diff --git a/ote_sdk/ote_sdk/entities/model.py b/ote_sdk/ote_sdk/entities/model.py index bad719b38da..34da6a5b7df 100644 --- a/ote_sdk/ote_sdk/entities/model.py +++ b/ote_sdk/ote_sdk/entities/model.py @@ -169,6 +169,16 @@ def id_(self) -> ID: def id_(self, value: ID): self.__id_ = value + @property + def id(self) -> ID: + """DEPRECATED""" + return self.__id_ + + @id.setter + def id(self, value: ID): + """DEPRECATED""" + self.__id_ = value + @property def configuration(self) -> ModelConfiguration: """Gets or sets the configuration of the Model""" diff --git a/ote_sdk/ote_sdk/entities/resultset.py b/ote_sdk/ote_sdk/entities/resultset.py index d2d7c955f73..597ce5d8856 100644 --- a/ote_sdk/ote_sdk/entities/resultset.py +++ b/ote_sdk/ote_sdk/entities/resultset.py @@ -97,6 +97,15 @@ def id_(self) -> ID: def id_(self, value: ID) -> None: self.__id_ = value + @property + def id(self) -> ID: + """Gets or sets the id of a Model""" + return self.__id_ + + @id.setter + def id(self, value: ID): + self.__id_ = value + @property def model(self) -> ModelEntity: """Returns the model that is used for the ResultSet""" diff --git a/ote_sdk/ote_sdk/entities/scored_label.py b/ote_sdk/ote_sdk/entities/scored_label.py index b87aec70272..e4ef801c5bf 100644 --- a/ote_sdk/ote_sdk/entities/scored_label.py +++ b/ote_sdk/ote_sdk/entities/scored_label.py @@ -37,6 +37,11 @@ def id_(self) -> ID: """ return self.label.id_ + @property + def id(self) -> ID: + """Gets or sets the id of a Model""" + return self.id_ + @property def color(self) -> Color: """ diff --git a/ote_sdk/ote_sdk/serialization/label_mapper.py b/ote_sdk/ote_sdk/serialization/label_mapper.py index 6481f1cf47e..2a3621227c1 100644 --- a/ote_sdk/ote_sdk/serialization/label_mapper.py +++ b/ote_sdk/ote_sdk/serialization/label_mapper.py @@ -60,7 +60,7 @@ def forward( """Serializes to dict.""" return { - "__id_": IDMapper().forward(instance.id_), + "_id": IDMapper().forward(instance.id_), "name": instance.name, "color": ColorMapper().forward(instance.color), "hotkey": instance.hotkey, @@ -73,7 +73,7 @@ def forward( def backward(instance: dict) -> LabelEntity: """Deserializes from dict.""" - label_id = IDMapper().backward(instance["__id_"]) + label_id = IDMapper().backward(instance["_id"]) domain = str(instance.get("domain")) label_domain = Domain[domain] @@ -100,7 +100,7 @@ def forward(instance: LabelGroup) -> dict: """Serializes to dict.""" return { - "__id_": IDMapper().forward(instance.id_), + "_id": IDMapper().forward(instance.id_), "name": instance.name, "label_ids": [IDMapper().forward(label.id_) for label in instance.labels], "relation_type": instance.group_type.name, @@ -111,7 +111,7 @@ def backward(instance: dict, all_labels: Dict[ID, LabelEntity]) -> LabelGroup: """Deserializes from dict.""" return LabelGroup( - id=IDMapper().backward(instance["__id_"]), + id=IDMapper().backward(instance["_id"]), name=instance["name"], group_type=LabelGroupType[instance["relation_type"]], labels=[ diff --git a/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py b/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py index d0dc8beb82b..c5b6bd20692 100644 --- a/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py +++ b/ote_sdk/ote_sdk/tests/serialization/test_label_mapper.py @@ -84,7 +84,7 @@ def test_label_entity_serialization(self): serialized = LabelMapper.forward(label) assert serialized == { - "__id_": "0000213", + "_id": "0000213", "name": "my_label", "color": {"red": red, "green": green, "blue": blue, "alpha": alpha}, "hotkey": "ctrl+1", @@ -136,7 +136,7 @@ def test_flat_label_schema_serialization(self): "label_tree": {"type": "tree", "directed": True, "nodes": [], "edges": []}, "label_groups": [ { - "__id_": label_schema.get_groups()[0].id_, + "_id": label_schema.get_groups()[0].id_, "name": "from_label_list", "label_ids": ["0", "1", "2"], "relation_type": "EXCLUSIVE", @@ -144,7 +144,7 @@ def test_flat_label_schema_serialization(self): ], "all_labels": { "0": { - "__id_": "0", + "_id": "0", "name": "cat", "color": ColorMapper.forward(colors[0]), "hotkey": "", @@ -153,7 +153,7 @@ def test_flat_label_schema_serialization(self): "is_empty": False, }, "1": { - "__id_": "1", + "_id": "1", "name": "dog", "color": ColorMapper.forward(colors[1]), "hotkey": "", @@ -162,7 +162,7 @@ def test_flat_label_schema_serialization(self): "is_empty": False, }, "2": { - "__id_": "2", + "_id": "2", "name": "mouse", "color": ColorMapper.forward(colors[2]), "hotkey": "", @@ -207,7 +207,7 @@ def test_label_group_serialization(self): ) serialized = LabelGroupMapper.forward(label_group) assert serialized == { - "__id_": label_group.id_, + "_id": label_group.id_, "name": "Test LabelGroup", "label_ids": ["0", "1", "2"], "relation_type": "EMPTY_LABEL", From 318e4e6050cd6d96cf7744b82c5c2eb4acd0c681 Mon Sep 17 00:00:00 2001 From: Harmjan Date: Thu, 17 Feb 2022 09:19:46 +0100 Subject: [PATCH 06/11] fix bug causing test breaking --- .../exportable_code/prediction_to_annotation_converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py b/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py index bffeb85f810..08b67172898 100644 --- a/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py +++ b/ote_sdk/ote_sdk/usecases/exportable_code/prediction_to_annotation_converter.py @@ -175,7 +175,7 @@ def convert_to_annotation( annotations = [] image_size = metadata["original_shape"][1::-1] for box in predictions: - scored_label = ScoredLabel(self.labels[int(box.id_)], float(box.score)) + scored_label = ScoredLabel(self.labels[int(box.id)], float(box.score)) coords = np.array(box.get_coords(), dtype=float) / np.tile(image_size, 2) annotations.append( Annotation( From 8cf2df3b56c57bcc675fc65299eb130b0f06092d Mon Sep 17 00:00:00 2001 From: Harmjan Date: Thu, 17 Feb 2022 14:15:58 +0100 Subject: [PATCH 07/11] reinstate deprecated AnnotationSceneEntity.id so SC doesn't break --- ote_sdk/ote_sdk/entities/annotation.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ote_sdk/ote_sdk/entities/annotation.py b/ote_sdk/ote_sdk/entities/annotation.py index ac636ef4170..5e929d8dc97 100644 --- a/ote_sdk/ote_sdk/entities/annotation.py +++ b/ote_sdk/ote_sdk/entities/annotation.py @@ -198,6 +198,16 @@ def id_(self): def id_(self, value): self.__id_ = value + @property + def id(self): + """DEPRECATED""" + return self.__id_ + + @id.setter + def id(self, value): + """DEPRECATED""" + self.__id_ = value + @property def kind(self): """ From ccf0279d48e97cabfaefa1f2bb90b7e435860594 Mon Sep 17 00:00:00 2001 From: Harmjan Date: Thu, 17 Feb 2022 14:59:09 +0100 Subject: [PATCH 08/11] fix configuration converter --- ote_sdk/ote_sdk/configuration/configurable_parameters.py | 1 + ote_sdk/ote_sdk/configuration/helper/convert.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ote_sdk/ote_sdk/configuration/configurable_parameters.py b/ote_sdk/ote_sdk/configuration/configurable_parameters.py index b174d2e2d6a..395ce2b9377 100644 --- a/ote_sdk/ote_sdk/configuration/configurable_parameters.py +++ b/ote_sdk/ote_sdk/configuration/configurable_parameters.py @@ -31,6 +31,7 @@ class ConfigurableParameters(ParameterGroup): id: ID = attrib( default=ID(), kw_only=True, converter=convert_string_to_id ) # DEPRECATED + type: ConfigElementType = attrib( default=ConfigElementType.CONFIGURABLE_PARAMETERS, repr=False, diff --git a/ote_sdk/ote_sdk/configuration/helper/convert.py b/ote_sdk/ote_sdk/configuration/helper/convert.py index 49c313b19ca..97f135c8923 100644 --- a/ote_sdk/ote_sdk/configuration/helper/convert.py +++ b/ote_sdk/ote_sdk/configuration/helper/convert.py @@ -127,8 +127,12 @@ def convert( ) if id_to_str or target == str or target == DictConfig: - config_id = config_dict.get("id", None) - config_dict["id"] = str(config_id) if config_id is not None else None + config_id = config_dict.get("id", None) # DEPRECATED + config_dict["id"] = ( + str(config_id) if config_id is not None else None + ) # DEPRECATED + config_id_ = config_dict.get("id_", None) + config_dict["id_"] = str(config_id_) if config_id_ is not None else None if target == str: result = yaml.dump(config_dict) From ab56b57a865af79279a2256b2f29630e04eddbc0 Mon Sep 17 00:00:00 2001 From: Harmjan Date: Mon, 21 Feb 2022 16:11:33 +0100 Subject: [PATCH 09/11] ilya's comments --- ote_sdk/ote_sdk/entities/resultset.py | 3 ++- ote_sdk/ote_sdk/entities/scored_label.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ote_sdk/ote_sdk/entities/resultset.py b/ote_sdk/ote_sdk/entities/resultset.py index 597ce5d8856..fd9d016aacf 100644 --- a/ote_sdk/ote_sdk/entities/resultset.py +++ b/ote_sdk/ote_sdk/entities/resultset.py @@ -99,11 +99,12 @@ def id_(self, value: ID) -> None: @property def id(self) -> ID: - """Gets or sets the id of a Model""" + """DEPRECATED""" return self.__id_ @id.setter def id(self, value: ID): + """DEPRECATED""" self.__id_ = value @property diff --git a/ote_sdk/ote_sdk/entities/scored_label.py b/ote_sdk/ote_sdk/entities/scored_label.py index e4ef801c5bf..1b01465000b 100644 --- a/ote_sdk/ote_sdk/entities/scored_label.py +++ b/ote_sdk/ote_sdk/entities/scored_label.py @@ -39,8 +39,8 @@ def id_(self) -> ID: @property def id(self) -> ID: - """Gets or sets the id of a Model""" - return self.id_ + """DEPRECATED""" + return self.label.id @property def color(self) -> Color: From c9bab220a9deee8c5bfdf8022e6cbe8a70ae4b1c Mon Sep 17 00:00:00 2001 From: Harmjan Date: Wed, 23 Feb 2022 13:54:09 +0100 Subject: [PATCH 10/11] undo config changes --- .../ote_sdk/configuration/configurable_parameters.py | 9 ++------- ote_sdk/ote_sdk/configuration/helper/convert.py | 8 ++------ .../configuration/test_configurable_parameters.py | 4 ++-- .../ote_sdk/tests/entities/test_task_environment.py | 10 +++++----- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/ote_sdk/ote_sdk/configuration/configurable_parameters.py b/ote_sdk/ote_sdk/configuration/configurable_parameters.py index 395ce2b9377..4faa2c54f43 100644 --- a/ote_sdk/ote_sdk/configuration/configurable_parameters.py +++ b/ote_sdk/ote_sdk/configuration/configurable_parameters.py @@ -20,18 +20,13 @@ class ConfigurableParameters(ParameterGroup): ConfigurableParameters instance is essentially a parameter group with an id attached to it, so that it can be uniquely identified in the repositories. - :var id_: ID that uniquely identifies the ConfigurableParameters - :var id: DEPRECATED + :var id: ID that uniquely identifies the ConfigurableParameters :var header: User friendly name for the ConfigurableParameters, that will be displayed in the UI """ - id_: ID = attrib(default=ID(), kw_only=True, converter=convert_string_to_id) - id: ID = attrib( - default=ID(), kw_only=True, converter=convert_string_to_id - ) # DEPRECATED - + id: ID = attrib(default=ID(), kw_only=True, converter=convert_string_to_id) type: ConfigElementType = attrib( default=ConfigElementType.CONFIGURABLE_PARAMETERS, repr=False, diff --git a/ote_sdk/ote_sdk/configuration/helper/convert.py b/ote_sdk/ote_sdk/configuration/helper/convert.py index 97f135c8923..49c313b19ca 100644 --- a/ote_sdk/ote_sdk/configuration/helper/convert.py +++ b/ote_sdk/ote_sdk/configuration/helper/convert.py @@ -127,12 +127,8 @@ def convert( ) if id_to_str or target == str or target == DictConfig: - config_id = config_dict.get("id", None) # DEPRECATED - config_dict["id"] = ( - str(config_id) if config_id is not None else None - ) # DEPRECATED - config_id_ = config_dict.get("id_", None) - config_dict["id_"] = str(config_id_) if config_id_ is not None else None + config_id = config_dict.get("id", None) + config_dict["id"] = str(config_id) if config_id is not None else None if target == str: result = yaml.dump(config_dict) diff --git a/ote_sdk/ote_sdk/tests/configuration/test_configurable_parameters.py b/ote_sdk/ote_sdk/tests/configuration/test_configurable_parameters.py index fb107439e61..62dc331b3e9 100644 --- a/ote_sdk/ote_sdk/tests/configuration/test_configurable_parameters.py +++ b/ote_sdk/ote_sdk/tests/configuration/test_configurable_parameters.py @@ -46,7 +46,7 @@ def check_configurable_parameters_attributes( == ConfigElementType.CONFIGURABLE_PARAMETERS ) assert configurable_parameters.groups == [] - assert configurable_parameters.id_ == expected_id + assert configurable_parameters.id == expected_id assert configurable_parameters.visible_in_ui == expected_visible_in_ui header = "Test Header" @@ -66,7 +66,7 @@ def check_configurable_parameters_attributes( configurable_parameters=ConfigurableParameters( header=header, description=description, - id_=config_id, + id=config_id, visible_in_ui=visible_in_ui, ), expected_header=header, diff --git a/ote_sdk/ote_sdk/tests/entities/test_task_environment.py b/ote_sdk/ote_sdk/tests/entities/test_task_environment.py index 76f89ff6202..ebb0b0080a5 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_task_environment.py +++ b/ote_sdk/ote_sdk/tests/entities/test_task_environment.py @@ -109,12 +109,12 @@ def test_task_environment(self): == __dummy_config[i] ) - assert env.get_model_configuration().configurable_parameters.id_ == ID() + assert env.get_model_configuration().configurable_parameters.id == ID() for param in __dummy_config: getattr(env.get_hyper_parameters(), param) == __dummy_config[param] - assert env.get_hyper_parameters().id_ == ID() + assert env.get_hyper_parameters().id == ID() assert "model=None" in repr(env) assert "label_schema=LabelSchemaEntity(label_groups=[LabelGroup(id=" in repr( @@ -439,13 +439,13 @@ def test_set_hyper_parameters(self): id_ = ID(123456789) hyper_parameters = ConfigurableParameters( - header=header, description=description, visible_in_ui=visible_in_ui, id_=id_ + header=header, description=description, visible_in_ui=visible_in_ui, id=id_ ) env.set_hyper_parameters(hyper_parameters=hyper_parameters) assert env.get_hyper_parameters().header == header assert env.get_hyper_parameters().description == description assert env.get_hyper_parameters().visible_in_ui == visible_in_ui - assert env.get_hyper_parameters().id_ == id_ + assert env.get_hyper_parameters().id == id_ assert env.get_model_configuration().configurable_parameters.header == header assert ( @@ -456,7 +456,7 @@ def test_set_hyper_parameters(self): env.get_model_configuration().configurable_parameters.visible_in_ui == visible_in_ui ) - assert env.get_model_configuration().configurable_parameters.id_ == id_ + assert env.get_model_configuration().configurable_parameters.id == id_ with pytest.raises(ValueError): # ValueError: Unable to set hyper parameters, invalid input: 123 From 1fd31bfadcfeb11da98cc395df039c5bbfb1eab4 Mon Sep 17 00:00:00 2001 From: Harmjan Date: Wed, 23 Feb 2022 13:58:48 +0100 Subject: [PATCH 11/11] undo config change --- ote_sdk/ote_sdk/tests/entities/test_task_environment.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ote_sdk/ote_sdk/tests/entities/test_task_environment.py b/ote_sdk/ote_sdk/tests/entities/test_task_environment.py index ebb0b0080a5..27a1b69d76e 100644 --- a/ote_sdk/ote_sdk/tests/entities/test_task_environment.py +++ b/ote_sdk/ote_sdk/tests/entities/test_task_environment.py @@ -436,16 +436,16 @@ def test_set_hyper_parameters(self): header = "Test header" description = "Test description" visible_in_ui = False - id_ = ID(123456789) + id = ID(123456789) hyper_parameters = ConfigurableParameters( - header=header, description=description, visible_in_ui=visible_in_ui, id=id_ + header=header, description=description, visible_in_ui=visible_in_ui, id=id ) env.set_hyper_parameters(hyper_parameters=hyper_parameters) assert env.get_hyper_parameters().header == header assert env.get_hyper_parameters().description == description assert env.get_hyper_parameters().visible_in_ui == visible_in_ui - assert env.get_hyper_parameters().id == id_ + assert env.get_hyper_parameters().id == id assert env.get_model_configuration().configurable_parameters.header == header assert ( @@ -456,7 +456,7 @@ def test_set_hyper_parameters(self): env.get_model_configuration().configurable_parameters.visible_in_ui == visible_in_ui ) - assert env.get_model_configuration().configurable_parameters.id == id_ + assert env.get_model_configuration().configurable_parameters.id == id with pytest.raises(ValueError): # ValueError: Unable to set hyper parameters, invalid input: 123