Skip to content

Commit aa98d23

Browse files
committed
Close Copilot review gaps: extend AGENCY-ID check + iterable normalization to all OGC functions
Four issues from Copilot's latest review: 1. `_check_monitoring_location_id` was missing from `get_combined_metadata`, `get_field_measurements_metadata`, and `get_peaks`. Bad mloc inputs to those callers reached the API. 2. `get_channel` built its `args` dict from a raw `locals()` comprehension instead of `_get_args`, so non-string iterables (`pd.Series`, `np.ndarray`, generators) were never materialized before request construction. 3. `get_combined_metadata`'s `thresholds: float | list[float]` filter was being routed through `_normalize_str_iterable`, which would reject `[1.0, 2.0]` as non-string. Added to `_NO_NORMALIZE_PARAMS`. 4. The `properties` annotation was `list[str] | None` in 8 functions, but `_get_args` wraps a single-string input into a list at runtime (via `_LIST_ONLY_STR_PARAMS`). Widened to `str | list[str] | None` so type checkers don't reject the supported `properties="time_series_id"` call shape.
1 parent 1d7a6e7 commit aa98d23

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

dataretrieval/waterdata/api.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def get_daily(
4343
monitoring_location_id: str | Iterable[str] | None = None,
4444
parameter_code: str | Iterable[str] | None = None,
4545
statistic_id: str | Iterable[str] | None = None,
46-
properties: list[str] | None = None,
46+
properties: str | list[str] | None = None,
4747
time_series_id: str | Iterable[str] | None = None,
4848
daily_id: str | Iterable[str] | None = None,
4949
approval_status: str | Iterable[str] | None = None,
@@ -246,7 +246,7 @@ def get_continuous(
246246
monitoring_location_id: str | Iterable[str] | None = None,
247247
parameter_code: str | Iterable[str] | None = None,
248248
statistic_id: str | Iterable[str] | None = None,
249-
properties: list[str] | None = None,
249+
properties: str | list[str] | None = None,
250250
time_series_id: str | Iterable[str] | None = None,
251251
continuous_id: str | Iterable[str] | None = None,
252252
approval_status: str | Iterable[str] | None = None,
@@ -472,7 +472,7 @@ def get_monitoring_locations(
472472
well_constructed_depth: str | Iterable[str] | None = None,
473473
hole_constructed_depth: str | Iterable[str] | None = None,
474474
depth_source_code: str | Iterable[str] | None = None,
475-
properties: list[str] | None = None,
475+
properties: str | list[str] | None = None,
476476
skip_geometry: bool | None = None,
477477
time: str | Iterable[str] | None = None,
478478
bbox: list[float] | None = None,
@@ -734,7 +734,7 @@ def get_time_series_metadata(
734734
monitoring_location_id: str | Iterable[str] | None = None,
735735
parameter_code: str | Iterable[str] | None = None,
736736
parameter_name: str | Iterable[str] | None = None,
737-
properties: list[str] | None = None,
737+
properties: str | list[str] | None = None,
738738
statistic_id: str | Iterable[str] | None = None,
739739
hydrologic_unit_code: str | Iterable[str] | None = None,
740740
state_name: str | Iterable[str] | None = None,
@@ -1181,6 +1181,7 @@ def get_combined_metadata(
11811181
service = "combined-metadata"
11821182
output_id = "combined_meta_id"
11831183

1184+
monitoring_location_id = _check_monitoring_location_id(monitoring_location_id)
11841185
args = _get_args(locals())
11851186

11861187
return get_ogc_data(args, output_id, service)
@@ -1190,7 +1191,7 @@ def get_latest_continuous(
11901191
monitoring_location_id: str | Iterable[str] | None = None,
11911192
parameter_code: str | Iterable[str] | None = None,
11921193
statistic_id: str | Iterable[str] | None = None,
1193-
properties: list[str] | None = None,
1194+
properties: str | list[str] | None = None,
11941195
time_series_id: str | Iterable[str] | None = None,
11951196
latest_continuous_id: str | Iterable[str] | None = None,
11961197
approval_status: str | Iterable[str] | None = None,
@@ -1386,7 +1387,7 @@ def get_latest_daily(
13861387
monitoring_location_id: str | Iterable[str] | None = None,
13871388
parameter_code: str | Iterable[str] | None = None,
13881389
statistic_id: str | Iterable[str] | None = None,
1389-
properties: list[str] | None = None,
1390+
properties: str | list[str] | None = None,
13901391
time_series_id: str | Iterable[str] | None = None,
13911392
latest_daily_id: str | Iterable[str] | None = None,
13921393
approval_status: str | Iterable[str] | None = None,
@@ -1583,7 +1584,7 @@ def get_field_measurements(
15831584
monitoring_location_id: str | Iterable[str] | None = None,
15841585
parameter_code: str | Iterable[str] | None = None,
15851586
observing_procedure_code: str | Iterable[str] | None = None,
1586-
properties: list[str] | None = None,
1587+
properties: str | list[str] | None = None,
15871588
field_visit_id: str | Iterable[str] | None = None,
15881589
approval_status: str | Iterable[str] | None = None,
15891590
unit_of_measure: str | Iterable[str] | None = None,
@@ -1882,6 +1883,7 @@ def get_field_measurements_metadata(
18821883
service = "field-measurements-metadata"
18831884
output_id = "field_series_id"
18841885

1886+
monitoring_location_id = _check_monitoring_location_id(monitoring_location_id)
18851887
args = _get_args(locals())
18861888

18871889
return get_ogc_data(args, output_id, service)
@@ -2002,6 +2004,7 @@ def get_peaks(
20022004
service = "peaks"
20032005
output_id = "peak_id"
20042006

2007+
monitoring_location_id = _check_monitoring_location_id(monitoring_location_id)
20052008
args = _get_args(locals())
20062009

20072010
return get_ogc_data(args, output_id, service)
@@ -2698,7 +2701,7 @@ def get_channel(
26982701
measurement_type: str | Iterable[str] | None = None,
26992702
last_modified: str | Iterable[str] | None = None,
27002703
channel_measurement_type: str | Iterable[str] | None = None,
2701-
properties: list[str] | None = None,
2704+
properties: str | list[str] | None = None,
27022705
skip_geometry: bool | None = None,
27032706
bbox: list[float] | None = None,
27042707
limit: int | None = None,
@@ -2840,11 +2843,6 @@ def get_channel(
28402843
service = "channel-measurements"
28412844
output_id = "channel_measurements_id"
28422845

2843-
# Build argument dictionary, omitting None values
2844-
args = {
2845-
k: v
2846-
for k, v in locals().items()
2847-
if k not in {"service", "output_id"} and v is not None
2848-
}
2846+
args = _get_args(locals())
28492847

28502848
return get_ogc_data(args, output_id, service)

dataretrieval/waterdata/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,7 @@ def _check_profiles(
12001200
"month",
12011201
"day",
12021202
"peak_since",
1203+
"thresholds",
12031204
}
12041205

12051206
# Param names that must be a list of strings (never a single string).

0 commit comments

Comments
 (0)