@@ -39,6 +39,7 @@ def __init__(
3939 project : ProjectEntity ,
4040 folder_names : List [str ],
4141 backend_service_provider : SuperannotateServiceProvider ,
42+ folders : BaseManageableRepository ,
4243 include_fuse : bool ,
4344 only_pinned : bool ,
4445 annotation_statuses : List [str ] = None ,
@@ -50,6 +51,7 @@ def __init__(
5051 self ._annotation_statuses = annotation_statuses
5152 self ._include_fuse = include_fuse
5253 self ._only_pinned = only_pinned
54+ self ._folders = folders
5355
5456 def validate_only_pinned (self ):
5557 if (
@@ -69,6 +71,19 @@ def validate_fuse(self):
6971 f"Include fuse functionality is not supported for projects containing { self ._project .type } attached with URLs"
7072 )
7173
74+ def validate_folder_names (self ):
75+ if self ._folder_names :
76+ condition = (
77+ Condition ("team_id" , self ._project .team_id , EQ ) &
78+ Condition ("project_id" , self ._project .id , EQ )
79+ )
80+ existing_folders = {folder .name for folder in self ._folders .get_all (condition )}
81+ folder_names_set = set (self ._folder_names )
82+ if not folder_names_set .issubset (existing_folders ):
83+ raise AppException (
84+ f"Folder(s) { ', ' .join (folder_names_set - existing_folders )} does not exist"
85+ )
86+
7287 def execute (self ):
7388 if self .is_valid ():
7489 if self ._project .upload_state == constances .UploadState .EXTERNAL .value :
0 commit comments