def test_restart_simple_run(self): _do_run_simple_test_run(self, self.temp_dir, self.config, end_year=1983) runs_manager = RunManager(self.config) config = _get_run_config(temp_dir=self.temp_dir) runs_manager.update_environment_variables(run_resources=config) run_activity = runs_manager.services_db.get_table("run_activity") s = select([func.max(run_activity.c.run_id)]) run_id = runs_manager.services_db.execute(s).fetchone()[0] s = select([run_activity.c.status], whereclause=run_activity.c.run_id == run_id) status = runs_manager.services_db.execute(s).fetchone()[0] expected = "done" self.assertEqual(status, expected) runs_manager.restart_run(run_id, restart_year=1981, project_name="eugene_gridcell", skip_urbansim=False) s = select([run_activity.c.status], whereclause=run_activity.c.run_id == run_id) status = runs_manager.services_db.execute(s).fetchone()[0] expected = "done" self.assertEqual(status, expected) # Restaring without running urbansim should not re-run that year. # TODO: test that no models are run this time. runs_manager.restart_run(run_id, restart_year=1982, project_name="eugene_gridcell", skip_urbansim=True) s = select([run_activity.c.status], whereclause=run_activity.c.run_id == run_id) status = runs_manager.services_db.execute(s).fetchone()[0] expected = "done" self.assertEqual(status, expected) self.cleanup_test_run()
def main(option_group=None, args=None): if option_group is None: option_group = RestartRunOptionGroup() parser = option_group.parser if args is None: options, args = option_group.parse() else: options, _args = option_group.parse() run_manager = RunManager( option_group.get_services_database_configuration(options)) run_as_multiprocess = not options.run_as_single_process if len(args) < 2: parser.print_help() else: run_id, year = (int(args[0]), int(args[1])) end_year = int( options.end_year) if options.end_year is not None else None run_manager.restart_run(run_id, year, options.project_name, end_year=end_year, skip_urbansim=options.skip_urbansim, create_baseyear_cache_if_not_exists=options. create_baseyear_cache_if_not_exists, skip_cache_cleanup=options.skip_cache_cleanup, run_as_multiprocess=run_as_multiprocess)
def main(option_group=None, args=None): if option_group is None: option_group = RestartRunOptionGroup() parser = option_group.parser if args is None: options, args = option_group.parse() else: options, _args = option_group.parse() run_manager = RunManager(option_group.get_services_database_configuration(options)) run_as_multiprocess = not options.run_as_single_process if len(args) < 2: parser.print_help() else: run_id, year = (int(args[0]), int(args[1])) end_year = int(options.end_year) if options.end_year is not None else None run_manager.restart_run(run_id, year, options.project_name, end_year=end_year, skip_urbansim=options.skip_urbansim, create_baseyear_cache_if_not_exists=options.create_baseyear_cache_if_not_exists, skip_cache_cleanup=options.skip_cache_cleanup, run_as_multiprocess=run_as_multiprocess )
def test_restart_simple_run(self): _do_run_simple_test_run(self, self.temp_dir, self.config, end_year=1983) runs_manager = RunManager(self.config) config = _get_run_config(temp_dir=self.temp_dir) runs_manager.update_environment_variables(run_resources=config) run_activity = runs_manager.services_db.get_table('run_activity') s = select([func.max(run_activity.c.run_id)]) run_id = runs_manager.services_db.execute(s).fetchone()[0] s = select([run_activity.c.status], whereclause=run_activity.c.run_id == run_id) status = runs_manager.services_db.execute(s).fetchone()[0] expected = 'done' self.assertEqual(status, expected) runs_manager.restart_run(run_id, restart_year=1981, project_name='eugene_gridcell', skip_urbansim=False) s = select([run_activity.c.status], whereclause=run_activity.c.run_id == run_id) status = runs_manager.services_db.execute(s).fetchone()[0] expected = 'done' self.assertEqual(status, expected) # Restaring without running urbansim should not re-run that year. # TODO: test that no models are run this time. runs_manager.restart_run(run_id, restart_year=1982, project_name='eugene_gridcell', skip_urbansim=True) s = select([run_activity.c.status], whereclause=run_activity.c.run_id == run_id) status = runs_manager.services_db.execute(s).fetchone()[0] expected = 'done' self.assertEqual(status, expected) self.cleanup_test_run()
def main(option_group=None, args=None): if option_group is None: option_group = restart_run.RestartRunOptionGroup() parser = option_group.parser if args is None: options, args = option_group.parse() else: options, _args = option_group.parse() run_manager = RunManager(option_group.get_services_database_configuration(options)) run_as_multiprocess = not options.run_as_single_process if len(args) < 1: parser.print_help() sys.exit(1) run_id = int(args[0]) year = None if len(args) > 1: year = int(args[1]) # Get configuration from DB and ensure the run directory is mounted. Note # that we pass a dummy value for restart_year because we might not know it # yet. But when we actually restart the run, we will pass the correct # year. run_resources = run_manager.create_run_resources_from_history(run_id=run_id, restart_year=2010) hudson_common.mount_cache_dir(run_resources) cache_dir = run_resources['cache_directory'] if not year: # guess the year based on how the cache dir is populated years = map(lambda y : int(os.path.basename(y)), glob.glob(os.path.join(cache_dir, "2*"))) year = max(years) end_year = int(options.end_year) if options.end_year is not None else None run_manager.restart_run(run_id, year, options.project_name, end_year=end_year, skip_urbansim=options.skip_urbansim, create_baseyear_cache_if_not_exists=options.create_baseyear_cache_if_not_exists, skip_cache_cleanup=options.skip_cache_cleanup, run_as_multiprocess=run_as_multiprocess )
def test_restart_simple_run(self): _do_run_simple_test_run(self, self.temp_dir, self.config) runs_manager = RunManager(self.config) runs_manager.update_environment_variables(run_resources = SubsetConfiguration()) run_activity = runs_manager.services_db.get_table('run_activity') s = select([func.max(run_activity.c.run_id)]) run_id = runs_manager.services_db.execute(s).fetchone()[0] s = select([run_activity.c.status], whereclause = run_activity.c.run_id == run_id) status = runs_manager.services_db.execute(s).fetchone()[0] expected = 'done' self.assertEqual(status, expected) runs_manager.restart_run(run_id, restart_year=2001, project_name = SubsetConfiguration()['project_name'], skip_urbansim=False) s = select([run_activity.c.status], whereclause = run_activity.c.run_id == run_id) status = runs_manager.services_db.execute(s).fetchone()[0] expected = 'done' self.assertEqual(status, expected) # Restaring without running urbansim should not re-run that year. # TODO: test that no models are run this time. runs_manager.restart_run(run_id, restart_year=2002, project_name = SubsetConfiguration()['project_name'], skip_urbansim=True) s = select([run_activity.c.status], whereclause = run_activity.c.run_id == run_id) status = runs_manager.services_db.execute(s).fetchone()[0] expected = 'done' self.assertEqual(status, expected) self.cleanup_test_run()
self.parser.add_option("-p", "--project-name", dest="project_name", default='',help="The name project name") self.parser.add_option("--skip-urbansim", dest="skip_urbansim", default=False, action="store_true", help="Skip running UrbanSim for the restart year.") self.parser.add_option("--create-baseyear-cache-if-not-exists", dest="create_baseyear_cache_if_not_exists", default=False, action="store_true", help="Create baseyear cache if not already exists") self.parser.add_option("--skip-cache-cleanup", dest="skip_cache_cleanup", default=False, action="store_true", help="Skip removing year caches for this and future years.") if __name__ == "__main__": option_group = RestartRunOptionGroup() parser = option_group.parser (options, args) = parser.parse_args() run_manager = RunManager(option_group.get_services_database_configuration(options)) if len(args) < 2: parser.print_help() else: run_id, year = (int(args[0]), int(args[1])) run_manager.restart_run(run_id, year, options.project_name, skip_urbansim=options.skip_urbansim, create_baseyear_cache_if_not_exists=options.create_baseyear_cache_if_not_exists, skip_cache_cleanup=options.skip_cache_cleanup)