コード例 #1
0
def get_args_and_run():
    pr.set_up_logging()
    args = sys.argv + ["", ""]
    print("Args are" + str(args))
    _year = int(args[1])

    if args[2] and args[2] != "--rerun":
        main_ps_name = args[2]
        main_ps = importlib.import_module(main_ps_name)
    else:
        import aa_settings as main_ps

    have_org = False
    if args[2] == "--rerun" or args[3] == "--rerun":
        logging.info("Rerunning AA in " + str(_year) +
                     " with solved prices from ExchangeResults.csv")
        have_org = True
        try:
            shutil.move(
                main_ps.scendir + "/" + str(_year) + "/ExchangeResultsI.csv",
                main_ps.scendir + "/" + str(_year) +
                "/ExchangeResultsI-orig.csv")
        except FileNotFoundError:
            have_org = False
        shutil.copyfile(
            main_ps.scendir + "/" + str(_year) + "/ExchangeResults.csv",
            main_ps.scendir + "/" + str(_year) + "/ExchangeResultsI.csv")

    _skimyear = pr.get_skim_year(_year, main_ps.skimyears)
    skimfilename = main_ps.skim_fname.format(yr=_skimyear)

    aa = StandardAARunner()
    aa.popsyn.start()

    try:
        logging.info("Running aa in year " + str(_year))
        # noinspection PyTypeChecker
        aa.run_aa(main_ps,
                  _year,
                  skimfilename,
                  _skimyear,
                  dbyear=None,
                  load=False)

        if have_org:
            shutil.move(
                main_ps.scendir + "/" + str(_year) +
                "/ExchangeResultsI-orig.csv",
                main_ps.scendir + "/" + str(_year) + "/ExchangeResultsI.csv")
    finally:
        aa.popsyn.stop()
コード例 #2
0
ファイル: run_aa_allyears.py プロジェクト: SANDAG/SRF
        if ps.run_demand:
            project_code.after_aa(year, ps=ps)
        year = year + 1


def _pull(seq: List[str], item: str) -> bool:
    if item in seq:
        seq.remove(item)
        return True
    else:
        return False


if __name__ == "__main__":
    pr.set_up_logging()
    args = [arg.lower() for arg in sys.argv]
    resume = _pull(args, "resume")
    if len(args) > 1:
        ps_name = args[-1]
    else:
        ps_name = "aa_settings"

    main_ps = importlib.import_module(ps_name)

    if resume:
        main_ps.resume_run = True

    logging.info("Running with settings module {!r}".format(ps_name))
    # noinspection PyTypeChecker
    main(main_ps)