Skip to content

Commit

Permalink
Change progress to a percent (#38)
Browse files Browse the repository at this point in the history
Currently progress is the value of terms computed, but this requires context to get anything meaningful from.
  • Loading branch information
CannonLock authored Aug 24, 2022
1 parent 5f1b4ef commit adcbb71
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/workers/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def km_work_all_vs_all(json: dict):
ab_results.append(res)

# sort by prediction score, descending
ab_results.sort(key=lambda res:
km.get_prediction_score(res['pvalue'], res['sort_ratio']),
ab_results.sort(key=lambda res:
km.get_prediction_score(res['pvalue'], res['sort_ratio']),
reverse=True)

ab_results = ab_results[:top_n]
Expand All @@ -121,7 +121,7 @@ def km_work_all_vs_all(json: dict):
'ab_pvalue': ab['pvalue'],
'ab_sort_ratio': ab['sort_ratio'],
'ab_pred_score': km.get_prediction_score(ab['pvalue'], ab['sort_ratio']),

'a_count': ab['len(a_term_set)'],
'b_count': ab['len(b_term_set)'],
'ab_count': ab['len(a_b_intersect)'],
Expand All @@ -142,23 +142,23 @@ def km_work_all_vs_all(json: dict):
abc_result['bc_pred_score'] = km.get_prediction_score(bc['pvalue'], bc['sort_ratio'])
abc_result['c_count'] = bc['len(b_term_set)']
abc_result['bc_count'] = bc['len(a_b_intersect)']

if return_pmids:
abc_result['bc_pmid_intersection'] = str(bc['pmid_intersection'])

# report number of C-terms complete
_update_job_status('progress', c_term_n + 1)
# report percentage of C-terms complete
_update_job_status('progress', round(((c_term_n + 1) / len(c_terms)), 2))
else:
# report number of A-terms complete
_update_job_status('progress', a_term_n + 1)
# report percentage of A-B pairs complete
_update_job_status('progress', round(((a_term_n + 1) / len(a_terms)), 2))

return_val.append(abc_result)

return return_val

def triple_miner_work(json: list):
_initialize_mongo_caching()

km_set = []

for query in json:
Expand Down Expand Up @@ -277,6 +277,6 @@ def _update_job_status(key, value):
if job is None:
print('error: tried to update job status, but could not find job')
return

job.meta[key] = value
job.save_meta()

0 comments on commit adcbb71

Please sign in to comment.