2020from lib .app .helpers import extract_project_folder
2121from lib .app .helpers import get_annotation_paths
2222from lib .app .helpers import get_name_url_duplicated_from_csv
23- from lib .app .helpers import wrap_error
23+ from lib .app .helpers import wrap_error as wrap_validation_errors
2424from lib .app .interface .base_interface import BaseInterfaceFacade
2525from lib .app .interface .base_interface import TrackableMeta
2626from lib .app .interface .types import AnnotationStatuses
@@ -2107,7 +2107,7 @@ def delete_annotations(
21072107 raise AppException (response .errors )
21082108
21092109 def validate_annotations (
2110- self , project_type : ProjectTypes , annotations_json : Union [NotEmptyStr , Path ]
2110+ self , project_type : ProjectTypes , annotations_json : Union [NotEmptyStr , Path , dict ]
21112111 ):
21122112 """Validates given annotation JSON.
21132113
@@ -2120,19 +2120,20 @@ def validate_annotations(
21202120 :return: The success of the validation
21212121 :rtype: bool
21222122 """
2123- with open (annotations_json ) as file :
2124- annotation_data = json .loads (file .read ())
2125- response = Controller .validate_annotations (project_type , annotation_data )
2126- response = self .controller .validate_annotations (
2127- project_type , annotation_data
2128- )
2129- if response .errors :
2130- raise AppException (response .errors )
2131- report = response .data
2132- if not report :
2133- return True
2134- print (wrap_error (report ))
2135- return False
2123+ if isinstance (annotations_json , dict ):
2124+ annotation_data = annotations_json
2125+ else :
2126+ annotation_data = json .load (open (annotations_json ))
2127+ response = self .controller .validate_annotations (
2128+ project_type , annotation_data
2129+ )
2130+ if response .errors :
2131+ raise AppException (response .errors )
2132+ report = response .data
2133+ if not report :
2134+ return True
2135+ print (wrap_validation_errors (report ))
2136+ return False
21362137
21372138 def add_contributors_to_project (
21382139 self ,
0 commit comments