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

first draft for not considering CPU

parent cf76e763
No related branches found
No related tags found
No related merge requests found
Pipeline #508907 passed
......@@ -16,3 +16,13 @@ def remove_mongodb_id_from_result(json_data, result_type) -> list:
d = d['gt_workspace']
purged_list.append(d)
return purged_list
def remove_key_from_dict(d: dict, tbr_key: str) -> None:
"""
This function removes keys with the value of null from the result.
"""
for key in list(d.keys()):
if key == tbr_key and d[key] == None:
del d[key]
else:
remove_key_from_dict(d[key], tbr_key)
......@@ -8,7 +8,7 @@ from re import compile, Pattern
from bson import json_util
from pymongo import collection
from model import Model
from commons import remove_mongodb_id_from_result
from commons import remove_mongodb_id_from_result, remove_key_from_dict
from gt import get_all_gt
from workflows import get_all_workflows
......@@ -20,8 +20,9 @@ def get_all_runs(coll: collection.Collection):
"""
cursor = coll.find({'eval_workflow_id': {'$exists': True}})
json_data = json.loads(json_util.dumps(cursor))
purged = remove_key_from_dict(json_data, 'cpu')
return remove_mongodb_id_from_result(json_data, 'run')
return remove_mongodb_id_from_result(purged, 'run')
def get_all_latest_runs(coll: collection.Collection):
"""
......@@ -71,7 +72,9 @@ 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))
return remove_mongodb_id_from_result(json_data, 'run')
purged = remove_key_from_dict(json_data, 'cpu')
return remove_mongodb_id_from_result(purged, 'run')
def get_all_runs_by_gt_and_wf(coll: collection.Collection,
......@@ -95,7 +98,9 @@ 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))
return remove_mongodb_id_from_result(json_data, 'run')
purged = remove_key_from_dict(json_data, 'cpu')
return remove_mongodb_id_from_result(purged, 'run')
def get_latest_runs(coll: collection.Collection,
......@@ -119,7 +124,9 @@ 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))
return remove_mongodb_id_from_result(latest_run_json, 'run')
purged = remove_key_from_dict(latest_run_json, 'cpu')
return remove_mongodb_id_from_result(purged, 'run')
def get_latest_runs_per_gt(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