hestia-earth-models 0.61.4__py3-none-any.whl → 0.61.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of hestia-earth-models might be problematic. Click here for more details.

@@ -7,6 +7,7 @@ from functools import reduce
7
7
  from typing import Tuple
8
8
 
9
9
  from hestia_earth.utils.tools import list_sum, flatten
10
+ from hestia_earth.utils.model import linked_node
10
11
  from hestia_earth.schema import EmissionMethodTier
11
12
 
12
13
  from hestia_earth.models.log import logShouldRun, logRequirements, log_blank_nodes_id
@@ -14,6 +15,7 @@ from hestia_earth.models.utils.emission import _new_emission
14
15
  from hestia_earth.models.utils.blank_node import group_by_keys
15
16
  from hestia_earth.models.utils.completeness import _is_term_type_complete
16
17
  from hestia_earth.models.utils.term import get_electricity_grid_mix_terms
18
+ from hestia_earth.models.utils.cycle import cycle_end_year
17
19
  from .utils import get_emission, get_all_emission_terms
18
20
 
19
21
  REQUIREMENTS = {
@@ -52,7 +54,7 @@ def _emission(value: float, term_id: str, inputs: list, operation: dict) -> dict
52
54
  emission = _new_emission(term_id, MODEL)
53
55
  emission['value'] = [value]
54
56
  emission['methodTier'] = TIER
55
- emission["inputs"] = list(inputs)
57
+ emission['inputs'] = list(map(linked_node, inputs))
56
58
  if operation:
57
59
  emission["operation"] = operation
58
60
  return emission
@@ -65,23 +67,34 @@ def _grid_inputs(inputs: list, electricity_grid_terms: list):
65
67
  ]
66
68
 
67
69
 
68
- def _run_input(cycle: dict, inputs: list, emission_term_id: str, input_term: dict):
69
- inputs = _grid_inputs(inputs, [input_term])
70
- return [
71
- _emission(
72
- value=get_emission(
73
- term_id=emission_term_id,
74
- country=cycle.get("site", {}).get("country", {}).get("@id", ""),
75
- energy=list_sum(flatten([i.get("value", []) for i in op_inputs])),
76
- year=cycle.get("endDate", ""),
77
- model=MODEL
78
- ),
70
+ def _run_input(cycle: dict, inputs: list, emission_term_id: str, electricity_grid_term: dict):
71
+ electricity_grid_inputs = [electricity_grid_term]
72
+ inputs = _grid_inputs(inputs, electricity_grid_inputs)
73
+
74
+ def run(grouped_inputs: list):
75
+ input = grouped_inputs[0]
76
+ term_id = input.get('term', {}).get('@id')
77
+ input_value = list_sum(flatten(input.get('value', []) for input in grouped_inputs))
78
+ country_id = cycle.get("site", {}).get("country", {}).get("@id")
79
+ year = cycle_end_year(cycle)
80
+ value = get_emission(
79
81
  term_id=emission_term_id,
80
- inputs=[input_term],
81
- operation=op_inputs[0].get("operation")
82
+ country=country_id,
83
+ energy=input_value,
84
+ year=year,
85
+ model=MODEL
82
86
  )
83
- for op_inputs in _group_by_operation(inputs).values()
84
- ] if inputs else []
87
+
88
+ logRequirements(cycle, model=MODEL, term=term_id,
89
+ input_value=input_value,
90
+ emission_value=value)
91
+
92
+ should_run = all([input_value > 0, value])
93
+ logShouldRun(cycle, MODEL, term_id, should_run, methodTier=TIER)
94
+
95
+ return _emission(value, emission_term_id, electricity_grid_inputs, input.get("operation"))
96
+
97
+ return list(map(run, _group_by_operation(inputs).values() if inputs else []))
85
98
 
86
99
 
87
100
  def _group_by_operation(inputs: list) -> dict:
@@ -94,8 +107,8 @@ def _run_emission(cycle: dict, electricity_grid_terms: list, inputs: list, emiss
94
107
  cycle=cycle,
95
108
  inputs=inputs,
96
109
  emission_term_id=emission_term_id,
97
- input_term=input_term
98
- ) for input_term in electricity_grid_terms
110
+ electricity_grid_term=electricity_grid_term
111
+ ) for electricity_grid_term in electricity_grid_terms
99
112
  ])
100
113
 
101
114
 
@@ -104,11 +117,16 @@ def _should_run_emission(cycle: dict, electricity_grid_terms: list, term_id: str
104
117
  inputs = _grid_inputs(cycle.get('inputs', []), electricity_grid_terms)
105
118
  has_relevant_inputs = bool(inputs)
106
119
  has_country = bool(cycle.get("site", {}).get("country", {}))
120
+ has_end_date = bool(cycle.get("endDate"))
107
121
 
108
122
  logRequirements(cycle, model=MODEL, term=term_id,
109
- input_ids=log_blank_nodes_id(inputs))
123
+ term_type_electricityFuel_complete=term_type_complete,
124
+ input_ids=log_blank_nodes_id(inputs),
125
+ has_relevant_inputs=has_relevant_inputs,
126
+ has_country=has_country,
127
+ has_end_date=has_end_date)
110
128
 
111
- should_run = all([term_type_complete, has_relevant_inputs, has_country])
129
+ should_run = all([term_type_complete, has_relevant_inputs, has_country, has_end_date])
112
130
  logShouldRun(cycle, MODEL, term_id, should_run, methodTier=TIER)
113
131
  return should_run, inputs
114
132
 
@@ -10,27 +10,18 @@ from hestia_earth.models.data.ecoinventV3 import ecoinventV3_emissions
10
10
  EMBER_ECOINVENT_LOOKUP_NAME = "ember-ecoinvent-mapping.csv"
11
11
 
12
12
 
13
- def _lookup_data(term_id: str, grouping: str, country_id: str, year: int, lookup_name: str, **log_args):
13
+ def _lookup_data(term_id: str, grouping: str, country_id: str, year: str, lookup_name: str, **log_args):
14
14
  lookup = download_lookup(lookup_name)
15
- data = get_table_value(lookup, 'termid', country_id, column_name(grouping))
16
- debugMissingLookup(lookup_name, 'termid', country_id, grouping, data, term=term_id, **log_args)
17
- percentage = extract_grouped_data(data, str(year))
15
+ column = column_name(grouping)
16
+ data = get_table_value(lookup, 'termid', country_id, column)
17
+ percentage = extract_grouped_data(data, year)
18
+ debugMissingLookup(lookup_name, 'termid', country_id, column, percentage, year=year, term=term_id, **log_args)
18
19
  return safe_parse_float(percentage, None)
19
20
 
20
21
 
21
22
  def _convert_name(name: str) -> str: return name.replace(";", ",")
22
23
 
23
24
 
24
- def _safe_parse_int(value: str, default=0):
25
- """
26
- Parse a string into an int.
27
- """
28
- try:
29
- return int(value)
30
- except ValueError:
31
- return default
32
-
33
-
34
25
  def _zero_from_non_numeric(value: Any) -> float:
35
26
  try:
36
27
  return float(value)
@@ -62,7 +53,7 @@ def _get_emission_rate_per_source(ember_ecoinvent_mapping: Dict, emission_term_i
62
53
  }
63
54
 
64
55
 
65
- def get_emission(term_id: str, country: str, year: str, energy: float, model: str) -> float:
56
+ def get_emission(term_id: str, country: str, year: int, energy: float, model: str) -> float:
66
57
  """
67
58
  Get the <term_id> emissions in kg for the energy consumed.
68
59
  a: ecoInventId of each source - from "ember-ecoinvent-mapping.csv"
@@ -89,7 +80,7 @@ def get_emission(term_id: str, country: str, year: str, energy: float, model: st
89
80
  term_id=source,
90
81
  grouping=source,
91
82
  country_id=country,
92
- year=_safe_parse_int(year),
83
+ year=str(year),
93
84
  lookup_name="region-ember-energySources.csv",
94
85
  model=model
95
86
  )
@@ -91,7 +91,11 @@ def _should_run(cycle: dict):
91
91
  weightAtMaturity=lookup_value,
92
92
  liveweightPerHead=liveweightPerHead_value)
93
93
 
94
- should_run = all([country_id, value.get('value') is not None, lookup_value >= liveweightPerHead_value])
94
+ should_run = all([
95
+ country_id,
96
+ lookup_value is not None,
97
+ lookup_value is None or liveweightPerHead_value is None or lookup_value >= liveweightPerHead_value
98
+ ])
95
99
  logShouldRun(cycle, MODEL, term_id, should_run)
96
100
 
97
101
  return should_run
@@ -694,7 +694,7 @@ def _should_run(cycle: dict) -> tuple:
694
694
  """
695
695
  cycle_id = cycle.get("@id")
696
696
  site = get_site(cycle)
697
- cycles = related_cycles(site.get("@id"))
697
+ cycles = related_cycles(site)
698
698
 
699
699
  grouped_soc_stocks = _get_grouped_soc_stocks(site)
700
700
  grouped_soc_stock_changes = _calc_grouped_soc_stock_changes(grouped_soc_stocks)
@@ -1891,11 +1891,12 @@ def _get_carbon_sources_from_cycles(cycles: dict) -> list[CarbonSource]:
1891
1891
  inputs_and_products = non_empty_list(flatten(
1892
1892
  [cycle.get("inputs", []) + cycle.get("products", []) for cycle in cycles]
1893
1893
  ))
1894
+ crop_residue_terms = get_crop_residue_incorporated_or_left_on_field_terms()
1894
1895
 
1895
1896
  return non_empty_list([
1896
1897
  _iterate_carbon_source(node) for node in inputs_and_products
1897
1898
  if any([
1898
- node.get("term", {}).get("@id") in get_crop_residue_incorporated_or_left_on_field_terms(),
1899
+ node.get("term", {}).get("@id") in crop_residue_terms,
1899
1900
  node.get("term", {}).get("termType") in CARBON_SOURCE_TERM_TYPES
1900
1901
  ])
1901
1902
  ])
@@ -3236,9 +3237,10 @@ def _get_carbon_input_kwargs(
3236
3237
  cumulative_threshold=MIN_AREA_THRESHOLD
3237
3238
  )
3238
3239
 
3240
+ cover_crop_property_terms = get_cover_crop_property_terms()
3239
3241
  has_cover_crop = cumulative_nodes_match(
3240
3242
  lambda node: any(
3241
- get_node_property(node, term_id, False).get("value", False) for term_id in get_cover_crop_property_terms()
3243
+ get_node_property(node, term_id, False).get("value", False) for term_id in cover_crop_property_terms
3242
3244
  ),
3243
3245
  land_cover_nodes,
3244
3246
  cumulative_threshold=MIN_AREA_THRESHOLD
@@ -3515,7 +3517,7 @@ def _should_run(site: dict) -> tuple[bool, dict]:
3515
3517
  site_type = site.get("siteType", "")
3516
3518
  management_nodes = site.get("management", [])
3517
3519
  measurement_nodes = site.get("measurements", [])
3518
- cycles = related_cycles(site.get("@id"))
3520
+ cycles = related_cycles(site)
3519
3521
 
3520
3522
  has_management = len(management_nodes) > 0
3521
3523
  has_measurements = len(measurement_nodes) > 0
@@ -3768,14 +3770,16 @@ def _get_grouped_climate_measurements(grouped_measurements: dict) -> dict:
3768
3770
 
3769
3771
 
3770
3772
  def _get_grouped_irrigated_monthly(grouped_cycles: dict) -> dict:
3773
+ irrigated_terms = get_irrigated_terms()
3774
+
3771
3775
  return {
3772
3776
  year: {
3773
- _InventoryKey.IRRIGATED_MONTHLY: _get_irrigated_monthly(year, cycles)
3777
+ _InventoryKey.IRRIGATED_MONTHLY: _get_irrigated_monthly(year, cycles, irrigated_terms)
3774
3778
  } for year, cycles in grouped_cycles.items()
3775
3779
  }
3776
3780
 
3777
3781
 
3778
- def _get_irrigated_monthly(year: int, cycles: list[dict]) -> list[bool]:
3782
+ def _get_irrigated_monthly(year: int, cycles: list[dict], irrigated_terms: list[str]) -> list[bool]:
3779
3783
  # Get practice nodes and add "startDate" and "endDate" from cycle if missing.
3780
3784
  irrigation_nodes = non_empty_list(flatten([
3781
3785
  [
@@ -3793,7 +3797,7 @@ def _get_irrigated_monthly(year: int, cycles: list[dict]) -> list[bool]:
3793
3797
  return [
3794
3798
  cumulative_nodes_term_match(
3795
3799
  grouped_nodes.get(year, {}).get(month, []),
3796
- target_term_ids=get_irrigated_terms(),
3800
+ target_term_ids=irrigated_terms,
3797
3801
  cumulative_threshold=MIN_AREA_THRESHOLD
3798
3802
  ) for month in range(1, 13)
3799
3803
  ]
@@ -3862,12 +3866,13 @@ def _check_is_paddy_rice(cycles: list[dict]) -> bool:
3862
3866
  default_node_value=MIN_YIELD_THRESHOLD
3863
3867
  ) for cycle in cycles)
3864
3868
 
3869
+ reice_terms = get_upland_rice_crop_terms() + get_upland_rice_land_cover_terms()
3865
3870
  has_upland_rice_products = any(cumulative_nodes_term_match(
3866
3871
  filter_list_term_type(
3867
3872
  cycle.get("products", []) + cycle.get("practices", []),
3868
3873
  [TermTermType.CROP, TermTermType.FORAGE, TermTermType.LANDCOVER]
3869
3874
  ),
3870
- target_term_ids=get_upland_rice_crop_terms() + get_upland_rice_land_cover_terms(),
3875
+ target_term_ids=reice_terms,
3871
3876
  cumulative_threshold=MIN_YIELD_THRESHOLD,
3872
3877
  default_node_value=MIN_YIELD_THRESHOLD
3873
3878
  ) for cycle in cycles)
@@ -1,23 +1,20 @@
1
+ import os
1
2
  from hestia_earth.models.utils import measurement, site
2
3
 
3
4
  from .mock_search import mock as mock_search
4
5
 
6
+ CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
7
+ RESULTS_PATH = os.path.join(CURRENT_DIR, 'search-results.json')
5
8
 
6
- def enable_mock(node: dict = None):
7
- """
8
- Mock calls to Hestia API using pre-loaded search results.
9
9
 
10
- Parameters
11
- ----------
12
- node : dict
13
- Optional - The node used to run calculations. This is especially useful when running calculations on a Site.
14
- """
10
+ def enable_mock(filepath: str, node: dict = None):
15
11
  # apply mocks on search results
16
- mock_search()
17
- # skip fetch bibliography data
18
- measurement.include_source = lambda v, *args: v
12
+ mock_search(filepath)
19
13
 
20
14
  if node is not None:
15
+ # skip fetch bibliography data
16
+ measurement.include_source = lambda v, *args: v
17
+
21
18
  # mock related cycles to return the current node
22
19
  fake_node = {'@id': 'fake-cycle', **node}
23
20
  site.download_hestia = lambda *args: fake_node
@@ -1,12 +1,9 @@
1
- import os
2
1
  from inspect import getmembers, isfunction
3
2
  import json
3
+ from hestia_earth.utils.tools import flatten
4
4
 
5
- from hestia_earth.models.log import logger
6
5
  from hestia_earth.models.utils import term
7
6
 
8
- CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
9
- RESULTS_PATH = os.path.join(CURRENT_DIR, 'search-results.json')
10
7
  IGNORE_FUNC = ['get_lookup_value', 'get_table_value']
11
8
 
12
9
 
@@ -14,7 +11,7 @@ def _map_results(results):
14
11
  # returning the whole term
15
12
  return [results] if isinstance(results, dict) else (
16
13
  {'@type': 'Term', '@id': results} if isinstance(results, str) else
17
- list(map(_map_results, results)) if isinstance(results, list) else
14
+ flatten(map(_map_results, results)) if isinstance(results, list) else
18
15
  None
19
16
  )
20
17
 
@@ -48,24 +45,27 @@ def create_search_results():
48
45
  return list(map(_create_search_result, funcs))
49
46
 
50
47
 
51
- def _load_results():
52
- with open(RESULTS_PATH) as f:
48
+ def _load_results(filepath: str):
49
+ with open(filepath) as f:
53
50
  return json.load(f)
54
51
 
55
52
 
56
- def _find_search_result(query: dict):
57
- search_results = _load_results()
53
+ def _find_search_result(filepath: str, query: dict):
54
+ search_results = _load_results(filepath)
58
55
  res = next((n for n in search_results if n['query'] == query), {})
59
- logger.debug('mocking search result: %s', res)
60
56
  return res.get('results', [])
61
57
 
62
58
 
63
- def _fake_search(query: dict, *_a, **_b): return _find_search_result(query)
59
+ def _fake_search(filepath: str):
60
+ def mock(query: dict, *_a, **_b): return _find_search_result(filepath, query)
61
+ return mock
64
62
 
65
63
 
66
- def _fake_find_node(_n, query: dict, *_a, **_b): return _find_search_result(query)
64
+ def _fake_find_node(filepath: str):
65
+ def mock(_n, query: dict, *_a, **_b): return _find_search_result(filepath, query)
66
+ return mock
67
67
 
68
68
 
69
- def mock():
70
- term.search = _fake_search
71
- term.find_node = _fake_find_node
69
+ def mock(filepath: str):
70
+ term.search = _fake_search(filepath)
71
+ term.find_node = _fake_find_node(filepath)
@@ -1113,26 +1113,22 @@
1113
1113
  }
1114
1114
  },
1115
1115
  "results": [
1116
- [
1117
- {
1118
- "@type": "Term",
1119
- "name": "Electricity, grid, renewable mix",
1120
- "termType": "electricity",
1121
- "@id": "electricityGridRenewableMix",
1122
- "units": "kWh",
1123
- "_score": 27.711746
1124
- }
1125
- ],
1126
- [
1127
- {
1128
- "@type": "Term",
1129
- "name": "Electricity, grid, market mix",
1130
- "termType": "electricity",
1131
- "@id": "electricityGridMarketMix",
1132
- "units": "kWh",
1133
- "_score": 27.711746
1134
- }
1135
- ]
1116
+ {
1117
+ "@type": "Term",
1118
+ "name": "Electricity, grid, renewable mix",
1119
+ "termType": "electricity",
1120
+ "@id": "electricityGridRenewableMix",
1121
+ "units": "kWh",
1122
+ "_score": 27.711746
1123
+ },
1124
+ {
1125
+ "@type": "Term",
1126
+ "name": "Electricity, grid, market mix",
1127
+ "termType": "electricity",
1128
+ "@id": "electricityGridMarketMix",
1129
+ "units": "kWh",
1130
+ "_score": 27.711746
1131
+ }
1136
1132
  ]
1137
1133
  },
1138
1134
  {
@@ -1394,7 +1390,7 @@
1394
1390
  "@type": "Term",
1395
1391
  "name": "Generic crop, seed",
1396
1392
  "@id": "genericCropSeed",
1397
- "_score": 25.694489
1393
+ "_score": 25.694498
1398
1394
  }
1399
1395
  ]
1400
1396
  },
@@ -0,0 +1,32 @@
1
+ """
2
+ Preload all search requests to avoid making the same searches many times while running models.
3
+ """
4
+ import json
5
+
6
+ from .log import logger
7
+ from .mocking.mock_search import create_search_results
8
+ from .mocking import RESULTS_PATH, enable_mock as _mock
9
+
10
+
11
+ def enable_preload(filepath: str = RESULTS_PATH, node: dict = None):
12
+ """
13
+ Prefetch calls to Hestia API in a local file.
14
+
15
+ Parameters
16
+ ----------
17
+ filepath : str
18
+ The path of the file containing the search results. Defaults to current library folder.
19
+ node : dict
20
+ Optional - The node used to run calculations. This is especially useful when running calculations on a Site.
21
+ """
22
+ logger.debug('Preloading search results and storing in %s', filepath)
23
+
24
+ # build the search results
25
+ data = create_search_results()
26
+
27
+ # store in file
28
+ with open(filepath, 'w') as f:
29
+ f.write(json.dumps(data, indent=2, ensure_ascii=False))
30
+
31
+ # enable mock search results from file
32
+ _mock(filepath=filepath, node=node)
@@ -198,7 +198,7 @@ def _get_relevant_inputs(cycles: List[dict]) -> List:
198
198
 
199
199
  def _should_run(site: dict):
200
200
  # Only get related cycles once.
201
- cycles = related_cycles(site.get("@id"))
201
+ cycles = related_cycles(site)
202
202
 
203
203
  products_land_cover = [
204
204
  _extract_node_value(
@@ -44,7 +44,7 @@ def region_level_1_id(term_id: str):
44
44
  def is_site(site: dict): return site.get('@type', site.get('type')) == SchemaType.SITE.value
45
45
 
46
46
 
47
- def related_cycles(site_id: str):
47
+ def related_cycles(site: dict):
48
48
  """
49
49
  Get the list of `Cycle` related to the `Site`.
50
50
  Gets the `recalculated` data if available, else `original`.
@@ -59,8 +59,9 @@ def related_cycles(site_id: str):
59
59
  list[dict]
60
60
  The related `Cycle`s as `dict`.
61
61
  """
62
- nodes = find_related(SchemaType.SITE, site_id, SchemaType.CYCLE)
63
- return non_empty_list(map(lambda node: _load_calculated_node(node, SchemaType.CYCLE), nodes or []))
62
+ cached_nodes = [n for n in cached_value(site, 'related', []) if n.get('@type') == SchemaType.CYCLE.value]
63
+ related_nodes = cached_nodes or find_related(SchemaType.SITE, site.get('@id'), SchemaType.CYCLE) or []
64
+ return non_empty_list(map(lambda node: _load_calculated_node(node, SchemaType.CYCLE), related_nodes))
64
65
 
65
66
 
66
67
  def _cycle_year(cycle: dict, key: str):
@@ -73,7 +74,7 @@ def related_years(site: dict):
73
74
  sorted(non_empty_list(set(flatten([
74
75
  _cycle_year(cycle, 'startDate'),
75
76
  _cycle_year(cycle, 'endDate')
76
- ] for cycle in related_cycles(site.get('@id'))))))
77
+ ] for cycle in related_cycles(site)))))
77
78
  )
78
79
 
79
80
 
@@ -1 +1 @@
1
- VERSION = '0.61.4'
1
+ VERSION = '0.61.6'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hestia-earth-models
3
- Version: 0.61.4
3
+ Version: 0.61.6
4
4
  Summary: Hestia's set of modules for filling gaps in the activity data using external datasets (e.g. populating soil properties with a geospatial dataset using provided coordinates) and internal lookups (e.g. populating machinery use from fuel use). Includes rules for when gaps should be filled versus not (e.g. never gap fill yield, gap fill crop residue if yield provided etc.).
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-engine-models
6
6
  Author: Hestia Team
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.6
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: hestia-earth.schema ==28.*
15
- Requires-Dist: hestia-earth.utils >=0.12.6
15
+ Requires-Dist: hestia-earth.utils >=0.13.0
16
16
  Requires-Dist: python-dateutil >=2.8.1
17
17
  Requires-Dist: CurrencyConverter ==0.16.8
18
18
  Requires-Dist: haversine >=2.7.0
@@ -53,6 +53,13 @@ from hestia_earth.models.pooreNemecek2018 import run
53
53
  run('no3ToGroundwaterSoilFlux', cycle_data)
54
54
  ```
55
55
 
56
+ Additionally, to reduce the number of queries to the HESTIA API and run the models faster, prefetching can be enabled:
57
+ ```python
58
+ from hestia_earth.models.preload_requests import enable_preload
59
+
60
+ enable_preload()
61
+ ```
62
+
56
63
  ### Using Spatial Models
57
64
 
58
65
  We have models that can gap-fill geographical information on a `Site`. If you want to use these models:
@@ -2,8 +2,9 @@ hestia_earth/__init__.py,sha256=G-d438vPx7m_ks5e9XTtM3u7LDRO5dSSukibukWmyPM,56
2
2
  hestia_earth/models/__init__.py,sha256=qEFeq3yuf3lQKVseALmL8aPM8fpCS54B_5pry00M3hk,76
3
3
  hestia_earth/models/cache_sites.py,sha256=KQp9cUKE-aIcYJoMWEtKFYS8gBFfsx5LKQhqoWpUSoM,6065
4
4
  hestia_earth/models/log.py,sha256=b63I3qyTtQs17xxbq8RI0Fv2lvZ1oDZ9k0njhxqiFFk,3459
5
+ hestia_earth/models/preload_requests.py,sha256=elhYQTxBVuFlZROWvZ3yErDzzMLdMUIjBhmpdaTUSi8,1012
5
6
  hestia_earth/models/requirements.py,sha256=znNZJAhwX2iYiKcAQXPftY7z_1MsNa0QxCXkXyHm_U0,17363
6
- hestia_earth/models/version.py,sha256=bmj37UzUxTNwdA4_HAC8XTpOEahYZizn-7UE1L4CEyc,19
7
+ hestia_earth/models/version.py,sha256=dBBOYPfbTEoLiqkPnN90IsOKd58x-WvuZYLLtlCWK5k,19
7
8
  hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
8
9
  hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=mrh8seYSYdTgcMDCETLiknuPeJehg071YoG4UiyW0yU,4404
9
10
  hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=_Rbngu0DzHKa62JwBl58ZC_ui1zLF2que_nB7ukhOQc,3392
@@ -106,8 +107,8 @@ hestia_earth/models/data/ecoinventV3/__init__.py,sha256=oevyurRuioXy_CsQCtG-S_FX
106
107
  hestia_earth/models/deRuijterEtAl2010/__init__.py,sha256=lbH6mB98dmZZlwdZctNYtEmVwAow957l80Dv7JSPDsI,418
107
108
  hestia_earth/models/deRuijterEtAl2010/nh3ToAirCropResidueDecomposition.py,sha256=2z10WqMsGUDDO8xJ3lmXvSUHgzz2t6PPRDha5NHoT5s,3291
108
109
  hestia_earth/models/ecoinventV3/__init__.py,sha256=nSktsE0c9ohx1FyDEEi-YlnGgMGNd-actCwPs_htzC0,6309
109
- hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py,sha256=-5FCTS2EA8D7hbuqsTN0E1SOTPwJ5ChfJBDJapbtzGc,4388
110
- hestia_earth/models/ecoinventV3AndEmberClimate/utils.py,sha256=Vh8cGkgvbcq3b8tE8Y_8LI1PYqrt9E53fPwInKoYmaY,4577
110
+ hestia_earth/models/ecoinventV3AndEmberClimate/__init__.py,sha256=H5fxfUy6HLHxRgvG3oPZ8pnLbq3Axm0Ejkp9CQ2UGlM,5306
111
+ hestia_earth/models/ecoinventV3AndEmberClimate/utils.py,sha256=mV55GMUxe_fORBVDWGBxOqmH2JVDKhLoKodJ7UzC38c,4420
111
112
  hestia_earth/models/emepEea2019/__init__.py,sha256=l90-pWrqIzt1ap1WNk0gF4iZeF5_TSG62hE83bIi4rQ,412
112
113
  hestia_earth/models/emepEea2019/co2ToAirFuelCombustion.py,sha256=DfoGlB5HjA1gafO0OutJjfsA6yPP_PsAd-p16evwCiQ,1609
113
114
  hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py,sha256=R3lRF5-Md4Jd7irvTe8WJZJPc9-wa1pD6UWVk7lnGtQ,1616
@@ -219,7 +220,7 @@ hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py,sha256=khX90Njkmlvos
219
220
  hestia_earth/models/ipcc2019/ch4ToAirExcreta.py,sha256=IzYHdnzT8Z-WQGoZIt9-O98VqriA5rKr38He_TbYadk,6723
220
221
  hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py,sha256=TJ4J7VA5n4RPrJYZQeR3lc3ZoCw7T1E5Cb1XJewr834,7331
221
222
  hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py,sha256=7z0zdqiiWQwkyJCgSNMoK2mft3cJkTRlqwKrMuSKdWI,2454
222
- hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChangeManagementChange.py,sha256=kWrWxhr-48jmbyt57EIjth8IWsl5-Yt1I-uTBSUqFuA,25381
223
+ hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChangeManagementChange.py,sha256=X-pUmOa7oy6uvgr0cMDeKRLVIQvh-4bjjrronvd0F3k,25370
223
224
  hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py,sha256=071H3ykjzJFW2K5PKvbAaeIj0aL8LTzMiG_pIeYEpEc,3520
224
225
  hestia_earth/models/ipcc2019/croppingDuration.py,sha256=_jlFrTNDOARH2_g8s4dzuaCoLHSX2BHzSQd3uuQN32Y,3173
225
226
  hestia_earth/models/ipcc2019/ligninContent.py,sha256=wp5EbCthCDAKyvPBfZULS9-uKEY58TQQ8ey1pf-juv8,7267
@@ -240,13 +241,13 @@ hestia_earth/models/ipcc2019/no3ToGroundwaterInorganicFertiliser.py,sha256=eyPfy
240
241
  hestia_earth/models/ipcc2019/no3ToGroundwaterOrganicFertiliser.py,sha256=px2SN-uaus2cftXzlsYCUAxLuon6BnDXmaFI9xhQrgU,3347
241
242
  hestia_earth/models/ipcc2019/noxToAirInorganicFertiliser.py,sha256=fmmFgjtvOD2TrrLY03jYly_KvDnCsAXqhL_tmZQQt-A,4480
242
243
  hestia_earth/models/ipcc2019/noxToAirOrganicFertiliser.py,sha256=9dx_MRTwJGxJRq6mj2EJQMdQ2w6j7lw0fQk0If_cIGc,4152
243
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=omxrtnAZ58qHQYIhi38R7VFn7SRzf8Kk89KgP0VELFQ,141507
244
+ hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=x2U3FwZuM-lVDCzXmj5eCFOt8b3DIszeebnYIFWCeBc,141712
244
245
  hestia_earth/models/ipcc2019/pastureGrass.py,sha256=Q3uX7IcTk0PmzxqEhU3JAcHb5LnUymZbmdRFP9xXsfo,8713
245
246
  hestia_earth/models/ipcc2019/pastureGrass_utils.py,sha256=nUJYYkovzF7QD4LeUqhV5mBYFKdrhxeG4gyPRv0Xpuk,16002
246
247
  hestia_earth/models/ipcc2019/utils.py,sha256=MSDMu15D9DnilFUgi4_6jYXC0FaKso3OODauGTMB6hs,6229
247
248
  hestia_earth/models/ipcc2019/animal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
248
249
  hestia_earth/models/ipcc2019/animal/pastureGrass.py,sha256=xPtuTiKeAvBhv9d7B6Upw_cbP6YxKykVJ3_p0S_EtZg,10689
249
- hestia_earth/models/ipcc2019/animal/weightAtMaturity.py,sha256=PlT11hX2nBIwDMsQs3E0XeJZ5BCA023_ibpXPreTncI,3558
250
+ hestia_earth/models/ipcc2019/animal/weightAtMaturity.py,sha256=5smSAmKVCIlELCD6S_3I16YuSWNFhcClGDOdvrIuYsE,3657
250
251
  hestia_earth/models/ipcc2021/__init__.py,sha256=VTgGFKhwMmk_nuI1RRq0in27fHYVPBonlXlPK00K8no,409
251
252
  hestia_earth/models/ipcc2021/gwp100.py,sha256=v-DYU-11XnWI1Ns1GEiKrJqL3JafxvhTsLmuBuFcxJU,1021
252
253
  hestia_earth/models/jarvisAndPain1994/__init__.py,sha256=ercUwy29sV7oPIESj8UjsGB5lqiBCss9OZcbjxeeG8E,418
@@ -357,9 +358,9 @@ hestia_earth/models/linkedImpactAssessment/landTransformationFromOtherNaturalVeg
357
358
  hestia_earth/models/linkedImpactAssessment/landTransformationFromPermanentPasture100YearAverageInputsProduction.py,sha256=7btlXl5PL47qIjfs-w_xLZY_nsRnJAwTREtt8LpY6UI,1052
358
359
  hestia_earth/models/linkedImpactAssessment/landTransformationFromPermanentPasture20YearAverageInputsProduction.py,sha256=pdluhfRQuJK0EHq-L0s0TOf37tvOQYB-M-wZiuSbarw,1050
359
360
  hestia_earth/models/linkedImpactAssessment/utils.py,sha256=dGwGc2d-8_WQElTpfyPmz5vQtL-LHQRmiZnCTuPXMDs,1876
360
- hestia_earth/models/mocking/__init__.py,sha256=kmSeOTSvurMUxw7Ajhf3G-SVPQ1NgmirMTk4TSOEicY,765
361
- hestia_earth/models/mocking/mock_search.py,sha256=V-ycVBTkJu7PP37Ivy_16hpKBV4aEtJb5S9DfChPNSU,2038
362
- hestia_earth/models/mocking/search-results.json,sha256=FuWHaK_s8PNp46cP3fBfE7kwkm4Tu_HlMGz8Y62UWLk,41248
361
+ hestia_earth/models/mocking/__init__.py,sha256=n3Fkkrvh8zHNWiJZmnfQ7WZ91JRzAO9P6pSG1JpwtXo,687
362
+ hestia_earth/models/mocking/mock_search.py,sha256=dBCDRfbZmbMLKP21u_VYkxyimomqs-zztjX-_ZNKuuM,2036
363
+ hestia_earth/models/mocking/search-results.json,sha256=Em88H12lmHhXF5ocZ0Qtm1ALNqW5GZXl2gRhtATc3Wk,41184
363
364
  hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
364
365
  hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=Qt-mel4dkhK6N5uUOutNOinCTFjbjtGzITaaI0LvYc4,2396
365
366
  hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=JT0RybbvWVlo01FO8K0Yj41HrEaJT3Kj1xfayr2X-xw,2315
@@ -458,7 +459,7 @@ hestia_earth/models/site/brackishWater.py,sha256=dl-R_vwFlXwAkir3grhCYZTLf05FYrf
458
459
  hestia_earth/models/site/cationExchangeCapacityPerKgSoil.py,sha256=0eH4A-tXJ0hvIkiYXWxlx8TfrdbIKUGYUDk97-yQJgg,3653
459
460
  hestia_earth/models/site/flowingWater.py,sha256=0ZuSXMr3EUTY3wsy8hdfuXeZcNX-n3D45MfX3dwyaeA,1728
460
461
  hestia_earth/models/site/freshWater.py,sha256=z-C_Il0U6UhZUQUPwh72Z0vixmSrUNEmBN5Lz-nl9_w,1254
461
- hestia_earth/models/site/management.py,sha256=F_zcXlW100pwdSfRyT8GxB_l1LMnAWzyVMe40qjV9ws,8843
462
+ hestia_earth/models/site/management.py,sha256=o9WIvbxip6B-jbQdgko6H2l1neQ0Z5ZpcPJmM5gcYlw,8832
462
463
  hestia_earth/models/site/netPrimaryProduction.py,sha256=UIIQkYd911qVzrWjxBLrC37e-RARIVgDwLdARY9BuLw,1849
463
464
  hestia_earth/models/site/organicCarbonPerHa.py,sha256=-qQWy1BI4vZJJNMS1RCluZ34dOTqR0lblXSOZLjkhOo,14362
464
465
  hestia_earth/models/site/organicCarbonPerKgSoil.py,sha256=t--wAshiAKS-JvEKhLFRadGvgSBv5NFZ68jdyms_wh4,1945
@@ -547,7 +548,7 @@ hestia_earth/models/utils/practice.py,sha256=tNadOzsrNlCEt801B815XaruJXzZ5yPASam
547
548
  hestia_earth/models/utils/product.py,sha256=H9UqJNzTqtMWXDQnbRkZlTpv_hg4s-Tya469fBk8InA,10143
548
549
  hestia_earth/models/utils/productivity.py,sha256=bUBVCZInGqHuHZvHDSYPQkjWXQxOtTjEk-1-f_BsFOo,594
549
550
  hestia_earth/models/utils/property.py,sha256=gHPEmy3Sw599ox64Gv-LCvjhP1THlBXBaBlTOK5lvog,5060
550
- hestia_earth/models/utils/site.py,sha256=oLuai82WdN_qAAG09XmLEbhf7-jr7AT7BGxRBUs1Bno,3292
551
+ hestia_earth/models/utils/site.py,sha256=XIpPGqByjpfrPxxcqt9iMAcIpsPUBfAENFnf8fz0iEE,3429
551
552
  hestia_earth/models/utils/source.py,sha256=HhZkvQoFdy6j6FC2cwP5EbHXHFM4pif9gpnuzeDwEh4,1746
552
553
  hestia_earth/models/utils/temperature.py,sha256=ljlG4-yCgFFb6LRZweb18cZKLrr7K2mqd4E4Hz_D1f8,476
553
554
  hestia_earth/models/utils/term.py,sha256=n_T1Qp_0z9ZUgrbVACNKue-5yDePOCkDw8g8dlMKSTM,17763
@@ -557,7 +558,7 @@ hestia_earth/models/webbEtAl2012AndSintermannEtAl2012/nh3ToAirOrganicFertiliser.
557
558
  tests/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
558
559
  tests/models/test_cache_sites.py,sha256=AsZSGb4ruFqag74wRaQxpoZxbMxexPY8q8sMb2ergzg,1986
559
560
  tests/models/test_ecoinventV3.py,sha256=gde7ny9ThMmezkDcTmS3ZKn82MNOaNSrpMcbkTjFJxk,1491
560
- tests/models/test_ecoinventV3AndEmberClimate.py,sha256=hMyCkDMLzUihfQpSTVPlycerqiDplBCJZlW1SrJxGjo,3622
561
+ tests/models/test_ecoinventV3AndEmberClimate.py,sha256=_V4d01j6itpwa_22H2GbSlRfOLN5KZLCxCIjkPdwoNg,3660
561
562
  tests/models/test_emissionNotRelevant.py,sha256=YXTdRfcdR_JepHuj2P3Y3r0aFMKNOmsXQHY48tmLTQo,1316
562
563
  tests/models/agribalyse2016/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
563
564
  tests/models/agribalyse2016/test_fuelElectricity.py,sha256=u_wNlqngJc8NELPr16kYsYQ-_2PcL8BnrfJucY7dccU,1353
@@ -1064,13 +1065,13 @@ tests/models/utils/test_measurement.py,sha256=UGCUzuc3gHltehpuOA7dj0DJJY4xcVrQOJ
1064
1065
  tests/models/utils/test_practice.py,sha256=ILaxkb3qICor9AquAGYiOtA-YKnq0hppmJQzNC_VNyA,612
1065
1066
  tests/models/utils/test_product.py,sha256=kwvgAeeEoRgkeStX0zQcFd-4DJhoUhX6Apaks0MU2L0,2305
1066
1067
  tests/models/utils/test_property.py,sha256=t2npw86IK7C6G4ypiPtanFi0db4PB7G5VBR1GjRGl34,618
1067
- tests/models/utils/test_site.py,sha256=5nCW3onTk6GF_N-h4NYDrlSoxHhXY2GVMbjaDsicbSE,1187
1068
+ tests/models/utils/test_site.py,sha256=9MXbP5JXl0mYaH-yVHJINnZu_MYwj-ogsJWZ3XTHxas,1196
1068
1069
  tests/models/utils/test_source.py,sha256=mv3vHZV5cjpoLA2I1109-YUkuzAiuhbRSnv_76_f0CA,631
1069
1070
  tests/models/utils/test_term.py,sha256=M5Sa26v2gzQYbZ4H_fo7DspnaCx__-WtL-MULGapCWk,3509
1070
1071
  tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1071
1072
  tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
1072
- hestia_earth_models-0.61.4.dist-info/LICENSE,sha256=AC7h7GAgCZGJK_Tzh6LUCrML9gQEfowWwecEw2w54QM,1154
1073
- hestia_earth_models-0.61.4.dist-info/METADATA,sha256=KxbGs2wQWB_3PbEeCUhb6j5W5DB9X6C-IJVMuFC7P8A,3134
1074
- hestia_earth_models-0.61.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1075
- hestia_earth_models-0.61.4.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
1076
- hestia_earth_models-0.61.4.dist-info/RECORD,,
1073
+ hestia_earth_models-0.61.6.dist-info/LICENSE,sha256=AC7h7GAgCZGJK_Tzh6LUCrML9gQEfowWwecEw2w54QM,1154
1074
+ hestia_earth_models-0.61.6.dist-info/METADATA,sha256=1nFjqi4tnhv8KZF_xP_-yxVdOx2dZZjeadqlh3M_QW4,3350
1075
+ hestia_earth_models-0.61.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1076
+ hestia_earth_models-0.61.6.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
1077
+ hestia_earth_models-0.61.6.dist-info/RECORD,,
@@ -10,8 +10,8 @@ from hestia_earth.models.ecoinventV3AndEmberClimate import MODEL, _should_run_em
10
10
  class_path = f"hestia_earth.models.{MODEL}"
11
11
  fixtures_folder = f"{fixtures_path}/{MODEL}"
12
12
 
13
- cycle_with_country = {"site": {"country": {"@type": "Term", "termType": "region"}}}
14
- cycle_without_country = {"site": {"country": {}}}
13
+ cycle_with_country = {"endDate": "2010", "site": {"country": {"@type": "Term", "termType": "region"}}}
14
+ cycle_without_country = {"endDate": "2010", "site": {"country": {}}}
15
15
  ELECTRICITY_TERMS = [
16
16
  {"@type": "Term", "@id": "electricityGridMarketMix"},
17
17
  {"@type": "Term", "@id": "electricityGridRenewableMix"}
@@ -21,7 +21,7 @@ def test_region_level_1_id():
21
21
  @patch(f"{class_path}.find_related", return_value=[CYCLE])
22
22
  @patch(f"{class_path}._load_calculated_node", return_value=CYCLE)
23
23
  def test_related_cycles(*args):
24
- assert related_cycles('id') == [CYCLE]
24
+ assert related_cycles({'@id': 'id'}) == [CYCLE]
25
25
 
26
26
 
27
27
  def test_valid_site_type():