1212from kili .domain .types import ListOrTuple
1313from kili .domain_api .base import DomainNamespace
1414from kili .domain_api .namespace_utils import get_available_methods
15- from kili .services .export .types import CocoAnnotationModifier , LabelFormat , SplitOption
15+ from kili .services .export .types import CocoAnnotationModifier , ExportType , LabelFormat , SplitOption
1616
1717if TYPE_CHECKING :
1818 import pandas as pd
@@ -94,6 +94,7 @@ def kili(
9494 include_sent_back_labels : Optional [bool ] = None ,
9595 label_type_in : Optional [list [LabelType ]] = None ,
9696 single_file : Optional [bool ] = False ,
97+ export_type : ExportType = "latest_from_last_step" ,
9798 ):
9899 """Export project labels in Kili native format.
99100
@@ -114,6 +115,14 @@ def kili(
114115 whose type belongs to that list.
115116 By default, only `DEFAULT` and `REVIEW` labels are exported.
116117 single_file: If True, all labels are exported in a single JSON file.
118+ export_type: Type of export. Options are:
119+ - `"latest_from_last_step"`: exports the latest label from the last workflow step
120+ (uses `latestLabels` field, supports multiple annotators).
121+ - `"latest_from_all_steps"`: exports latest labels from all workflow steps
122+ (useful for consensus projects with multiple annotators).
123+ - `"latest"`: exports the single latest label per asset (uses `latestLabel` field).
124+ - `"normal"`: exports all labels for each asset.
125+ Defaults to `"latest_from_last_step"`.
117126
118127 Returns:
119128 Export information or None if export failed.
@@ -129,6 +138,7 @@ def kili(
129138 normalized_coordinates = True ,
130139 fmt = "kili" ,
131140 single_file = bool (single_file ),
141+ export_type = export_type ,
132142 )
133143
134144 def coco (
@@ -142,6 +152,7 @@ def coco(
142152 include_sent_back_labels : Optional [bool ] = None ,
143153 label_type_in : Optional [list [LabelType ]] = None ,
144154 layout : SplitOption = "split" ,
155+ export_type : ExportType = "latest_from_last_step" ,
145156 ):
146157 """Export project labels in COCO format.
147158
@@ -165,6 +176,14 @@ def coco(
165176 By default, only `DEFAULT` and `REVIEW` labels are exported.
166177 layout: Layout of the exported files. "split" means there is one folder
167178 per job, "merged" that there is one folder with every labels.
179+ export_type: Type of export. Options are:
180+ - `"latest_from_last_step"`: exports the latest label from the last workflow step
181+ (uses `latestLabels` field, supports multiple annotators).
182+ - `"latest_from_all_steps"`: exports latest labels from all workflow steps
183+ (useful for consensus projects with multiple annotators).
184+ - `"latest"`: exports the single latest label per asset (uses `latestLabel` field).
185+ - `"normal"`: exports all labels for each asset.
186+ Defaults to `"latest_from_last_step"`.
168187
169188 Returns:
170189 Export information or None if export failed.
@@ -180,6 +199,7 @@ def coco(
180199 label_type_in = label_type_in ,
181200 layout = layout ,
182201 fmt = "coco" ,
202+ export_type = export_type ,
183203 )
184204
185205 def yolo_v4 (
@@ -192,6 +212,7 @@ def yolo_v4(
192212 filter : Optional [ExportAssetFilter ] = None ,
193213 include_sent_back_labels : Optional [bool ] = None ,
194214 label_type_in : Optional [list [LabelType ]] = None ,
215+ export_type : ExportType = "latest_from_last_step" ,
195216 ):
196217 """Export project labels in YOLO v4 format.
197218
@@ -214,6 +235,14 @@ def yolo_v4(
214235 By default, only `DEFAULT` and `REVIEW` labels are exported.
215236 include_sent_back_labels: If True, the export will include the labels that
216237 have been sent back.
238+ export_type: Type of export. Options are:
239+ - `"latest_from_last_step"`: exports the latest label from the last workflow step
240+ (uses `latestLabels` field, supports multiple annotators).
241+ - `"latest_from_all_steps"`: exports latest labels from all workflow steps
242+ (useful for consensus projects with multiple annotators).
243+ - `"latest"`: exports the single latest label per asset (uses `latestLabel` field).
244+ - `"normal"`: exports all labels for each asset.
245+ Defaults to `"latest_from_last_step"`.
217246
218247 Returns:
219248 Export information or None if export failed.
@@ -228,6 +257,7 @@ def yolo_v4(
228257 label_type_in = label_type_in ,
229258 layout = layout ,
230259 fmt = "yolo_v4" ,
260+ export_type = export_type ,
231261 )
232262
233263 def yolo_v5 (
@@ -240,6 +270,7 @@ def yolo_v5(
240270 filter : Optional [ExportAssetFilter ] = None ,
241271 include_sent_back_labels : Optional [bool ] = None ,
242272 label_type_in : Optional [list [LabelType ]] = None ,
273+ export_type : ExportType = "latest_from_last_step" ,
243274 ):
244275 """Export project labels in YOLO v5 format.
245276
@@ -262,6 +293,14 @@ def yolo_v5(
262293 By default, only `DEFAULT` and `REVIEW` labels are exported.
263294 include_sent_back_labels: If True, the export will include the labels that
264295 have been sent back.
296+ export_type: Type of export. Options are:
297+ - `"latest_from_last_step"`: exports the latest label from the last workflow step
298+ (uses `latestLabels` field, supports multiple annotators).
299+ - `"latest_from_all_steps"`: exports latest labels from all workflow steps
300+ (useful for consensus projects with multiple annotators).
301+ - `"latest"`: exports the single latest label per asset (uses `latestLabel` field).
302+ - `"normal"`: exports all labels for each asset.
303+ Defaults to `"latest_from_last_step"`.
265304
266305 Returns:
267306 Export information or None if export failed.
@@ -276,6 +315,7 @@ def yolo_v5(
276315 label_type_in = label_type_in ,
277316 layout = layout ,
278317 fmt = "yolo_v5" ,
318+ export_type = export_type ,
279319 )
280320
281321 def yolo_v7 (
@@ -288,6 +328,7 @@ def yolo_v7(
288328 filter : Optional [ExportAssetFilter ] = None ,
289329 include_sent_back_labels : Optional [bool ] = None ,
290330 label_type_in : Optional [list [LabelType ]] = None ,
331+ export_type : ExportType = "latest_from_last_step" ,
291332 ):
292333 """Export project labels in YOLO v7 format.
293334
@@ -310,6 +351,14 @@ def yolo_v7(
310351 By default, only `DEFAULT` and `REVIEW` labels are exported.
311352 include_sent_back_labels: If True, the export will include the labels that
312353 have been sent back.
354+ export_type: Type of export. Options are:
355+ - `"latest_from_last_step"`: exports the latest label from the last workflow step
356+ (uses `latestLabels` field, supports multiple annotators).
357+ - `"latest_from_all_steps"`: exports latest labels from all workflow steps
358+ (useful for consensus projects with multiple annotators).
359+ - `"latest"`: exports the single latest label per asset (uses `latestLabel` field).
360+ - `"normal"`: exports all labels for each asset.
361+ Defaults to `"latest_from_last_step"`.
313362
314363 Returns:
315364 Export information or None if export failed.
@@ -324,6 +373,7 @@ def yolo_v7(
324373 label_type_in = label_type_in ,
325374 layout = layout ,
326375 fmt = "yolo_v7" ,
376+ export_type = export_type ,
327377 )
328378
329379 def yolo_v8 (
@@ -336,6 +386,7 @@ def yolo_v8(
336386 filter : Optional [ExportAssetFilter ] = None ,
337387 include_sent_back_labels : Optional [bool ] = None ,
338388 label_type_in : Optional [list [LabelType ]] = None ,
389+ export_type : ExportType = "latest_from_last_step" ,
339390 ):
340391 """Export project labels in YOLO v8 format.
341392
@@ -358,6 +409,14 @@ def yolo_v8(
358409 By default, only `DEFAULT` and `REVIEW` labels are exported.
359410 include_sent_back_labels: If True, the export will include the labels that
360411 have been sent back.
412+ export_type: Type of export. Options are:
413+ - `"latest_from_last_step"`: exports the latest label from the last workflow step
414+ (uses `latestLabels` field, supports multiple annotators).
415+ - `"latest_from_all_steps"`: exports latest labels from all workflow steps
416+ (useful for consensus projects with multiple annotators).
417+ - `"latest"`: exports the single latest label per asset (uses `latestLabel` field).
418+ - `"normal"`: exports all labels for each asset.
419+ Defaults to `"latest_from_last_step"`.
361420
362421 Returns:
363422 Export information or None if export failed.
@@ -372,6 +431,7 @@ def yolo_v8(
372431 label_type_in = label_type_in ,
373432 layout = layout ,
374433 fmt = "yolo_v8" ,
434+ export_type = export_type ,
375435 )
376436
377437 def pascal_voc (
@@ -383,6 +443,7 @@ def pascal_voc(
383443 filter : Optional [ExportAssetFilter ] = None ,
384444 include_sent_back_labels : Optional [bool ] = None ,
385445 label_type_in : Optional [list [LabelType ]] = None ,
446+ export_type : ExportType = "latest_from_last_step" ,
386447 ):
387448 """Export project labels in Pascal VOC format.
388449
@@ -403,6 +464,14 @@ def pascal_voc(
403464 By default, only `DEFAULT` and `REVIEW` labels are exported.
404465 include_sent_back_labels: If True, the export will include the labels that
405466 have been sent back.
467+ export_type: Type of export. Options are:
468+ - `"latest_from_last_step"`: exports the latest label from the last workflow step
469+ (uses `latestLabels` field, supports multiple annotators).
470+ - `"latest_from_all_steps"`: exports latest labels from all workflow steps
471+ (useful for consensus projects with multiple annotators).
472+ - `"latest"`: exports the single latest label per asset (uses `latestLabel` field).
473+ - `"normal"`: exports all labels for each asset.
474+ Defaults to `"latest_from_last_step"`.
406475
407476 Returns:
408477 Export information or None if export failed.
@@ -417,6 +486,7 @@ def pascal_voc(
417486 label_type_in = label_type_in ,
418487 layout = "merged" ,
419488 fmt = "pascal_voc" ,
489+ export_type = export_type ,
420490 )
421491
422492 def geojson (
@@ -428,6 +498,7 @@ def geojson(
428498 filter : Optional [ExportAssetFilter ] = None ,
429499 include_sent_back_labels : Optional [bool ] = None ,
430500 label_type_in : Optional [list [LabelType ]] = None ,
501+ export_type : ExportType = "latest_from_last_step" ,
431502 ):
432503 """Export project labels in GeoJSON format.
433504
@@ -448,6 +519,14 @@ def geojson(
448519 By default, only `DEFAULT` and `REVIEW` labels are exported.
449520 include_sent_back_labels: If True, the export will include the labels that
450521 have been sent back.
522+ export_type: Type of export. Options are:
523+ - `"latest_from_last_step"`: exports the latest label from the last workflow step
524+ (uses `latestLabels` field, supports multiple annotators).
525+ - `"latest_from_all_steps"`: exports latest labels from all workflow steps
526+ (useful for consensus projects with multiple annotators).
527+ - `"latest"`: exports the single latest label per asset (uses `latestLabel` field).
528+ - `"normal"`: exports all labels for each asset.
529+ Defaults to `"latest_from_last_step"`.
451530
452531 Returns:
453532 Export information or None if export failed.
@@ -462,6 +541,7 @@ def geojson(
462541 label_type_in = label_type_in ,
463542 layout = "merged" ,
464543 fmt = "geojson" ,
544+ export_type = export_type ,
465545 )
466546
467547 @typechecked
@@ -531,6 +611,7 @@ def _export(
531611 project_id : str ,
532612 single_file : bool = False ,
533613 with_assets : Optional [bool ] = True ,
614+ export_type : ExportType = "latest_from_last_step" ,
534615 ) -> Optional [list [dict [str , Union [list [str ], str ]]]]:
535616 """Export the project labels with the requested format into the requested output path.
536617
@@ -591,4 +672,5 @@ def _export(
591672 normalized_coordinates = normalized_coordinates ,
592673 label_type_in = list (label_type_in ) if label_type_in else None ,
593674 include_sent_back_labels = include_sent_back_labels ,
675+ export_type = export_type ,
594676 )
0 commit comments