Commit 47a44e94 authored by lukas leufen's avatar lukas leufen 👻
Browse files

try to prevent break down on download toar

parent 70ed13c6
Pipeline #105017 passed with stages
in 17 minutes and 29 seconds
......@@ -78,16 +78,27 @@ def retries_session(max_retries=3):
def download_toar(station, toar_stats, sampling, data_origin, station_type=None):
# load data from toar-data (v2)
df_toar, meta_toar = toar_data_v2.download_toar(station, toar_stats, sampling=sampling, data_origin=data_origin)
# load join data (toar-data v1)
df_join, _ = join.download_join(station_name=station, stat_var=toar_stats, sampling=sampling,
station_type=station_type, data_origin=data_origin)
try:
# load data from toar-data (v2)
df_toar, meta_toar = toar_data_v2.download_toar(station, toar_stats, sampling=sampling, data_origin=data_origin)
except (AttributeError, EmptyQueryResult, KeyError, requests.ConnectionError, ValueError, IndexError):
df_toar, meta_toar = None, None
try:
# load join data (toar-data v1)
df_join, meta_join = join.download_join(station_name=station, stat_var=toar_stats, sampling=sampling,
station_type=station_type, data_origin=data_origin)
except (AttributeError, EmptyQueryResult, KeyError, requests.ConnectionError, ValueError, IndexError):
df_join, meta_join = None, None
# merge both data sources with priority on toar-data v2
df_merged = merge_toar_join(df_toar, df_join, sampling)
return df_merged, meta_toar
if df_toar is not None and df_join is not None:
df_merged = merge_toar_join(df_toar, df_join, sampling)
meta_merged = meta_toar
else:
df_merged = df_toar if df_toar is not None else df_join
meta_merged = meta_toar if df_toar is not None else meta_join
return df_merged, meta_merged
def merge_toar_join(df_toar, df_join, sampling):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment