Skip to content

Commit fad9295

Browse files
authored
[SDK-567] Fix returned type in ExportTask instance representation (#1401)
1 parent 6e6266b commit fad9295

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

labelbox/schema/export_task.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from enum import Enum
44
from functools import lru_cache
55
from io import TextIOWrapper
6+
import json
67
from pathlib import Path
78
from typing import (
89
Callable,
@@ -470,10 +471,23 @@ def __init__(self, task: Task) -> None:
470471
self._task = task
471472

472473
def __repr__(self):
473-
return self._task.__repr__()
474+
return f"<ExportTask ID: {self.uid}>" if getattr(
475+
self, "uid", None) else "<ExportTask>"
474476

475477
def __str__(self):
476-
return self._task.__str__()
478+
properties_to_include = [
479+
"completion_percentage",
480+
"created_at",
481+
"metadata",
482+
"name",
483+
"result",
484+
"status",
485+
"type",
486+
"uid",
487+
"updated_at",
488+
]
489+
props = {prop: getattr(self, prop) for prop in properties_to_include}
490+
return f"<ExportTask {json.dumps(props, indent=4, default=str)}>"
477491

478492
def __eq__(self, other):
479493
return self._task.__eq__(other)
@@ -511,6 +525,16 @@ def status(self):
511525
"""Returns the status of the task."""
512526
return self._task.status
513527

528+
@property
529+
def metadata(self):
530+
"""Returns the metadata of the task."""
531+
return self._task.metadata
532+
533+
@property
534+
def result(self):
535+
"""Returns the result of the task."""
536+
return self._task.result_url
537+
514538
@property
515539
def completion_percentage(self):
516540
"""Returns the completion percentage of the task."""

0 commit comments

Comments
 (0)