@@ -47,6 +47,7 @@ class ExportParams(NamedTuple):
4747 asset_filter_kwargs : Optional [Dict [str , object ]]
4848 normalized_coordinates : Optional [bool ]
4949 label_type_in : Optional [List [str ]]
50+ include_sent_back_labels : Optional [bool ]
5051
5152
5253class AbstractExporter (ABC ): # pylint: disable=too-many-instance-attributes
@@ -79,6 +80,7 @@ def __init__(
7980 self .asset_filter_kwargs = export_params .asset_filter_kwargs
8081 self .normalized_coordinates = export_params .normalized_coordinates
8182 self .label_type_in = export_params .label_type_in or ["DEFAULT" , "REVIEW" ]
83+ self .include_sent_back_labels = export_params .include_sent_back_labels
8284
8385 self .project = kili .kili_api_gateway .get_project (
8486 self .project_id , ["jsonInterface" , "inputType" , "title" , "description" , "id" ]
@@ -273,19 +275,28 @@ def _format_json_response(label: Dict) -> Dict:
273275
274276 def preprocess_assets (self , assets : List [Dict ]) -> List [Dict ]:
275277 """Format labels in the requested format, and filter out autosave labels."""
278+ include_sent_back_labels = self .include_sent_back_labels
276279 assets_in_format = []
277280 for asset in assets :
278281 if "labels" in asset :
279282 labels_of_asset = []
280283 for label in asset ["labels" ]:
281284 clean_label = AbstractExporter ._format_json_response (label )
282285 labels_of_asset .append (clean_label )
286+ if not include_sent_back_labels :
287+ labels_of_asset = list (
288+ filter (
289+ lambda label : label ["isSentBackToQueue" ] is False , labels_of_asset
290+ )
291+ )
283292 asset ["labels" ] = labels_of_asset
293+ assets_in_format .append (asset )
284294 if "latestLabel" in asset :
285295 label = asset ["latestLabel" ]
286296 if label is not None :
287297 clean_label = AbstractExporter ._format_json_response (label )
288298 asset ["latestLabel" ] = clean_label
289- assets_in_format .append (asset )
299+ if include_sent_back_labels or asset ["latestLabel" ]["isSentBackToQueue" ] is False :
300+ assets_in_format .append (asset )
290301
291302 return AbstractExporter ._filter_out_autosave_labels (assets_in_format )
0 commit comments