From 0a81cabdc23f80252d9ae89b0a3e47107a961c20 Mon Sep 17 00:00:00 2001 From: Ramy1951 Date: Fri, 28 Jun 2024 11:48:09 +0400 Subject: [PATCH 1/4] Check for non empty export streams if GQL returns 0 as total size --- libs/labelbox/src/labelbox/schema/export_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/labelbox/src/labelbox/schema/export_task.py b/libs/labelbox/src/labelbox/schema/export_task.py index b00c9166a..d19a11a4d 100644 --- a/libs/labelbox/src/labelbox/schema/export_task.py +++ b/libs/labelbox/src/labelbox/schema/export_task.py @@ -807,7 +807,7 @@ def _get_metadata_header( variables = {"where": {"id": task_id}, "streamType": stream_type.value} res = client.execute(query, variables, error_log_key="errors") res = res["task"]["exportMetadataHeader"] - return _MetadataHeader(**res) if res else None + return _MetadataHeader(**res) if res and int(res["totalSize"]) > 0 and int(res["totalLines"]) > 0 else None def get_total_file_size(self, stream_type: StreamType) -> Union[int, None]: """Returns the total file size for a specific task.""" From bffe45032f8d7332683f4d38ecfd60602d4096b3 Mon Sep 17 00:00:00 2001 From: Ramy1951 Date: Fri, 28 Jun 2024 12:04:20 +0400 Subject: [PATCH 2/4] Added default value for totalSize and totalLines --- libs/labelbox/src/labelbox/schema/export_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/labelbox/src/labelbox/schema/export_task.py b/libs/labelbox/src/labelbox/schema/export_task.py index d19a11a4d..02e6c95de 100644 --- a/libs/labelbox/src/labelbox/schema/export_task.py +++ b/libs/labelbox/src/labelbox/schema/export_task.py @@ -807,7 +807,7 @@ def _get_metadata_header( variables = {"where": {"id": task_id}, "streamType": stream_type.value} res = client.execute(query, variables, error_log_key="errors") res = res["task"]["exportMetadataHeader"] - return _MetadataHeader(**res) if res and int(res["totalSize"]) > 0 and int(res["totalLines"]) > 0 else None + return _MetadataHeader(**res) if res and int(res.get("totalSize", 0)) > 0 and int(res.get("totalLines", 0) > 0) else None def get_total_file_size(self, stream_type: StreamType) -> Union[int, None]: """Returns the total file size for a specific task.""" From a2b17a6b4a24e21ed2b6435eca9c6c8c6327db93 Mon Sep 17 00:00:00 2001 From: Ramy1951 Date: Fri, 28 Jun 2024 12:08:10 +0400 Subject: [PATCH 3/4] Check for totalSize only --- libs/labelbox/src/labelbox/schema/export_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/labelbox/src/labelbox/schema/export_task.py b/libs/labelbox/src/labelbox/schema/export_task.py index 02e6c95de..a60b1874c 100644 --- a/libs/labelbox/src/labelbox/schema/export_task.py +++ b/libs/labelbox/src/labelbox/schema/export_task.py @@ -807,7 +807,7 @@ def _get_metadata_header( variables = {"where": {"id": task_id}, "streamType": stream_type.value} res = client.execute(query, variables, error_log_key="errors") res = res["task"]["exportMetadataHeader"] - return _MetadataHeader(**res) if res and int(res.get("totalSize", 0)) > 0 and int(res.get("totalLines", 0) > 0) else None + return _MetadataHeader(**res) if res and int(res.get("totalSize", 0)) > 0 else None def get_total_file_size(self, stream_type: StreamType) -> Union[int, None]: """Returns the total file size for a specific task.""" From 654c9d4b0176fe6bd4f486ba5a372e8cb7ab1321 Mon Sep 17 00:00:00 2001 From: Ramy1951 Date: Fri, 28 Jun 2024 12:11:44 +0400 Subject: [PATCH 4/4] test undo changes --- libs/labelbox/src/labelbox/schema/export_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/labelbox/src/labelbox/schema/export_task.py b/libs/labelbox/src/labelbox/schema/export_task.py index a60b1874c..b00c9166a 100644 --- a/libs/labelbox/src/labelbox/schema/export_task.py +++ b/libs/labelbox/src/labelbox/schema/export_task.py @@ -807,7 +807,7 @@ def _get_metadata_header( variables = {"where": {"id": task_id}, "streamType": stream_type.value} res = client.execute(query, variables, error_log_key="errors") res = res["task"]["exportMetadataHeader"] - return _MetadataHeader(**res) if res and int(res.get("totalSize", 0)) > 0 else None + return _MetadataHeader(**res) if res else None def get_total_file_size(self, stream_type: StreamType) -> Union[int, None]: """Returns the total file size for a specific task."""