Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise a more informative error when scenario variant is missing a variable key #388

Open
tomalrussell opened this issue Jul 30, 2019 · 0 comments

Comments

@tomalrussell
Copy link
Member

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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant