hestia-earth-aggregation 0.21.17__tar.gz → 0.21.18__tar.gz

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.
Files changed (44) hide show
  1. {hestia_earth_aggregation-0.21.17/hestia_earth_aggregation.egg-info → hestia_earth_aggregation-0.21.18}/PKG-INFO +1 -1
  2. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/management.py +33 -2
  3. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/queries.py +1 -1
  4. hestia_earth_aggregation-0.21.18/hestia_earth/aggregation/version.py +1 -0
  5. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18/hestia_earth_aggregation.egg-info}/PKG-INFO +1 -1
  6. hestia_earth_aggregation-0.21.17/hestia_earth/aggregation/version.py +0 -1
  7. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/LICENSE +0 -0
  8. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/MANIFEST.in +0 -0
  9. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/README.md +0 -0
  10. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/__init__.py +0 -0
  11. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/aggregate_cycles.py +0 -0
  12. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/config/Cycle/crop.json +0 -0
  13. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/config/Cycle/processedFood.json +0 -0
  14. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/log.py +0 -0
  15. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/recalculate_cycles.py +0 -0
  16. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/__init__.py +0 -0
  17. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/aggregate_country_nodes.py +0 -0
  18. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/aggregate_weighted.py +0 -0
  19. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/blank_node.py +0 -0
  20. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/combine.py +0 -0
  21. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/completeness.py +0 -0
  22. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/covariance.py +0 -0
  23. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/cycle.py +0 -0
  24. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/distribution.py +0 -0
  25. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/emission.py +0 -0
  26. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/group.py +0 -0
  27. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/input.py +0 -0
  28. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/lookup.py +0 -0
  29. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/measurement.py +0 -0
  30. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/practice.py +0 -0
  31. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/product.py +0 -0
  32. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/property.py +0 -0
  33. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/quality_score.py +0 -0
  34. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/site.py +0 -0
  35. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/source.py +0 -0
  36. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/term.py +0 -0
  37. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth/aggregation/utils/weights.py +0 -0
  38. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth_aggregation.egg-info/SOURCES.txt +0 -0
  39. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth_aggregation.egg-info/dependency_links.txt +0 -0
  40. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth_aggregation.egg-info/requires.txt +0 -0
  41. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/hestia_earth_aggregation.egg-info/top_level.txt +0 -0
  42. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/setup.cfg +0 -0
  43. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/setup.py +0 -0
  44. {hestia_earth_aggregation-0.21.17 → hestia_earth_aggregation-0.21.18}/tests/test_aggregation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hestia_earth_aggregation
3
- Version: 0.21.17
3
+ Version: 0.21.18
4
4
  Summary: HESTIA's aggregation engine.
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-aggregation-engine
6
6
  Author: HESTIA Team
@@ -1,6 +1,7 @@
1
1
  from hestia_earth.schema import ManagementJSONLD
2
2
  from hestia_earth.utils.model import linked_node
3
- from hestia_earth.utils.tools import safe_parse_date
3
+ from hestia_earth.utils.tools import safe_parse_date, flatten
4
+ from hestia_earth.utils.date import gapfill_datestr
4
5
 
5
6
  from . import match_dates, _set_dict_single
6
7
  from .queries import TIME_PERIOD, _get_time_ranges, _current_date
@@ -45,6 +46,34 @@ def aggregated_dates(blank_node: dict):
45
46
  )
46
47
 
47
48
 
49
+ def split_by_dates(blank_nodes: list, start_year: int):
50
+ # if the blank_node overlaps with the start period of the aggregation, we need to split it in 2 parts
51
+ def split_data(blank_node: dict):
52
+ start_date = safe_parse_date(blank_node.get("startDate"), default=None)
53
+ end_date = safe_parse_date(blank_node.get("endDate"), default=None)
54
+ is_overlapping = all([start_date is not None, end_date is not None]) and all(
55
+ [start_date.year < start_year, start_year < end_date.year]
56
+ )
57
+ return (
58
+ [
59
+ blank_node
60
+ | {
61
+ "startDate": blank_node.get("startDate"),
62
+ "endDate": gapfill_datestr(start_year - 1, "end"),
63
+ },
64
+ blank_node
65
+ | {
66
+ "startDate": gapfill_datestr(start_year, "start"),
67
+ "endDate": blank_node.get("endDate"),
68
+ },
69
+ ]
70
+ if is_overlapping
71
+ else blank_node
72
+ )
73
+
74
+ return flatten(map(split_data, blank_nodes))
75
+
76
+
48
77
  def filter_management(blank_nodes: list, start_year: int = None, end_year: int = None):
49
78
  def update_dates(blank_node: dict):
50
79
  start_date = safe_parse_date(blank_node.get("startDate"), default=None)
@@ -72,7 +101,9 @@ def filter_management(blank_nodes: list, start_year: int = None, end_year: int =
72
101
  """
73
102
  return [
74
103
  update_dates(v)
75
- for v in blank_nodes
104
+ for v in (
105
+ split_by_dates(blank_nodes, start_year) if start_year else blank_nodes
106
+ )
76
107
  if not start_year
77
108
  or not end_year
78
109
  or match_dates(v, start_year - TIME_PERIOD, end_year)
@@ -15,7 +15,7 @@ from hestia_earth.aggregation.log import logger
15
15
  from . import HestiaError, _save_json, pick
16
16
  from .term import DEFAULT_COUNTRY_NAME, _fetch_countries, is_global as is_global_country
17
17
 
18
- SEARCH_LIMIT = 10000
18
+ SEARCH_LIMIT = int(os.getenv("SEARCH_LIMIT", "10000"))
19
19
  _MATCH_AGGREGATED_QUERY = {"match": {"aggregated": "true"}}
20
20
  _MATCH_AGGREGATED_VALIDATED_QUERY = {"match": {"aggregatedDataValidated": "true"}}
21
21
  # enable matching any product
@@ -0,0 +1 @@
1
+ VERSION = "0.21.18"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hestia_earth_aggregation
3
- Version: 0.21.17
3
+ Version: 0.21.18
4
4
  Summary: HESTIA's aggregation engine.
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-aggregation-engine
6
6
  Author: HESTIA Team
@@ -1 +0,0 @@
1
- VERSION = "0.21.17"