oemof / oemof-tabular

Load oemof energy systems from tabular data sources.
https://oemof-tabular.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
7 stars 5 forks source link

Improve error message for reading datapackage #134

Closed nailend closed 1 year ago

nailend commented 1 year ago

Description

Just adds further information about which why the reading of the datapackage might not have worked. E.g which column could not be casted.

Type of change

New feature (non-breaking change which adds functionality)

Checklist:

Please tick or delete options that are not relevant.

henhuy commented 1 year ago

I like the idea, but cannot test it - do you have an example? Maybe even add a minimal test?

nailend commented 1 year ago

For a minimal test, I would need to add a false datapackage to examples. This might be confusing. The easiest way to check is by modifying an existing example e.g investment_multi_period/datapackage.json. Change type of field name to integer for the bus.csv and then run the `test_example_datapackage_readability``

The new error message will look like this:

E               tableschema.exceptions.CastError: 
E               Metadata structure of resource `bus` does not match data structure. Check the column names, types and their order.
E               Field "name" can't cast value "bus0" for type "integer" with format "default"
nailend commented 1 year ago

Can't think of a test without creating an example datapackage. Anyway, I am basically just appending the original error message to the tabular internal one. I will just merge this