Skip to content
Snippets Groups Projects
Commit b4e45333 authored by leufen1's avatar leufen1
Browse files

introduced test if all requested variables are available, the join module will...

introduced test if all requested variables are available, the join module will raise an EmptyQueryResult with detailed information which variables could not be loaded
parent 982fc6f6
Branches
Tags
3 merge requests!226Develop,!225Resolve "release v1.2.0",!198Resolve "REFAC: "bad" stations do not report which variable is missing"
Pipeline #53948 failed
...@@ -47,6 +47,13 @@ def download_join(station_name: Union[str, List[str]], stat_var: dict, station_t ...@@ -47,6 +47,13 @@ def download_join(station_name: Union[str, List[str]], stat_var: dict, station_t
# load series information # load series information
vars_dict = load_series_information(station_name, station_type, network_name, join_url_base, headers, data_origin) vars_dict = load_series_information(station_name, station_type, network_name, join_url_base, headers, data_origin)
# check if all requested variables are available
if set(stat_var).issubset(vars_dict) is False:
missing_variables = set(stat_var).difference(vars_dict)
origin = helpers.select_from_dict(data_origin, missing_variables)
options = f"station={station_name}, type={station_type}, network={network_name}, origin={origin}"
raise EmptyQueryResult(f"No data found for variables {missing_variables} and options {options} in JOIN.")
# correct stat_var values if data is not aggregated (hourly) # correct stat_var values if data is not aggregated (hourly)
if sampling == "hourly": if sampling == "hourly":
stat_var = {key: "values" for key in stat_var.keys()} stat_var = {key: "values" for key in stat_var.keys()}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment