Raise a more informative error when scenario variant is missing a variable key
tomalrussell opened this issue · 0 comments
tomalrussell commented
e.g. in a scenario definition, for a scenario which should provide multiple outputs:
variants:
- name: es_energy_demand_dummy_full
description: ''
data:
a: file.csv
# oil_non_heat_eh not included here
trying to access (through DataHandle.get_data
) an output which has no entry in the variant data
dict raises a KeyError
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/data_layer/data_handle.py", line 304, in get_data
data = self._get_scenario(dep, timestep, input_name)
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/data_layer/data_handle.py", line 383, in _get_scenario
timestep
File "/home/vagrant/nismod/lib/python3.5/site-packages/smif/data_layer/store.py", line 546, in read_scenario_variant_data
key = self._key_from_data(variant['data'][variable], scenario_name, variant_name,
File "/home/vagrant/nismod/lib/python3.5/site-packages/ruamel/yaml/comments.py", line 716, in __getitem__
return ordereddict.__getitem__(self, key)
KeyError: 'oil_non_heat_eh'