-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathbatches.py
More file actions
26 lines (21 loc) · 792 Bytes
/
batches.py
File metadata and controls
26 lines (21 loc) · 792 Bytes
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
class Batch(object):
def __init__(self, param_dict, client):
self.param_dict = param_dict
self.name = param_dict['name']
self.pending = None
self.completed = None
self.error = None
self.canceled = None
self.client = client
def __hash__(self):
return hash(self.name)
def __str__(self):
return 'Batch(name=%s)' % self.name
def __repr__(self):
return 'Batch(%s)' % self.param_dict
def finalize(self):
return self.client._postrequest("batches/%s/finalize" % self.name)
def get_status(self):
res = self.client._getrequest("batches/%s/status" % self.name)
for stat in ["pending", "completed", "error", "canceled"]:
setattr(self, stat, res.get(stat, 0))