From a578e1e3b6326cc56bf928922916ba9c1f716baa Mon Sep 17 00:00:00 2001 From: Mikhail Maluyk Date: Mon, 4 Mar 2024 23:43:29 +0000 Subject: [PATCH] changing order of functions, fixing small typos --- label_studio_sdk/label_interface/interface.py | 72 +++++++++---------- .../label_interface/object_tags.py | 4 +- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/label_studio_sdk/label_interface/interface.py b/label_studio_sdk/label_interface/interface.py index 3f080d9f..0270e51e 100644 --- a/label_studio_sdk/label_interface/interface.py +++ b/label_studio_sdk/label_interface/interface.py @@ -424,42 +424,7 @@ def _unique_names_validation(self, config_string): all_names = re.findall(r'name="([^"]*)"', config_string) if len(set(all_names)) != len(all_names): raise LabelStudioValidationErrorSentryIgnored('Label config contains non-unique names') - - def validate(self): - """Validates the provided configuration string against various validation criteria. - - This method applies a series of validation checks to - `_config`, including schema validation, checking for - uniqueness of names used in the configuration, and the - "to_name" validation. It throws exceptions if any of these - validations fail. - - Raises: - Exception: If any validation fails, specific to the type of validation. - - """ - config_string = self._config - - self._schema_validation(config_string) - self._unique_names_validation(config_string) - self._to_name_validation(config_string) - @property - def is_valid(self): - """ - """ - try: - self.validate() - return True - except LabelStudioValidationErrorSentryIgnored: - return False - - @classmethod - def validate_with_data(cls, config): - """ - """ - raise NotImplemented() - def load_task(self, task): """Loads a task and substitutes the value in each object tag with actual data from the task, returning a copy of the @@ -487,7 +452,42 @@ def load_task(self, task): obj.value = task.get(obj.value_name) return tree - + + @property + def is_valid(self): + """ + """ + try: + self.validate() + return True + except LabelStudioValidationErrorSentryIgnored: + return False + + def validate(self): + """Validates the provided configuration string against various validation criteria. + + This method applies a series of validation checks to + `_config`, including schema validation, checking for + uniqueness of names used in the configuration, and the + "to_name" validation. It throws exceptions if any of these + validations fail. + + Raises: + Exception: If any validation fails, specific to the type of validation. + + """ + config_string = self._config + + self._schema_validation(config_string) + self._unique_names_validation(config_string) + self._to_name_validation(config_string) + + @classmethod + def validate_with_data(cls, config): + """ + """ + raise NotImplemented() + def validate_task(self, task: "TaskValue", validate_regions_only=False): """ """ diff --git a/label_studio_sdk/label_interface/object_tags.py b/label_studio_sdk/label_interface/object_tags.py index 2a846214..0681e9a1 100644 --- a/label_studio_sdk/label_interface/object_tags.py +++ b/label_studio_sdk/label_interface/object_tags.py @@ -74,8 +74,8 @@ class ObjectTag(LabelStudioTag): """ Class that represents a ObjectTag in Label Studio """ - name: Optional[str] = None, - value: Optional[str] = None, + name: Optional[str] = None + value: Optional[str] = None # value_type: Optional[str] = None, # TODO needs to set during parsing