def prepare_for_run(self, configuration_path=None, config=None, run_id=None, prepare_cache=True, run_name = None): """Configuration is given either as an opus path (configuration_path) or as a Configuration object (config).""" if run_id is not None: self.run_id = run_id config = self.get_run_manager().get_resources_for_run_id_from_history(run_id=self.run_id) self.remote_communication_path = '%s/%s' % (self.remote_communication_path_root, self.run_id) else: if configuration_path is not None: opus_path = configuration_path config = get_config_from_opus_path(opus_path) else: if config is None: raise StandardError, "Either configuration_path, config or run_id must be given." insert_auto_generated_cache_directory_if_needed(config) self.run_id = self.get_run_manager()._get_new_run_id() head, tail = os.path.split(config['cache_directory']) config['cache_directory'] = '%s/run_%s.%s' % (head, self.run_id, tail) self.remote_communication_path = '%s/%s' % (self.remote_communication_path_root, self.run_id) if not self.skip_urbansim and prepare_cache: self.prepare_cache_and_communication_path(config) self.get_run_manager().add_row_to_history(self.run_id, config, "started", run_name = None) #check that run_id must exist results = self.get_run_manager().services_db.GetResultsFromQuery( "SELECT * from run_activity WHERE run_id = %s " % self.run_id) if not len(results) > 1: raise StandardError, "run_id %s doesn't exist in run_activity table." % self.run_id self.set_local_output_path() return config
def test_run(self): # The paths work as follows: opus_matsim.__path__ is the path of the opus_matsim python module. So we can use that # as anchor ... config_location = os.path.join(opus_matsim.__path__[0], 'tests') print "location: ", config_location run_config = XMLConfiguration( os.path.join(config_location, "test_config.xml")).get_run_configuration("Test") run_config[ 'creating_baseyear_cache_configuration'].cache_directory_root = self.temp_dir run_config['creating_baseyear_cache_configuration'].baseyear_cache.existing_cache_to_copy = \ os.path.join(opus_matsim.__path__[0], 'tests', 'testdata', 'base_year_data') # insert_auto_generated_cache_directory... does things I don't understand. Need to do the following to obtain consistent # behavior independent from the file root: run_config['cache_directory'] = None insert_auto_generated_cache_directory_if_needed(run_config) run_manager = RunManager(ServicesDatabaseConfiguration()) run_manager.setup_new_run( cache_directory=run_config['cache_directory'], configuration=run_config) run_manager.run_run(run_config, run_as_multiprocess=True) self.assert_(True) self.cleanup_test_run()
def prepare_for_run(self, configuration_path=None, config=None, run_id=None): """Configuration is given either as an opus path (configuration_path) or as a Configuration object (config).""" run_manager = self.get_run_manager() if run_id is not None: config = run_manager.get_resources_for_run_id_from_history( run_id=run_id) else: if configuration_path is not None: config = get_config_from_opus_path(configuration_path) elif config is None: raise StandardError, "Either configuration_path, config or run_id must be given." insert_auto_generated_cache_directory_if_needed(config) run_manager.setup_new_run( cache_directory=config['cache_directory'], configuration=config) run_id = run_manager.run_id config['cache_directory'] = pathname2url( run_manager.get_current_cache_directory()) ## pathname2url converts '\' or '\\' to '/'; it is necessary when this script is invoked from a nt os run_manager.add_row_to_history(run_id, config, "started") #verify run_id has been added to services db results = run_manager.services_db.GetResultsFromQuery( "SELECT * from run_activity WHERE run_id = %s " % run_id) if not len(results) > 1: raise StandardError, "run_id %s doesn't exist in run_activity table." % run_id return run_id, config
def test_run(self): # The paths work as follows: opus_matsim.__path__ is the path of the opus_matsim python module. So we can use that # as anchor ... config_location = os.path.join(opus_matsim.__path__[0], 'tests') print "location: ", config_location run_config = XMLConfiguration( os.path.join(config_location,"test_config.xml")).get_run_configuration("Test") run_config['creating_baseyear_cache_configuration'].cache_directory_root = self.temp_dir run_config['creating_baseyear_cache_configuration'].baseyear_cache.existing_cache_to_copy = \ os.path.join(opus_matsim.__path__[0], 'tests', 'testdata', 'base_year_data') # insert_auto_generated_cache_directory... does things I don't understand. Need to do the following to obtain consistent # behavior independent from the file root: run_config['cache_directory'] = None insert_auto_generated_cache_directory_if_needed(run_config) run_manager = RunManager(ServicesDatabaseConfiguration()) run_manager.setup_new_run(cache_directory = run_config['cache_directory'], configuration = run_config) run_manager.run_run(run_config, run_as_multiprocess = True ) self.assert_(True) self.cleanup_test_run()
def prepare_for_run(self, configuration_path=None, config=None, run_id=None): """Configuration is given either as an opus path (configuration_path) or as a Configuration object (config).""" run_manager = self.get_run_manager() if run_id is not None: config = run_manager.get_resources_for_run_id_from_history(run_id=run_id) else: if configuration_path is not None: config = get_config_from_opus_path(configuration_path) elif config is None: raise StandardError, "Either configuration_path, config or run_id must be given." insert_auto_generated_cache_directory_if_needed(config) run_manager.setup_new_run(cache_directory = config['cache_directory'], configuration = config) run_id = run_manager.run_id config['cache_directory'] = pathname2url(run_manager.get_current_cache_directory()) ## pathname2url converts '\' or '\\' to '/'; it is necessary when this script is invoked from a nt os run_manager.add_row_to_history(run_id, config, "started") #verify run_id has been added to services db results = run_manager.services_db.GetResultsFromQuery( "SELECT * from run_activity WHERE run_id = %s " % run_id) if not len(results) > 1: raise StandardError, "run_id %s doesn't exist in run_activity table." % run_id return run_id, config
def init_run(self, create_baseyear_cache=True): ''' init run, get run_id & cache_directory. ''' ##avoid invoking start_run from cmd line - option_group = StartRunOptionGroup() option_group.parser.set_defaults(xml_configuration=self.xml_config, scenario_name=self.scenario) #run_id, cache_directory = start_run(option_group) options, args = option_group.parse() self.run_manager = RunManager( option_group.get_services_database_configuration(options)) resources = XMLConfiguration(self.xml_config).get_run_configuration( self.scenario) insert_auto_generated_cache_directory_if_needed(resources) cache_directory = resources['cache_directory'] self.run_manager.setup_new_run(cache_directory, resources) run_id, cache_directory = self.run_manager.run_id, self.run_manager.get_current_cache_directory( ) self.run_manager.add_row_to_history(run_id, resources, "done") if create_baseyear_cache: self.run_manager.create_baseyear_cache(resources) ## good for testing #run_id = 275 #cache_directory = '/home/lmwang/opus/data/paris_zone/runs/run_275.2012_05_26_00_20' assert run_id is not None assert cache_directory is not None return run_id, cache_directory
def _do_run_simple_test_run(caller, temp_dir, config, end_year=None): """Runs model system with a single model (for speed). Sets the .resources property of the caller before starting the run. """ runs_manager = RunManager(config) run_configuration = _get_run_config(temp_dir=temp_dir) insert_auto_generated_cache_directory_if_needed(run_configuration) run_configuration[ 'creating_baseyear_cache_configuration'].cache_directory_root = temp_dir run_configuration['models'] = ['land_price_model'] if end_year is not None: run_configuration['years'] = (run_configuration['years'][0], end_year) SessionConfiguration( new_instance=True, package_order=run_configuration['dataset_pool_configuration']. package_order, in_storage=AttributeCache()) insert_auto_generated_cache_directory_if_needed(run_configuration) caller.resources = run_configuration runs_manager.setup_new_run( cache_directory=run_configuration['cache_directory'], configuration=run_configuration) runs_manager.run_run(run_configuration)
def testName(self): print "entering test_run" logger.log_status('Preparing MATsim test run ...') # unzip MATSim files matsim_zip = ExtractZipFile(self.matsim_source, self.destination) matsim_zip.extract() matsim_extracted_files = os.path.join(self.destination, 'MATSimTestClasses') # location of unziped MATSim files # unzip base_year_cache base_year_data_zip = ExtractZipFile(self.base_year_data_source, self.destination) base_year_data_zip.extract() base_year_data_extracted_files = os.path.join(self.destination, 'base_year_data') # location of unziped base_year_cache # updating location of base_year_data self.run_config['creating_baseyear_cache_configuration'].cache_directory_root = self.destination self.run_config['creating_baseyear_cache_configuration'].baseyear_cache.existing_cache_to_copy = base_year_data_extracted_files self.run_config['cache_directory'] = base_year_data_extracted_files self.run_config.add('matsim_files', matsim_extracted_files) self.run_config.add('matsim_config', self.matsim_config_full) self.run_config.add('root', self.destination) insert_auto_generated_cache_directory_if_needed(self.run_config) run_manager = RunManager(ServicesDatabaseConfiguration()) run_manager.setup_new_run(cache_directory = self.run_config['cache_directory'], configuration = self.run_config) logger.log_status('Strating UrbanSim run ... ') run_manager.run_run(self.run_config, run_as_multiprocess = True ) # after the UrbanSim run the travel data sets schould be equal # self.assertTrue( self.compare_travel_data_sets() ) logger.log_status('... UrbanSim run finished.') print "leaving test_run"
def init_run(self, create_baseyear_cache=True): """ init run, get run_id & cache_directory. """ ##avoid invoking start_run from cmd line - option_group = StartRunOptionGroup() option_group.parser.set_defaults(xml_configuration=self.xml_config, scenario_name=self.scenario) # run_id, cache_directory = start_run(option_group) options, args = option_group.parse() self.run_manager = RunManager(option_group.get_services_database_configuration(options)) resources = XMLConfiguration(self.xml_config).get_run_configuration(self.scenario) insert_auto_generated_cache_directory_if_needed(resources) cache_directory = resources["cache_directory"] self.run_manager.setup_new_run(cache_directory, resources) run_id, cache_directory = self.run_manager.run_id, self.run_manager.get_current_cache_directory() self.run_manager.add_row_to_history(run_id, resources, "done") if create_baseyear_cache: self.run_manager.create_baseyear_cache(resources) ## good for testing # run_id = 275 # cache_directory = '/home/lmwang/opus/data/paris_zone/runs/run_275.2012_05_26_00_20' assert run_id is not None assert cache_directory is not None return run_id, cache_directory
def prepare_run_manager(option_group=None): if option_group is None: option_group = StartRunOptionGroup() parser = option_group.parser options, args = option_group.parse() run_manager = RunManager( option_group.get_services_database_configuration(options)) if options.pickled_resource_file is not None: f = file(options.pickled_resource_file, 'r') try: config = pickle.load(f) finally: f.close() elif options.configuration_path is not None: opus_path = options.configuration_path try: config = get_config_from_opus_path(opus_path) except ImportError: # TODO: Once all fully-specified configurations are stored as classes, # get rid of this use. import_stmt = 'from %s import run_configuration as config' % opus_path exec(import_stmt) insert_auto_generated_cache_directory_if_needed(config) elif options.xml_configuration is not None: if options.scenario_name is None: parser.print_help() sys.exit(1) config = XMLConfiguration( options.xml_configuration).get_run_configuration( options.scenario_name) insert_auto_generated_cache_directory_if_needed(config) else: parser.print_help() sys.exit(1) if options.existing_cache_to_copy is not None: config[ 'creating_baseyear_cache_configuration'].cache_from_database = False config[ 'creating_baseyear_cache_configuration'].baseyear_cache = BaseyearCacheConfiguration( existing_cache_to_copy=options.existing_cache_to_copy, ) if options.years_to_cache is not None: config[ 'creating_baseyear_cache_configuration'].baseyear_cache.years_to_cache = eval( options.years_to_cache) if options.profile_filename is not None: config["profile_filename"] = options.profile_filename run_manager.setup_new_run(cache_directory=config['cache_directory'], configuration=config) return options, config, run_manager
def test_simulation(self): services_db = ServicesDatabaseConfiguration( database_name = 'services', database_configuration = 'services_database_server' ) run_manager = RunManager(services_db) run_as_multiprocess = True for scenario_name in ['san_antonio_baseline_test']: config = self.xml_config.get_run_configuration(scenario_name) insert_auto_generated_cache_directory_if_needed(config) run_manager.setup_new_run(cache_directory = config['cache_directory'], configuration = config) run_manager.run_run(config, run_as_multiprocess = run_as_multiprocess)
def run(self): logger.start_block() insert_auto_generated_cache_directory_if_needed(self.config) run_manager = RunManager(ServicesDatabaseConfiguration()) run_manager.setup_new_run(cache_directory = self.config['cache_directory'],configuration = self.config) run_manager.run_run(self.config, run_as_multiprocess = True ) logger.end_block()
def test_simulation(self): services_db = ServicesDatabaseConfiguration( database_name = 'services', database_configuration = 'services_database_server' ) run_manager = RunManager(services_db) run_as_multiprocess = True for scenario_name in ['psrc_baseline_test']: config = self.xml_config.get_run_configuration(scenario_name) insert_auto_generated_cache_directory_if_needed(config) run_manager.setup_new_run(cache_directory = config['cache_directory'], configuration = config) run_manager.run_run(config, run_as_multiprocess = run_as_multiprocess)
def run(self, config, executable): #--config=opus_matsim/sustain_city/configs/seattle_parcel.xml --executable=Seattle_baseline config = XMLConfiguration(config).get_run_configuration(executable) insert_auto_generated_cache_directory_if_needed(config) run_manager = RunManager(ServicesDatabaseConfiguration()) run_manager.setup_new_run(cache_directory = config['cache_directory'],configuration = config) run_manager.run_run(config, run_as_multiprocess = True )
def __init__(self, mainwindow, runManager, model, xml_config): QWidget.__init__(self, mainwindow) self.mainwindow = mainwindow self.setupUi(self) self.runManager = runManager self.project = runManager.project self.model = model self.model.guiElement = self self.inGui = False self.logFileKey = 0 self.running = False self.paused = False self.timer = None self.runThread = None self.config = None self.xml_config = xml_config self.config = xml_config.get_run_configuration( str(self.model.modeltorun)) insert_auto_generated_cache_directory_if_needed(self.config) (self.start_year, self.end_year) = self.config['years'] self.tabIcon = QIcon(":/Images/Images/cog.png") self.tabLabel = model.modeltorun self.setup_run_name_line_edit() self.setup_indicator_batch_combobox() # Simulation Progress Tab self.runProgressBarTotal.setProperty("value", QVariant(0)) self.runProgressBarTotal.reset() ### Year Progress Bar self.runProgressBarYear.setProperty("value", QVariant(0)) self.runProgressBarYear.reset() ### Model Progress Bar self.runProgressBarModel.setProperty("value", QVariant(0)) self.runProgressBarModel.reset() self.setupDiagnosticIndicatorTab() self.gb_model_progress.hide() self.spatial_datasets = get_available_spatial_dataset_names( project=self.project) self.diagnostic_go_button.setEnabled(False)
def test_simulation(self): eugene_dir = __import__('eugene').__path__[0] xml_config = XMLConfiguration(os.path.join(eugene_dir, 'configs', 'eugene_gridcell.xml')) option_group = StartRunOptionGroup() parser = option_group.parser # simulate 0 command line arguments by passing in [] (options, _) = parser.parse_args([]) run_manager = RunManager(option_group.get_services_database_configuration(options)) run_section = xml_config.get_run_configuration('Eugene_baseline') insert_auto_generated_cache_directory_if_needed(run_section) run_manager.setup_new_run(cache_directory = run_section['cache_directory'], configuration = run_section) run_manager.run_run(run_section)
def __init__(self, mainwindow, runManager, model, xml_config): QWidget.__init__(self, mainwindow) self.mainwindow = mainwindow self.setupUi(self) self.runManager = runManager self.project = runManager.project self.model = model self.model.guiElement = self self.inGui = False self.logFileKey = 0 self.running = False self.paused = False self.timer = None self.runThread = None self.config = None self.xml_config = xml_config self.config = xml_config.get_run_configuration(str(self.model.modeltorun)) insert_auto_generated_cache_directory_if_needed(self.config) (self.start_year, self.end_year) = self.config['years'] self.tabIcon = QIcon(":/Images/Images/cog.png") self.tabLabel = model.modeltorun self.setup_run_name_line_edit() self.setup_indicator_batch_combobox() # Simulation Progress Tab self.runProgressBarTotal.setProperty("value",QVariant(0)) self.runProgressBarTotal.reset() ### Year Progress Bar self.runProgressBarYear.setProperty("value",QVariant(0)) self.runProgressBarYear.reset() ### Model Progress Bar self.runProgressBarModel.setProperty("value",QVariant(0)) self.runProgressBarModel.reset() self.setupDiagnosticIndicatorTab() self.gb_model_progress.hide() self.spatial_datasets = get_available_spatial_dataset_names(project = self.project) self.diagnostic_go_button.setEnabled(False)
def prepare_run_manager(option_group=None): if option_group is None: option_group = StartRunOptionGroup() parser = option_group.parser options, args = option_group.parse() run_manager = RunManager(option_group.get_services_database_configuration(options)) if options.pickled_resource_file is not None: f = file(options.pickled_resource_file, 'r') try: config = pickle.load(f) finally: f.close() elif options.configuration_path is not None: opus_path = options.configuration_path try: config = get_config_from_opus_path(opus_path) except ImportError: # TODO: Once all fully-specified configurations are stored as classes, # get rid of this use. import_stmt = 'from %s import run_configuration as config' % opus_path exec(import_stmt) insert_auto_generated_cache_directory_if_needed(config) elif options.xml_configuration is not None: if options.scenario_name is None: parser.print_help() sys.exit(1) config = XMLConfiguration(options.xml_configuration).get_run_configuration(options.scenario_name) insert_auto_generated_cache_directory_if_needed(config) else: parser.print_help() sys.exit(1) if options.existing_cache_to_copy is not None: config['creating_baseyear_cache_configuration'].cache_from_database = False config['creating_baseyear_cache_configuration'].baseyear_cache = BaseyearCacheConfiguration( existing_cache_to_copy = options.existing_cache_to_copy, ) if options.years_to_cache is not None: config['creating_baseyear_cache_configuration'].baseyear_cache.years_to_cache = eval(options.years_to_cache) if options.profile_filename is not None: config["profile_filename"] = options.profile_filename run_manager.setup_new_run(cache_directory = config['cache_directory'], configuration = config) return options, config, run_manager
def test_simulation(self): # check that the simulation proceeds without crashing # open the configuration for seattle_parcel.xml seattle_parcel_dir = __import__('seattle_parcel').__path__[0] xml_config = XMLConfiguration(os.path.join(seattle_parcel_dir, 'configs', 'seattle_parcel.xml')) option_group = StartRunOptionGroup() parser = option_group.parser # simulate 0 command line arguments by passing in [] (options, _) = parser.parse_args([]) run_manager = RunManager(option_group.get_services_database_configuration(options)) run_section = xml_config.get_run_configuration('Seattle_baseline') insert_auto_generated_cache_directory_if_needed(run_section) run_manager.setup_new_run(cache_directory = run_section['cache_directory'], configuration = run_section) run_manager.run_run(run_section)
def __init__(self): print "Entering setup" logger.log_status('Running UrbanSim to test the impact of travel costs (provided from an dummy travel model)') # get sensitivity test path self.test_dir_path = test_dir.__path__[0] self.config_file = os.path.join( self.test_dir_path, "configs", "seattle_parcel_travel_cost_test.xml") print 'Loding UrbanSim config file: %s' % self.config_file # get seattle_parcel configuration self.config = XMLConfiguration( self.config_file ).get_run_configuration( "Seattle_baseline" ) insert_auto_generated_cache_directory_if_needed(self.config) print "Leaving setup"
def test_simulation(self): eugene_dir = __import__('eugene').__path__[0] xml_config = XMLConfiguration( os.path.join(eugene_dir, 'configs', 'eugene_gridcell.xml')) option_group = StartRunOptionGroup() parser = option_group.parser # simulate 0 command line arguments by passing in [] (options, _) = parser.parse_args([]) run_manager = RunManager( option_group.get_services_database_configuration(options)) run_section = xml_config.get_run_configuration('Eugene_baseline') insert_auto_generated_cache_directory_if_needed(run_section) run_manager.setup_new_run( cache_directory=run_section['cache_directory'], configuration=run_section) run_manager.run_run(run_section)
def test_simulation(self): base_year_data_path = os.path.join(self.data_path, 'base_year_data') if not os.path.exists(base_year_data_path): os.makedirs(base_year_data_path) ftp_url = os.environ["FTP_URL"] file_name = os.path.split(ftp_url)[1] ftp_user = os.environ["FTP_USERNAME"] ftp_password = os.environ["FTP_PASSWORD"] #stdout, stderr = Popen("ls -la %s" % base_year_data_path, shell=True).communicate() #stdout, stderr = Popen("echo '%s'" % (base_year_data_path), stdout=PIPE).communicate() #print stdout try: Popen( """ cd %s; pwd; ls -la; echo wget --timestamping %s --ftp-user=%s --ftp-password=%s > /dev/null 2>&1; rm -rf 2008; unzip -o %s """ % (base_year_data_path, ftp_url, ftp_user, ftp_password, file_name), shell = True ).communicate() except: print "Error when downloading and unzipping file from %s." % ftp_url raise services_db = ServicesDatabaseConfiguration( database_name = 'services', database_configuration = 'services_database_server' ) run_manager = RunManager(services_db) run_as_multiprocess = True xml_config = XMLConfiguration(os.path.join(self.opus_home, 'project_configs', 'washtenaw_parcel.xml')) for scenario_name in ['washtenaw_baseline_test']: config = xml_config.get_run_configuration(scenario_name) insert_auto_generated_cache_directory_if_needed(config) # base_year = config['base_year'] # config['years_to_run'] = (base_year+1, base_year+2) run_manager.setup_new_run(cache_directory = config['cache_directory'], configuration = config) run_manager.run_run(config, run_as_multiprocess = run_as_multiprocess)
def _do_run_simple_test_run(caller, temp_dir, config, end_year=None): """Runs model system with a single model (for speed). Sets the .resources property of the caller before starting the run. """ runs_manager = RunManager(config) run_configuration = SubsetConfiguration() run_configuration['creating_baseyear_cache_configuration'].cache_directory_root = temp_dir run_configuration['models'] = ['land_price_model'] if end_year is not None: run_configuration['years'] = (run_configuration['years'][0], end_year) SessionConfiguration(new_instance=True, package_order=run_configuration['dataset_pool_configuration'].package_order, in_storage=AttributeCache()) insert_auto_generated_cache_directory_if_needed(run_configuration) caller.resources = run_configuration runs_manager.setup_new_run(cache_directory = run_configuration['cache_directory'], configuration = run_configuration) runs_manager.run_run(run_configuration)
def testName(self): print "entering test_run" logger.log_status("Preparing MATsim test run ...") # unzip MATSim files matsim_zip = ExtractZipFile(self.matsim_source, self.destination) matsim_zip.extract() matsim_extracted_files = os.path.join(self.destination, "MATSimTestClasses") # location of unziped MATSim files # unzip base_year_cache base_year_data_zip = ExtractZipFile(self.base_year_data_source, self.destination) base_year_data_zip.extract() base_year_data_extracted_files = os.path.join( self.destination, "base_year_data" ) # location of unziped base_year_cache # updating location of base_year_data self.run_config["creating_baseyear_cache_configuration"].cache_directory_root = self.destination self.run_config[ "creating_baseyear_cache_configuration" ].baseyear_cache.existing_cache_to_copy = base_year_data_extracted_files self.run_config["cache_directory"] = base_year_data_extracted_files self.run_config.add("matsim_files", matsim_extracted_files) self.run_config.add("matsim_config", self.matsim_config_full) self.run_config.add("root", self.destination) insert_auto_generated_cache_directory_if_needed(self.run_config) run_manager = RunManager(ServicesDatabaseConfiguration()) run_manager.setup_new_run(cache_directory=self.run_config["cache_directory"], configuration=self.run_config) logger.log_status("Strating UrbanSim run ... ") run_manager.run_run(self.run_config, run_as_multiprocess=True) # after the UrbanSim run the travel data sets schould be equal # self.assertTrue( self.compare_travel_data_sets() ) logger.log_status("... UrbanSim run finished.") print "leaving test_run"
class StartRunOptionGroup(object): """ Helper class to start model from an xml config file. """ logger.start_block("Starting UrbanSim") # get program arguments from the command line program_arguments = sys.argv[1:] # default parameters are: # --config=opus_matsim/sustain_city/configs/seattle_parcel_prescheduled_events.xml # --executable=Seattle_baseline parser = optparse.OptionParser() parser.add_option("-c", "--config", dest="config_file_name", action="store", type="string", help="Name of file containing urbansim config") parser.add_option("-e", "--executable", dest="scenario_executable", action="store", type="string", help="Model to execute") (options, args) = parser.parse_args() if options.config_file_name == None: logger.log_error("Missing path to the urbansim config file") if options.scenario_executable == None: logger.log_error("Missing name of executable scenario") config = XMLConfiguration(options.config_file_name).get_run_configuration( options.scenario_executable) insert_auto_generated_cache_directory_if_needed(config) run_manager = RunManager(ServicesDatabaseConfiguration()) run_manager.setup_new_run(cache_directory=config['cache_directory'], configuration=config) #try: #tnicolai # import pydevd # pydevd.settrace() #except: pass run_manager.run_run(config, run_as_multiprocess=True)
class StartRunOptionGroup(object): """ Helper class to start model from an xml config file. """ config = XMLConfiguration("opus_matsim/configs/seattle_parcel.xml" ).get_run_configuration("Seattle_baseline") # config = XMLConfiguration("opus_matsim/configs/psrc_parcel.xml").get_run_configuration("PSRC_baseline") insert_auto_generated_cache_directory_if_needed(config) run_manager = RunManager(ServicesDatabaseConfiguration()) run_manager.setup_new_run(cache_directory=config['cache_directory'], configuration=config) # run_manager.create_baseyear_cache(config) run_manager.run_run(config, run_as_multiprocess=True)
f = file(options.pickled_resource_file, 'r') try: config = pickle.load(f) finally: f.close() elif options.configuration_path is not None: opus_path = options.configuration_path try: config = get_config_from_opus_path(opus_path) except ImportError: # TODO: Once all fully-specified configurations are stored as classes, # get rid of this use. import_stmt = 'from %s import run_configuration as config' % opus_path exec(import_stmt) insert_auto_generated_cache_directory_if_needed(config) elif options.xml_configuration is not None: if options.scenario_name is None: parser.print_help() sys.exit(1) config = XMLConfiguration(options.xml_configuration).get_run_configuration(options.scenario_name) insert_auto_generated_cache_directory_if_needed(config) else: parser.print_help() sys.exit(1) if options.existing_cache_to_copy is not None: config['creating_baseyear_cache_configuration'].cache_from_database = False config['creating_baseyear_cache_configuration'].baseyear_cache.existing_cache_to_copy = options.existing_cache_to_copy if options.years_to_cache is not None: config['creating_baseyear_cache_configuration'].baseyear_cache.years_to_cache = eval(options.years_to_cache)
def updateConfigAndGuiForRun(self): config = self.xml_config.get_run_configuration( str(self.model.modeltorun)) self.config = config insert_auto_generated_cache_directory_if_needed(config) (self.start_year, self.end_year) = config['years']
f = file(options.pickled_resource_file, 'r') try: config = pickle.load(f) finally: f.close() elif options.configuration_path is not None: opus_path = options.configuration_path try: config = get_config_from_opus_path(opus_path) except ImportError: # TODO: Once all fully-specified configurations are stored as classes, # get rid of this use. import_stmt = 'from %s import run_configuration as config' % opus_path exec(import_stmt) insert_auto_generated_cache_directory_if_needed(config) elif options.xml_configuration is not None: if options.scenario_name is None: parser.print_help() sys.exit(1) config = XMLConfiguration( options.xml_configuration).get_run_configuration( options.scenario_name) insert_auto_generated_cache_directory_if_needed(config) else: parser.print_help() sys.exit(1) if options.existing_cache_to_copy is not None: config[ 'creating_baseyear_cache_configuration'].cache_from_database = False
def updateConfigAndGuiForRun(self): config = self.xml_config.get_run_configuration(str(self.model.modeltorun)) self.config = config insert_auto_generated_cache_directory_if_needed(config) (self.start_year, self.end_year) = config['years']