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 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 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()
class OptionGroup(GenericOptionGroup): def __init__(self): GenericOptionGroup.__init__(self, usage="python %prog [options] run_id [pickle_file]", description="dump resources.pickle from services db for the given run_id") self.parser.add_option("-p", "--project-name", dest="project_name", default='',help="The project name") if __name__ == "__main__": option_group = OptionGroup() parser = option_group.parser (options, args) = parser.parse_args() try: run_id = int(args[0]) except IndexError: parser.error("run_id must be provided.") parser.print_help() sys.exit(1) if len(args) == 2: pickle_file = args[1] else: pickle_file = "resources.pickle" run_manager = RunManager(option_group.get_services_database_configuration(options)) if options.project_name: run_manager.update_environment_variables(run_resources={'project_name':options.project_name}) resources = run_manager.get_resources_for_run_id_from_history(run_id=run_id) write_resources_to_file(pickle_file, resources)
dest="project_name", default='', help="The project name") if __name__ == "__main__": option_group = OptionGroup() parser = option_group.parser (options, args) = parser.parse_args() try: run_id = int(args[0]) except IndexError: parser.error("run_id must be provided.") parser.print_help() sys.exit(1) if len(args) == 2: pickle_file = args[1] else: pickle_file = "resources.pickle" run_manager = RunManager( option_group.get_services_database_configuration(options)) if options.project_name: run_manager.update_environment_variables( run_resources={'project_name': options.project_name}) resources = run_manager.get_resources_for_run_id_from_history( run_id=run_id) write_resources_to_file(pickle_file, resources)