configure_logging() parser = argparse.ArgumentParser(description='Pull data from FSRS Feed') parser.add_argument('-p', '--procurement', action='store_true', help="Load just procurement awards") parser.add_argument('-g', '--grants', action='store_true', help="Load just grant awards") parser.add_argument('-i', '--ids', type=int, nargs='+', help="Single or list of FSRS ids to pull from the FSRS API ") with create_app().app_context(): logger.info("Begin loading FSRS data from FSRS API") sess = GlobalDB.db().session args = parser.parse_args() # Setups state mapping for deriving state name config_state_mappings(sess, init=True) if not config_valid(): logger.error("No config for broker/fsrs/[service]/wsdl") sys.exit(1) elif args.procurement and args.grants and args.ids: logger.error("Cannot run both procurement and grant loads when specifying FSRS ids") else: # Regular FSRS data load, starts where last load left off if len(sys.argv) <= 1: awards = ['Starting'] while len(awards) > 0: procs = fetch_and_replace_batch(sess, PROCUREMENT) grants = fetch_and_replace_batch(sess, GRANT) awards = procs + grants log_fsrs_counts(awards) elif args.procurement and args.ids:
type=int, help="Load procurement awards up to this id") parser.add_argument('-max_g', '--max_grant_id', type=int, help="Load grant awards up to this id") with create_app().app_context(): logger.info("Begin backilling FSRS data from FSRS API") sess = GlobalDB.db().session args = parser.parse_args() # Setups state mapping for deriving state name config_state_mappings(sess, init=True) if not config_valid(): logger.error("No config for broker/fsrs/[service]/wsdl") sys.exit(1) elif not (args.max_procurement_id or args.max_grant_id): logger.error( "Must run one either/both of procurement and grant backfills") sys.exit(1) else: next_proc_id = args.min_procurement_id max_proc_id = args.max_procurement_id if args.max_procurement_id else 0 next_grant_id = args.min_grant_id max_grant_id = args.max_grant_id if args.max_grant_id else 0 if max_grant_id and (max_grant_id - next_grant_id) < 1 or next_grant_id < 0: logger.error(