Skip to content

Commit f7022f7

Browse files
committed
Refactor to use fewer db calls
1 parent 999e710 commit f7022f7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

upload_biomek_logs.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,20 @@ def main(args):
7373
inst_id = conf["inst_id"]
7474
biomek_logs_db = couch['biomek_logs']
7575
db_view_run_finished = biomek_logs_db.view('names/run_finished')
76+
run_finished_dict = {}
77+
for row in db_view_run_finished:
78+
run_finished_dict[(row.key[0], row.key[1])] = (row.value, row.id)
7679

7780
log_files_list = os.listdir(args.log_file_path)
7881
logs_to_create = []
7982
logs_to_update = []
8083
save_docs = []
8184
for fname in log_files_list:
8285
if fname.startswith("Errors"):
83-
if (not db_view_run_finished[[fname, inst_id]]):
86+
if ((fname, inst_id) not in run_finished_dict):
8487
logs_to_create.append(fname)
85-
elif (db_view_run_finished[[fname, inst_id]].rows[0].value == False):
86-
logs_to_update.append(db_view_run_finished[[fname, inst_id]].rows[0].id)
88+
elif (run_finished_dict[(fname, inst_id)][0] == False):
89+
logs_to_update.append(run_finished_dict[(fname, inst_id)][1])
8790

8891

8992
for fname in logs_to_create:

0 commit comments

Comments
 (0)