def run_update(parsed_args): update = update_registry.get(parsed_args.fn) start = time() update.run(**vars(parsed_args)) db.session.remove() logger.info("finished update in {} secconds".format(elapsed(start)))
def run(parsed_args, job_type): start = time() if job_type in ("normal", "hybrid"): update = update_registry.get("WeeklyStats." + process_name(job_type)) if parsed_args.doi: parsed_args.id = clean_doi(parsed_args.doi) parsed_args.doi = None else: update = update_registry.get("DateRange.get_events") update.run(**vars(parsed_args)) logger.info("finished update in {} seconds".format(elapsed(start))) if job_type in ("normal", "hybrid"): from event import CedEvent my_event = CedEvent.query.get(parsed_args.id) pprint(my_event)
def run(parsed_args, job_type): start = time() if job_type in ("normal", "hybrid"): update = update_registry.get("Pub."+process_name(job_type)) if parsed_args.doi: parsed_args.id = normalize_doi(parsed_args.doi) parsed_args.doi = None else: update = update_registry.get("DateRange.get_unpaywall_events") # update = update_registry.get("DateRange.get_pmh_events") update.run(**vars(parsed_args)) logger.info(u"finished update in {} seconds".format(elapsed(start))) resp = None if job_type in ("normal", "hybrid"): my_pub = Pub.query.get(parsed_args.id) resp = my_pub.response_jsonb pprint(resp) return resp
def run(parsed_args, job_type): start = time() if job_type in ("normal", "hybrid"): update = update_registry.get("Pub."+process_name(job_type)) if parsed_args.doi: parsed_args.id = clean_doi(parsed_args.doi) parsed_args.doi = None else: update = update_registry.get("DateRange.get_unpaywall_events") # update = update_registry.get("DateRange.get_pmh_events") update.run(**vars(parsed_args)) logger.info(u"finished update in {} seconds".format(elapsed(start))) resp = None if job_type in ("normal", "hybrid"): my_pub = Pub.query.get(parsed_args.id) resp = my_pub.response_jsonb pprint(resp) return resp
def run_update(parsed_args): update = update_registry.get(parsed_args.fn) start = time() update.run( use_rq=parsed_args.rq, obj_id=parsed_args.id, # is empty unless updating just one row min_id=parsed_args.after, # is empty unless minimum id num_jobs=parsed_args.limit, chunk_size=parsed_args.chunk ) db.session.remove() print "finished update in {}sec".format(elapsed(start))
def run_update(parsed_args): update = update_registry.get(parsed_args.fn) start = time() #convenience method for handling an doi if parsed_args.doi: from pub import Pub from util import clean_doi my_pub = db.session.query(Pub).filter(Pub.id==clean_doi(parsed_args.doi)).first() parsed_args.id = my_pub.id logger.info(u"Got database hit for this doi: {}".format(my_pub.id)) update.run(**vars(parsed_args)) db.session.remove() logger.info(u"finished update in {} secconds".format(elapsed(start)))
def run_update(parsed_args): update = update_registry.get(parsed_args.fn) start = time() #convenience method for handling an doi if parsed_args.doi: from pub import Pub from util import clean_doi my_pub = db.session.query(Pub).filter( Pub.id == clean_doi(parsed_args.doi)).first() parsed_args.id = my_pub.id logger.info(u"Got database hit for this doi: {}".format(my_pub.id)) update.run(**vars(parsed_args)) db.session.remove() logger.info(u"finished update in {} secconds".format(elapsed(start)))
def run_update(parsed_args): update = update_registry.get(parsed_args.fn) start = time() #convenience method for handling an orcid if parsed_args.orcid: from models.person import Person my_person = db.session.query(Person).filter( Person.orcid_id == parsed_args.orcid).first() parsed_args.id = my_person.id update.run( use_rq=parsed_args.rq, obj_id=parsed_args.id, # is empty unless updating just one row min_id=parsed_args.after, # is empty unless minimum id num_jobs=parsed_args.limit, chunk_size=parsed_args.chunk) db.session.remove() print "finished update in {}sec".format(elapsed(start))
def run_update(parsed_args): update = update_registry.get(parsed_args.fn) start = time() #convenience method for handling an orcid if parsed_args.orcid: from models.person import Person my_person = db.session.query(Person).filter(Person.orcid_id==parsed_args.orcid).first() parsed_args.id = my_person.id update.run( use_rq=parsed_args.rq, obj_id=parsed_args.id, # is empty unless updating just one row min_id=parsed_args.after, # is empty unless minimum id num_jobs=parsed_args.limit, chunk_size=parsed_args.chunk ) db.session.remove() print "finished update in {}sec".format(elapsed(start))
def run_update(parsed_args): update = update_registry.get(parsed_args.fn) start = time() #convenience method for handling an doi if parsed_args.doi: from models.doi import Publication my_pub = db.session.query(Publication).filter( Publication.doi == parsed_args.doi).first() parsed_args.id = my_pub.id print u"Got database for this doi: {}".format(my_pub.id) update.run( use_rq=parsed_args.rq, obj_id=parsed_args.id, # is empty unless updating just one row min_id=parsed_args.after, # is empty unless minimum id num_jobs=parsed_args.limit, chunk_size=parsed_args.chunk) db.session.remove() print "finished update in {}sec".format(elapsed(start))
# for everything parser.add_argument('fn', type=str, help="what function you want to run") # comment back in when and if we support running anything via rq # parser.add_argument('--no-rq', action="store_true", help="do jobs in this thread") # just for updating lots parser.add_argument('--limit', "-l", nargs="?", type=int, help="how many jobs to do") parser.add_argument('--chunk', "-ch", nargs="?", type=int, help="how many to take off db at once") # just for updating one parser.add_argument('--id', nargs="?", type=str, help="id of the one thing you want to update") # parse and run parsed = parser.parse_args() update = update_registry.get(parsed.fn) start = time() update.run( no_rq=True, # force to no-rq always now. was parsed.no_rq obj_id=parsed.id, # is empty unless updating just one row num_jobs=parsed.limit, chunk_size=parsed.chunk ) db.session.remove() print "finished update in {}sec".format(elapsed(start))
# for everything parser.add_argument('fn', type=str, help="what function you want to run") parser.add_argument('--rq', action="store_true", default=False, help="do jobs in this thread") # just for updating lots parser.add_argument('--limit', "-l", nargs="?", type=int, help="how many jobs to do") parser.add_argument('--chunk', "-ch", nargs="?", type=int, help="how many to take off db at once") # just for updating one parser.add_argument('--id', nargs="?", type=str, help="id of the one thing you want to update") parser.add_argument('--after', nargs="?", type=str, help="minimum id or id start, ie 0000-0001") # parse and run parsed = parser.parse_args() update = update_registry.get(parsed.fn) start = time() update.run( use_rq=parsed.rq, obj_id=parsed.id, # is empty unless updating just one row min_id=parsed.after, # is empty unless minimum id num_jobs=parsed.limit, chunk_size=parsed.chunk ) db.session.remove() print "finished update in {}sec".format(elapsed(start))