def dump_recon(recon): session = Session() Match.tally(session) session.commit() for match in Match.all(session): if match.judgement is not None: obj = Recon(match.subject, match.candidate, match.judgement) recon.write(obj.to_json()) recon.write('\n') recon.flush()
def load_entities(entities): session = Session() try: while True: entity = read_entity(entities) if entity is None: break Entity.save(session, entities.name, entity) except BrokenPipeError: pass session.commit()
def load_votes(votes): session = Session() try: while True: data = read_entity(votes) if data is None: break Vote.save(session, data.get('match_id'), data.get('user'), data.get('judgement')) except BrokenPipeError: pass Match.tally(session) session.commit()
def load_results(results): session = Session() try: while True: result = read_result(results) if result is None: break if result.subject is None or result.candidate is None: continue se = Entity.save(session, result.enricher.name, result.subject) ce = Entity.save(session, result.enricher.name, result.candidate) priority = max((se.priority, ce.priority)) Match.save(session, result.subject, result.candidate, score=result.score, priority=priority) session.flush() except BrokenPipeError: pass session.commit()
def before(): request.session = Session() request.user = '******' request.user = request.headers.get("X-Auth-Email") or request.user
def load_recon(recon): session = Session() for recon in Recon.from_file(recon): Match.save(session, recon.subject, recon.canonical, judgement=recon.judgement) session.commit()
def dedupe(threshold): session = Session() Entity.dedupe(session, threshold=threshold) session.commit()
def dump_votes(votes): session = Session() for vote in Vote.all(session): votes.write(vote.to_json()) votes.write('\n') votes.flush()