Skip to content

Commit 6d6462c

Browse files
author
Matt Sokoloff
committed
fix bug when error is reported
1 parent e4be7a3 commit 6d6462c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

labelbox/schema/task.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ def result(self) -> Dict[str, Any]:
9090
if self.status == "COMPLETE":
9191
return self._fetch_remote(self.result_url)
9292
elif self.status == "FAILED":
93-
raise Exception(f"Job failed. Errors : {self.errors()}")
93+
errors = self.errors
94+
message = errors.get('message') or errors
95+
raise Exception(f"Job failed. Errors : {message}")
9496
else:
9597
raise Exception("Job state IN_PROGRESS. Result not available.")
9698

tests/integration/test_task.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pytest
2+
13
from labelbox import DataRow
24
from labelbox.schema.data_row_metadata import DataRowMetadataField
35

@@ -24,6 +26,10 @@ def test_task_errors(dataset, image_url):
2426
assert task.status == "FAILED"
2527
assert task.errors is not None
2628
assert 'message' in task.errors
29+
with pytest.raises(Exception) as exc_info:
30+
task.result
31+
assert str(exc_info.value).startswith(
32+
"Job failed. Errors : Failed to validate the metadata")
2733

2834

2935
def test_task_success(dataset, image_url):

0 commit comments

Comments
 (0)