hestia-earth-models 0.68.0__py3-none-any.whl → 0.68.1__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.
- hestia_earth/models/cache_sites.py +18 -9
- hestia_earth/models/mocking/search-results.json +575 -575
- hestia_earth/models/site/soilMeasurement.py +2 -0
- hestia_earth/models/utils/measurement.py +1 -1
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.68.0.dist-info → hestia_earth_models-0.68.1.dist-info}/METADATA +1 -1
- {hestia_earth_models-0.68.0.dist-info → hestia_earth_models-0.68.1.dist-info}/RECORD +10 -10
- {hestia_earth_models-0.68.0.dist-info → hestia_earth_models-0.68.1.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.68.0.dist-info → hestia_earth_models-0.68.1.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.68.0.dist-info → hestia_earth_models-0.68.1.dist-info}/top_level.txt +0 -0
@@ -80,7 +80,7 @@ def _run_values(
|
|
80
80
|
site_cache = merge(
|
81
81
|
site.get(CACHE_KEY, {}),
|
82
82
|
{CACHE_GEOSPATIAL_KEY: cached_data},
|
83
|
-
({CACHE_YEARS_KEY: cached_value(site, CACHE_YEARS_KEY, []) + years} if years else {})
|
83
|
+
({CACHE_YEARS_KEY: list(set(cached_value(site, CACHE_YEARS_KEY, []) + years))} if years else {})
|
84
84
|
)
|
85
85
|
return merge(site, {CACHE_KEY: site_cache})
|
86
86
|
|
@@ -137,6 +137,17 @@ def _run(sites: list, years: list = [], years_only: bool = False):
|
|
137
137
|
] + _run_values(sites_no_run, years=years))
|
138
138
|
|
139
139
|
|
140
|
+
def _run_by_years(sites: list, years: list, batch_size: int):
|
141
|
+
batches = range(0, len(years), batch_size)
|
142
|
+
|
143
|
+
for batch_index in batches:
|
144
|
+
logger.info(f"Processing sites in batch {batch_index + 1} of {len(batches)}...")
|
145
|
+
sub_years = years[batch_index:batch_index + batch_size]
|
146
|
+
sites = _run(sites, sub_years, years_only=True)
|
147
|
+
|
148
|
+
return sites
|
149
|
+
|
150
|
+
|
140
151
|
def run(sites: list, years: list = None):
|
141
152
|
"""
|
142
153
|
Run all queries at once for the list of provided Sites.
|
@@ -153,12 +164,10 @@ def run(sites: list, years: list = None):
|
|
153
164
|
|
154
165
|
# avoid memory limit errors by running only a few years at a time
|
155
166
|
unique_years = sorted(list(set(years)))
|
156
|
-
batch_size = 5
|
157
|
-
batches = range(0, len(unique_years), batch_size)
|
158
|
-
|
159
|
-
for batch_index in batches:
|
160
|
-
logger.info(f"Processing sites in batch {batch_index + 1} of {len(batches)}...")
|
161
|
-
sub_years = unique_years[batch_index:batch_index + batch_size]
|
162
|
-
sites = _run(sites, sub_years, years_only=True)
|
163
167
|
|
164
|
-
|
168
|
+
try:
|
169
|
+
return _run_by_years(sites, unique_years, batch_size=5)
|
170
|
+
except Exception as e:
|
171
|
+
if 'exceeded' in str(e):
|
172
|
+
return _run_by_years(sites, unique_years, batch_size=1)
|
173
|
+
raise e
|