-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtask.py
More file actions
84 lines (55 loc) · 1.3 KB
/
task.py
File metadata and controls
84 lines (55 loc) · 1.3 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
from ..regular.regular import refresh_from_dict
from diffgram.file.file import File
class Task():
"""
"""
def __init__(
self,
client = None,
id = None):
self.client = client
self.id = id
self.file = None
def __factory_create_object_from_json(task_in_json):
"""
In the current context a user doesn't create a new
File directly, the system creates a file at import
and/or when copying / operating on a file.
"""
task = Task()
refresh_from_dict(task, task_in_json)
if task.file:
task.file = File.new(
client = self.client,
file_json = task.file)
return task
def update():
"""
Update task, ie meta information
"""
raise NotImplemented
def update_file(
self,
frame_packet_map: dict = None,
):
# TODO could abstract code block L225 file_constructor
raise NotImplemented
def serialize(self):
return {
'id' : self.id
}
def get_by_id(self, id: int):
"""
"""
endpoint = "/api/v1/task"
spec_dict = {
'task_id': id,
'builder_or_trainer_mode': 'builder'
}
response = self.client.session.post(
self.client.host + endpoint,
json = spec_dict)
self.client.handle_errors(response)
response_json = response.json()
return Task.__factory_create_object_from_json(
task_in_json = response_json.get('task'))