-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathtasks.py
More file actions
88 lines (67 loc) · 2.29 KB
/
tasks.py
File metadata and controls
88 lines (67 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from enum import Enum
class TaskType(Enum):
"""Task Type List"""
Annotation = "annotation"
Categorization = "categorization"
Comparison = "comparison"
CuboidAnnotation = "cuboidannotation"
DataCollection = "datacollection"
DocumentModel = "documentmodel"
DocumentTranscription = "documenttranscription"
ImageAnnotation = "imageannotation"
LaneAnnotation = "laneannotation"
LidarAnnotation = "lidarannotation"
LidarLinking = "lidarlinking"
LidarSegmentation = "lidarsegmentation"
LidarTopdown = "lidartopdown"
LineAnnotation = "lineannotation"
NamedEntityRecognition = "namedentityrecognition"
PointAnnotation = "pointannotation"
PolygonAnnotation = "polygonannotation"
SegmentAnnotation = "segmentannotation"
Transcription = "transcription"
TextCollection = "textcollection"
VideoAnnotation = "videoannotation"
VideoBoxAnnotation = "videoboxannotation"
VideoPlaybackAnnotation = "videoplaybackannotation"
VideoCuboidAnnotation = "videocuboidannotation"
class TaskReviewStatus(Enum):
"""Customer Audit Status of Task"""
Accepted = "accepted"
Fixed = "fixed"
Commented = "commented"
Rejected = "rejected"
class TaskStatus(Enum):
"""Status of Task"""
Pending = "pending"
Completed = "completed"
Canceled = "canceled"
class Task:
"""Task class, containing task information."""
def __init__(self, json, client):
self._client = client
self._json = json
self.id = json["task_id"]
def __getattr__(self, name):
if name in self._json:
return self._json[name]
raise AttributeError(f"'{type(self).__name__}' object has no attribute {name}")
def __hash__(self):
return hash(self.id)
def __str__(self):
return f"Task(id={self.id})"
def __repr__(self):
return f"Task({self._json})"
def as_dict(self):
"""Returns object details as a dictionary
`Task.as_dict()['params']`
Returns:
Dict with object content
"""
return self._json
def refresh(self):
"""Refreshes the task details."""
self._json = self._client.get_task(self.id).as_dict()
def cancel(self):
"""Cancels the task"""
self._client.cancel_task(self.id)