@@ -46,6 +46,7 @@ def __init__(
4646 only_pinned : bool ,
4747 annotation_statuses : List [str ] = None ,
4848 integration_id : int = None ,
49+ export_type : int = None ,
4950 ):
5051 super ().__init__ (),
5152 self ._project = project
@@ -55,6 +56,7 @@ def __init__(
5556 self ._include_fuse = include_fuse
5657 self ._only_pinned = only_pinned
5758 self ._integration_id = integration_id
59+ self ._export_type = export_type
5860
5961 def validate_only_pinned (self ):
6062 if (
@@ -75,6 +77,20 @@ def validate_fuse(self):
7577 f"{ ProjectType .get_name (self ._project .type )} attached with URLs"
7678 )
7779
80+ def validate_export_type (self ):
81+ if self ._export_type == 2 :
82+ if (
83+ self ._project .type != ProjectType .VECTOR .value
84+ or self ._project .upload_state != constances .UploadState .EXTERNAL .value
85+ ):
86+ raise AppValidationException (
87+ "COCO format is not supported for this project."
88+ )
89+ elif self ._export_type == 3 and self ._project .type != ProjectType .GEN_AI .value :
90+ raise AppValidationException (
91+ "CSV format is not supported for this project."
92+ )
93+
7894 def validate_folder_names (self ):
7995 if self ._folder_names :
8096 condition = Condition ("project_id" , self ._project .id , EQ )
@@ -102,15 +118,17 @@ def execute(self):
102118 constances .AnnotationStatus .NOT_STARTED .name ,
103119 constances .AnnotationStatus .SKIPPED .name ,
104120 ]
105-
106- response = self ._service_provider .prepare_export (
121+ kwargs = dict (
107122 project = self ._project ,
108123 folders = self ._folder_names ,
109124 annotation_statuses = self ._annotation_statuses ,
110125 include_fuse = self ._include_fuse ,
111126 only_pinned = self ._only_pinned ,
112127 integration_id = self ._integration_id ,
113128 )
129+ if self ._export_type :
130+ kwargs ["export_type" ] = self ._export_type
131+ response = self ._service_provider .prepare_export (** kwargs )
114132 if not response .ok :
115133 raise AppException (response .error )
116134
0 commit comments