Skip to content

Commit

Permalink
Add validation against legacy variables in integration test (#7)
Browse files Browse the repository at this point in the history
* Add testing for legacy variables in integration test

* Remove variables added to common-definitions
  • Loading branch information
danielhuppmann authored Mar 23, 2024
1 parent e55780b commit 711addd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 64 deletions.
63 changes: 0 additions & 63 deletions definitions/variable/variable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,6 @@
- Employment:
definition: Number of employed inhabitants (based on ILO classification)
unit: million
- Unemployment:
definition: Number of unemployed inhabitants (based on ILO classification)
unit: million
- Unemployment|Rate:
definition: Fraction of unemployed inhabitants (based on ILO classification)
unit: '%'
Expand Down Expand Up @@ -2452,14 +2449,6 @@
- Final Energy|Transportation|Freight|LDV:
definition: final energy consumption by the freight transportation sector by LDV
unit: EJ/yr
- Final Energy|Bunkers|Passenger|International Shipping:
definition: final energy consumption by the Passenger transportation sector by
International Shipping
unit: EJ/yr
- Final Energy|Bunkers|Passenger|International Aviation:
definition: final energy consumption by the Passenger transportation sector by
International Aviation
unit: EJ/yr
- Final Energy|Bunkers|Passenger|International Aviation|Electricity:
definition: final energy consumption of electricity excluding transmission/distribution
losses in the Bunkers Passenger sector by International Aviation
Expand All @@ -2476,14 +2465,6 @@
definition: final energy consumption of liquids in the Bunkers Passenger sector
by International Aviation
unit: EJ/yr
- Final Energy|Bunkers|Freight|International Shipping:
definition: final energy consumption by the freight transportation sector by International
Shipping
unit: EJ/yr
- Final Energy|Bunkers|Freight|International Aviation:
definition: final energy consumption by the freight transportation sector by International
Aviation
unit: EJ/yr
- Final Energy|Bunkers|International Aviation|Electricity:
definition: final energy consumption of electricity excluding transmission/distribution
losses in the Bunkers sector by International Aviation
Expand Down Expand Up @@ -3014,12 +2995,6 @@
- Energy Service|Residential|Floor Space:
definition: energy service demand for conditioned floor space in residential buildings
unit: bn m2
- Energy Service|Transportation|Freight:
definition: energy service demand for freight transport
unit: bn tkm/yr
- Energy Service|Transportation|Passenger:
definition: energy service demand for passenger transport
unit: bn pkm/yr
- Energy Service|Transportation|Freight|Domestic Aviation:
definition: energy service demand for freight transport on domestic aircrafts
unit: bn tkm/yr
Expand Down Expand Up @@ -3047,9 +3022,6 @@
- Energy Service|Transportation|Passenger|Railways:
definition: energy service demand for passenger transport on railways
unit: bn pkm/yr
- Energy Service|Transportation|Passenger|Road:
definition: energy service demand for passenger transport on roads
unit: bn pkm/yr
- Energy Service|Bunkers|Freight|International Shipping:
definition: energy service demand for freight transport operating on international
shipping routes
Expand Down Expand Up @@ -3233,11 +3205,6 @@
- Food Energy Supply|Livestock:
definition: calory food demand from livestock products
unit: EJ/yr
- Population|Risk of Hunger:
definition: Population at risk of hunger, calculated by multipling total population
and prevalence of undernourishment which is computed from a probability distribution
of daily dietary energy consumption and minimum dietary energy requirement.
unit: million
- Forestry Demand|Roundwood:
definition: forestry demand level for all roundwood (consumption, not production)
unit: million m3/yr
Expand Down Expand Up @@ -3654,16 +3621,9 @@
definition: investment into water-related infrastructure (other than for thermal
cooling and irrigation)
unit: billion US$2010/yr
- Land Cover:
definition: total land cover
unit: million ha
- Land Cover|Built-up Area:
definition: total built-up land associated with human settlement
unit: million ha
- Land Cover|Cropland:
definition: total arable land, i.e. land in bioenergy crop, food, and feed/fodder
crops, permant crops as well as other arable land (physical area)
unit: million ha
- Land Cover|Forest:
definition: managed and unmanaged forest area
unit: million ha
Expand Down Expand Up @@ -5547,17 +5507,6 @@
- Price|Drinking Water:
definition: price for m3 of drinking water distributed to the users
unit: US$2010/m3
- Population|Electricity Access:
definition: Population with access to electricity
unit: million
- Population|Relying on Solid Fuels:
definition: Population without access to electricity and relying on solid fuels
for heating-cooking
unit: million
- Population|Clean cooking Access:
definition: Population with access to improved cooking facilities (electric or
gas)
unit: million
- Investment|Infrastructure|Water|Distribution:
definition: Investment into water distribution infrastructure
unit: billion US$2010/yr
Expand Down Expand Up @@ -5585,18 +5534,6 @@
- Investment|Forestry:
definition: Investment into growing forests
unit: billion US$2010/yr
- Terrestrial Biodiversity|MSA|Vertebrates:
definition: Terrestrial biodiversity of vertebrate species measured in Mean Species
Abundance (MSA)
unit: '%'
- Terrestrial Biodiversity|MSA|Plants:
definition: Terrestrial biodiversity of plant species measured in Mean Species
Abundance (MSA)
unit: '%'
- Terrestrial Biodiversity|BII:
definition: Terrestrial biodiversity measured with Biodiversity Intactness Index
(BII)
unit: '%'
- Land Cover|Protected Area:
definition: Land-use coverage of officially protected area
unit: million ha
Expand Down
21 changes: 20 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,26 @@ def test_integration_common_definitions():
yaml.dump(config, file)

try:
nomenclature.DataStructureDefinition("definitions")
dsd = nomenclature.DataStructureDefinition("definitions")

existing_variables = list(dsd.variable)
legacy_variables = {}
for code, attrs in dsd.variable.items():
for project in ["navigate", "engage", "shape"]:
if project in attrs.extra_attributes:
legacy_var = attrs.__getattr__(project)
if legacy_var in existing_variables:
legacy_variables[legacy_var] = code

if legacy_variables:
error = [
f"'{legacy_var}' -> '{code}'" + "\n"
for legacy_var, code in legacy_variables.items()
]

raise ValueError(
"Deprecated variables from legacy projects:\n" f"{''.join(error)}"
)

finally:
pathlib.Path(config_file).unlink()

0 comments on commit 711addd

Please sign in to comment.