Skip to content
Snippets Groups Projects
Commit 640c636a authored by Michelle Weidling's avatar Michelle Weidling :blowfish:
Browse files

refactor

parent 76df4ec6
No related branches found
No related tags found
No related merge requests found
Pipeline #509176 passed
......@@ -10,7 +10,7 @@ def remove_mongodb_id_from_result(json_data, result_type) -> list:
purged_list = []
for obj in json_data:
d = dict(obj)
print(d)
remove_key_from_dict(d)
del d['_id']
if result_type == 'gt':
d = d['gt_workspace']
......@@ -27,4 +27,3 @@ def remove_key_from_dict(d: dict) -> dict:
del d[key]
else:
remove_key_from_dict(d[key])
return d
......@@ -20,11 +20,8 @@ def get_all_runs(coll: collection.Collection):
"""
cursor = coll.find({'eval_workflow_id': {'$exists': True}})
json_data = json.loads(json_util.dumps(cursor))
print(json_data)
print('+++++++++++++++++++++++++++++++++++++')
purged = remove_key_from_dict(json_data)
return remove_mongodb_id_from_result(purged, 'run')
return remove_mongodb_id_from_result(json_data, 'run')
def get_all_latest_runs(coll: collection.Collection):
"""
......@@ -74,9 +71,7 @@ def get_all_runs_by_gt(coll: collection.Collection,
cursor = coll.find({'metadata.gt_workspace.id': gt_regex})
json_data = json.loads(json_util.dumps(cursor))
purged = remove_key_from_dict(json_data)
return remove_mongodb_id_from_result(purged, 'run')
return remove_mongodb_id_from_result(json_data, 'run')
def get_all_runs_by_gt_and_wf(coll: collection.Collection,
......@@ -100,9 +95,8 @@ def get_all_runs_by_gt_and_wf(coll: collection.Collection,
cursor = coll.find({'$and': [{'metadata.gt_workspace.id': gt_regex},
{'metadata.ocr_workflow.id': wf_regex}]})
json_data = json.loads(json_util.dumps(cursor))
purged = remove_key_from_dict(json_data)
return remove_mongodb_id_from_result(purged, 'run')
return remove_mongodb_id_from_result(json_data, 'run')
def get_latest_runs(coll: collection.Collection,
......@@ -126,9 +120,8 @@ def get_latest_runs(coll: collection.Collection,
{'metadata.ocr_workflow.id': wf_regex},
{'metadata.timestamp': compile(closest_timestamp)}]})
latest_run_json = json.loads(json_util.dumps(latest_run))
purged = remove_key_from_dict(latest_run_json)
return remove_mongodb_id_from_result(purged, 'run')
return remove_mongodb_id_from_result(latest_run_json, 'run')
def get_latest_runs_per_gt(coll: collection.Collection,
......@@ -147,8 +140,7 @@ def get_latest_runs_per_gt(coll: collection.Collection,
latest_run = coll.find({'$and': [{'metadata.gt_workspace.id': gt_regex},
{'metadata.timestamp': compile(closest_timestamp)}]})
latest_run_json = json.loads(json_util.dumps(latest_run))
purged = remove_key_from_dict(latest_run_json)
return remove_mongodb_id_from_result(purged, 'run')
return remove_mongodb_id_from_result(latest_run_json, 'run')
def post_new_result(coll: collection.Collection,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment