Commit dda8b6a6 authored by Kento HASEGAWA's avatar Kento HASEGAWA

Improve the request status display

parent 26018bb4
......@@ -407,9 +407,16 @@ class Request(object):
idx = data['part_id']
print(idx)
if data['status'] == 'done':
self.solved[idx] += 1
self.solved[idx] = 1
else:
self.solved[idx] = -1
if all([v!=0 for v in self.solved]) and any([v<0 for v in self.solved]):
self.solved[-1] = -1
else:
self.solved[-1] = 1
if data['status'] == 'done':
self.solved[-1] = 1
else:
self.solved[-1] = -1
self.done_time = time.time()
def get_status(self):
......@@ -428,7 +435,7 @@ class Request(object):
status = 'Not connected'
else:
if len(self.solved) == 1:
status_mes = 'Waiting for response'
status_mes = 'Running'
elif len(self.solved) > 1:
counter = sum([v>0 for v in self.solved])
status_mes = f'{counter}/{len(self.solved)}'
......
......@@ -360,10 +360,16 @@ class Problem(object):
idx = int(data['part_id'])
self.partial_solutions[idx].append(data)
print([len(v)>0 for v in self.partial_solutions])
outdir = f"{self.solution_path}/{self.name}"
if not os.path.exists(outdir):
os.mkdir(outdir)
outpath = f"{outdir}/{data['request_id']}-{data['worker']}-p{data['part_id']}.json".replace(":", ".")
with open(outpath, 'w') as fp:
json.dump(self.get_dict(), fp, indent=4)
# print([len(v)>0 for v in self.partial_solutions])
if all([len(v)>0 for v in self.partial_solutions]):
# for v in self.partial_solutions:
# print(v[0])
return True
else:
return False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment