Unhelpful error message when incorrect narrative variant provided
sveneggimann opened this issue · 1 comments
sveneggimann commented
Adding a new narrative results in the following error message which is unhelpful to diagnose what the issue is. Replacing the narrative construct with an empty dict in the yaml configuration file removes the source of the error.
Traceback (most recent call last):
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/controller/scheduler.py", line 178, in add
self._run(job_graph, job_graph_id)
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/controller/scheduler.py", line 240, in _run
decision_iteration=job['decision_iteration']
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/data_layer/data_handle.py", line 66, in __init__
self._load_parameters(sos_model, modelrun['narratives'])
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/data_layer/data_handle.py", line 138, in _load_parameters
narrative_name, variant_name, parameter
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/data_layer/store.py", line 545, in read_narrative_variant_data
key = self._key_from_data(variant['data'][parameter_name], narrative_name,
TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "/home/vagrant/nismod/bin/smif", line 10, in <module>
sys.exit(main())
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/cli/__init__.py", line 345, in main
args.func(args)
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/cli/__init__.py", line 129, in run_model_runs
execute_model_run(model_run_ids, store, args.warm)
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/controller/execute.py", line 32, in execute_model_run
modelrun.run(store)
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/controller/modelrun.py", line 137, in run
modelrunner.solve_model(self, store)
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/controller/modelrun.py", line 190, in solve_model
raise err
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/controller/scheduler.py", line 178, in add
self._run(job_graph, job_graph_id)
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/controller/scheduler.py", line 240, in _run
decision_iteration=job['decision_iteration']
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/data_layer/data_handle.py", line 66, in __init__
self._load_parameters(sos_model, modelrun['narratives'])
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/data_layer/data_handle.py", line 138, in _load_parameters
narrative_name, variant_name, parameter
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/data_layer/store.py", line 545, in read_narrative_variant_data
key = self._key_from_data(variant['data'][parameter_name], narrative_name,
TypeError: 'NoneType' object is not subscriptable
willu47 commented
After investigation, this error is caused by an incorrect narrative variant name in the model run config. This should raise a friendly error e.g. "The narrative variant 'does not exist' does not exist in the variants of narrative mode
.
This is a validation issue, and should be picked up in validation.py
. At present, validation code is not called from the builder. Suggest adding a flag to the cli to optionally run validation upon building a model run (see issue #343).