lundi 9 décembre 2019

Passing execution context without telescope signatures

I have a series of functions to evaluate a set of docs against ground truth docs. It goes down from docs to their fields:

def eval_docs(preds, trues, docs_ids, fields, match, match_kwargs)
def eval_doc(pred, true, fields, doc_id, match, **match_kwargs)
def eval_fields(preds, trues, fields, doc_id, match, **match_kwargs)
def eval_field(pred, true, field, doc_id, match, **match_kwargs)

Information about docs_ids, doc_id, fields, field is passed down only for logging purpose, because the last method logs it.

DEBUG: {'docId': 'doc1', 'field': '/items/0/key2', 'result': 'fp', 'expected': None, 'predicted': 'value3'}

This information is not used in any other way. This results in telescope method signatures that makes reading the code more harder.

Is there a better way pass the information to logging?

Ideally, I would expect signatures like:

def eval_docs(preds, trues, match, match_kwargs)
def eval_doc(pred, true, match, **match_kwargs)
def eval_fields(preds, trues, **match_kwargs)
def eval_field(pred, true, match, **match_kwargs)

Aucun commentaire:

Enregistrer un commentaire