From dda8b6a6100f157331f479a48eb8940f739ff794 Mon Sep 17 00:00:00 2001 From: Kento HASEGAWA Date: Mon, 26 Aug 2019 20:04:10 +0900 Subject: [PATCH] Improve the request status display --- roles/host.py | 13 ++++++++++--- utils/data.py | 12 +++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/roles/host.py b/roles/host.py index 592eeaf..0cad37d 100644 --- a/roles/host.py +++ b/roles/host.py @@ -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)}' diff --git a/utils/data.py b/utils/data.py index 37e7037..1049a1f 100644 --- a/utils/data.py +++ b/utils/data.py @@ -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 -- 2.22.0