def get_ores_data_dgf_from_api(rev_ids, context='enwiki'): session = ores_api.Session('https://ores.wikimedia.org', user_agent='newcomerquality', batch_size=50, parallel_requests=4, retries=2) scores = session.score(context, ('damaging', 'goodfaith'), rev_ids) return scores
def main(): args = docopt.docopt(__doc__) rev_ids = (int(line) for line in sys.stdin) session = api.Session(args['<host>'], user_agent="Load testing <*****@*****.**>") for score in session.score(args['<context>'], args['<model>'], rev_ids): print(score, flush=True)
def test_session(): session1 = api.Session("myhost", session=FakeSession()) scores = list(session1.score("context", ["foo", "bar"], range(0, 100))) assert len(scores) == 100 assert scores[0] == { "foo": { "score": "my score" }, "bar": { "score": "my score" } }
def run(ores_host, context, model_names, rev_docs, verbose): session = api.Session(ores_host, user_agent="*****@*****.**") rev_ids = [d['rev_id'] for d in rev_docs] scores = session.score(context, model_names, rev_ids) for rev_doc, score_doc in zip(rev_docs, scores): rev_doc['score'] = score_doc json.dump(rev_doc, sys.stdout) sys.stdout.write("\n") if verbose: sys.stderr.write(".") sys.stderr.flush()
def test_base_error(): session2 = api.Session("myhost", session=FakeSession(error_out=True)) scores = list(session2.score("context", ["foo", "bar"], range(0, 100))) assert len(scores) == 100 assert scores[0]['foo']['error'] == \ {'code': 'an error', 'message': 'a message'}