From 934fd3f5e5a6f7e03ed538b09bd71eb41410876e Mon Sep 17 00:00:00 2001 From: Samuel Fendell Date: Wed, 3 Apr 2024 13:55:07 -0700 Subject: [PATCH] [PLT-51] Avoid showing "error present" warning inappropriately. --- labelbox/schema/task.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/labelbox/schema/task.py b/labelbox/schema/task.py index 2382978e8..977f7d4fa 100644 --- a/labelbox/schema/task.py +++ b/labelbox/schema/task.py @@ -64,6 +64,15 @@ def refresh(self) -> None: if self.is_creation_task(): self.errors_url = self.result_url + def has_errors(self) -> bool: + if self.type == "export-data-rows": + # self.errors fetches the error content. + # This first condition prevents us from downloading the content for v2 exports + return bool(self.errors_url or self.errors) + if self.is_creation_task(): + return bool(self.failed_data_rows) + return self.status == "FAILED" + def wait_till_done(self, timeout_seconds: float = 300.0, check_frequency: float = 2.0) -> None: @@ -79,9 +88,7 @@ def wait_till_done(self, "Expected check frequency to be two seconds or more") while timeout_seconds > 0: if self.status != "IN_PROGRESS": - # self.errors fetches the error content. - # This first condition prevents us from downloading the content for v2 exports - if self.errors_url is not None or self.errors is not None: + if self.has_errors(): logger.warning( "There are errors present. Please look at `task.errors` for more details" )