The core BASIN-3D application that uses a generalized data synthesis model that applies across a variety of earth science observation types (hydrology, geochemistry, climate etc.). https://basin3d.readthedocs.io/
Other
13
stars
4
forks
source link
Unmapped parameter in a plugin should raise an error #89
Describe the bug
When searching for data of an unmapped parameter, basin3d does creates a syntactically incorrect query to the data source. This raising a datasource error. This is confusing to the user as the issue is that the variable is not mapped in the plugin.
To Reproduce
Here is the code to reproduce this error
# All the imports
import datetime
import os
import sys
import h5py
import pandas
from basin3d import synthesis
from basin3d.plugins import usgs
import logging
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
# Register the USGS Plugin
synthesizer = synthesis.register()
# Create a query dictionary
query_info = {}
query_info['observed_property_variables'] = ['SAL']
query_info['start_date'] = '2020-01-01'
query_info['end_date'] = '2020-01-05'
query_info['monitoring_features'] = 'USGS-02'
# NOTE: this will not work for the current version of basin3d because
# the return for get_timeseries_data() was changed to a SynthesizedTimeseriesData
# object. This is coming from iNAIADS/basin3d -> branch devlop
output = synthesis.get_timeseries_data(synthesizer, **query_info)
Output from the above code
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): waterservices.usgs.gov:443
DEBUG:urllib3.connectionpool:https://waterservices.usgs.gov:443 "GET /nwis/site/?huc=02 HTTP/1.1" 200 None
DEBUG:basin3d.core.access:url:https://waterservices.usgs.gov/nwis/site/?huc=02
WARNING:root:Could not connect to USGS site info: _log() got an unexpected keyword argument 'url'
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): waterservices.usgs.gov:443
DEBUG:urllib3.connectionpool:https://waterservices.usgs.gov:443 "GET /nwis/dv?startDT=2020-01-01&endDT=2020-01-05¶meterCd=&huc=02&siteStatus=all&siteType=ST&format=json HTTP/1.1" 400 509
DEBUG:basin3d.core.access:url:https://waterservices.usgs.gov/nwis/dv?startDT=2020-01-01&endDT=2020-01-05¶meterCd=&huc=02&siteStatus=all&siteType=ST&format=json
ERROR:basin3d.plugins.usgs:HTTP 400: Error report HTTP Status 400 - input error: value string length is zero [token=parameterCd], server=[caas01] type Status report message input error: value string length is zero [token=parameterCd], server=[caas01] description The request sent by the client was syntactically incorrect. Error Report
Expected behavior
The unmapped parameter should not be queried from the data source. This should show us as either a warning or as an error.
Describe the bug When searching for data of an unmapped parameter, basin3d does creates a syntactically incorrect query to the data source. This raising a datasource error. This is confusing to the user as the issue is that the variable is not mapped in the plugin.
To Reproduce Here is the code to reproduce this error
Output from the above code
Expected behavior The unmapped parameter should not be queried from the data source. This should show us as either a warning or as an error.