Skip to content

Commit

Permalink
changing order of functions, fixing small typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Maluyk committed Mar 4, 2024
1 parent 166f4e0 commit a578e1e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
72 changes: 36 additions & 36 deletions label_studio_sdk/label_interface/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
"""
Expand Down
4 changes: 2 additions & 2 deletions label_studio_sdk/label_interface/object_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a578e1e

Please sign in to comment.