88from smif .exception import SmifDataNotFoundError
99from smif .model import ScenarioModel , SosModel
1010
11- LOGGER = logging .getLogger (__name__ )
12-
1311
1412def get_model_run_definition (store , modelrun ):
1513 """Builds the model run
@@ -31,26 +29,26 @@ def get_model_run_definition(store, modelrun):
3129 try :
3230 model_run_config = store .read_model_run (modelrun )
3331 except SmifDataNotFoundError :
34- LOGGER .error ("Model run %s not found. Run 'smif list' to see available model runs." ,
32+ logging .error ("Model run %s not found. Run 'smif list' to see available model runs." ,
3533 modelrun )
3634 exit (- 1 )
3735
38- LOGGER .info ("Running %s" , model_run_config ['name' ])
39- LOGGER .debug ("Model Run: %s" , model_run_config )
36+ logging .info ("Running %s" , model_run_config ['name' ])
37+ logging .debug ("Model Run: %s" , model_run_config )
4038 sos_model_config = store .read_sos_model (model_run_config ['sos_model' ])
4139
4240 sector_models = get_sector_models (sos_model_config ['sector_models' ], store )
43- LOGGER .debug ("Sector models: %s" , sector_models )
41+ logging .debug ("Sector models: %s" , sector_models )
4442
4543 scenario_models = get_scenario_models (model_run_config ['scenarios' ], store )
46- LOGGER .debug ("Scenario models: %s" , [model .name for model in scenario_models ])
44+ logging .debug ("Scenario models: %s" , [model .name for model in scenario_models ])
4745
4846 sos_model = SosModel .from_dict (sos_model_config , sector_models + scenario_models )
4947 model_run_config ['sos_model' ] = sos_model
50- LOGGER .debug ("Model list: %s" , list (model .name for model in sos_model .models ))
48+ logging .debug ("Model list: %s" , list (model .name for model in sos_model .models ))
5149
5250 model_run_config ['strategies' ] = store .read_strategies (model_run_config ['name' ])
53- LOGGER .debug ("Strategies: %s" , [s ['type' ] for s in model_run_config ['strategies' ]])
51+ logging .debug ("Strategies: %s" , [s ['type' ] for s in model_run_config ['strategies' ]])
5452
5553 return model_run_config
5654
@@ -78,7 +76,7 @@ def get_scenario_models(scenarios, handler):
7876 scenario_definition ['outputs' ] = scenario_definition ['provides' ]
7977 del scenario_definition ['provides' ]
8078
81- LOGGER .debug ("Scenario definition: %s" , scenario_name )
79+ logging .debug ("Scenario definition: %s" , scenario_name )
8280
8381 scenario_model = ScenarioModel .from_dict (scenario_definition )
8482 scenario_models .append (scenario_model )
@@ -123,7 +121,8 @@ def build_model_run(model_run_config):
123121 -------
124122 `smif.controller.modelrun.ModelRun`
125123 """
126- LOGGER .profiling_start ('build_model_run' , model_run_config ['name' ])
124+ logger = logging .getLogger ()
125+ logger .profiling_start ('build_model_run' , model_run_config ['name' ])
127126 try :
128127 builder = ModelRunBuilder ()
129128 builder .construct (model_run_config )
@@ -133,10 +132,10 @@ def build_model_run(model_run_config):
133132 traceback .print_exception (err_type , err_value , err_traceback )
134133 err_msg = str (error )
135134 if err_msg :
136- LOGGER .error ("An AssertionError occurred (%s) see details above." , err_msg )
135+ logger .error ("An AssertionError occurred (%s) see details above." , err_msg )
137136 else :
138- LOGGER .error ("An AssertionError occurred, see details above." )
137+ logger .error ("An AssertionError occurred, see details above." )
139138 exit (- 1 )
140139
141- LOGGER .profiling_stop ('build_model_run' , model_run_config ['name' ])
140+ logger .profiling_stop ('build_model_run' , model_run_config ['name' ])
142141 return modelrun
0 commit comments