Skip to content

Commit 4fb960f

Browse files
Copilotkrowvin
andauthored
Fix review feedback on timeseries data loader (#139)
- [x] Fix help text in `timeseries.py` to accurately describe command behavior - [x] Update `cwms-python` minimum version to 1.0.1 in `requirements.py` and `pyproject.toml` - [x] Fix module header comment in `timeseries_data.py` - [x] Remove unused `json` import in `timeseries_data.py` - [x] Remove unused `from cwms import JSON` import in `timeseries_data.py` - [x] Fix `ts_data` being wrapped in a list (now stores result directly from `cwms.get_timeseries()`) - [x] Fix incorrect comment in the `ts_id` branch - [x] Fix type hints for `ts_id`, `ts_group`, etc. to `Optional[str] = None` - [x] Fix completion message to "Timeseries data copy operation completed." - [x] Update `poetry.lock` to fix CI failure (pyproject.toml changed significantly since lock file was last generated) <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: krowvin <23619282+krowvin@users.noreply.github.com>
1 parent cd2efc1 commit 4fb960f

5 files changed

Lines changed: 22 additions & 23 deletions

File tree

cwmscli/load/timeseries/timeseries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def load_timeseries_ids_all(
5858

5959
@timeseries.command(
6060
"data",
61-
help="Copy timeseries data for a single location in a target CDA from a source CDA.",
61+
help="Copy timeseries data (by timeseries ID or timeseries group) into a target CDA from a source CDA.",
6262
)
6363
@shared_source_target_options
6464
@click.option(

cwmscli/load/timeseries/timeseries_data.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# cwmscli/load/timeseries_ids.py
2-
import json
1+
# cwmscli/load/timeseries/timeseries_data.py
32
import logging
43
from datetime import datetime
54
from typing import Optional
65

76
import click
87
import pandas as pd
9-
from cwms import JSON
108

119

1210
def _load_timeseries_data(
@@ -16,10 +14,10 @@ def _load_timeseries_data(
1614
target_api_key: Optional[str],
1715
verbose: int,
1816
dry_run: bool,
19-
ts_id: str,
20-
ts_group: str,
21-
ts_group_category_id: str,
22-
ts_group_category_office_id: str,
17+
ts_id: Optional[str] = None,
18+
ts_group: Optional[str] = None,
19+
ts_group_category_id: Optional[str] = None,
20+
ts_group_category_office_id: Optional[str] = None,
2321
begin: Optional[datetime] = None,
2422
end: Optional[datetime] = None,
2523
):
@@ -33,12 +31,13 @@ def _load_timeseries_data(
3331
cwms.init_session(api_root=source_cda, api_key=None)
3432
# User has a ts_id
3533
if ts_id and not ts_group:
36-
ts_data = [
37-
cwms.get_timeseries(
38-
ts_id=ts_id, office_id=source_office, begin=begin, end=end
39-
)
40-
]
41-
# only grab time_ids for locations that are in the target database
34+
ts_data = cwms.get_timeseries(
35+
ts_id=ts_id,
36+
office_id=source_office,
37+
begin=begin,
38+
end=end,
39+
)
40+
# store the retrieved timeseries data into the target database
4241
try:
4342
if dry_run:
4443
click.echo("Dry run enabled. No changes will be made.")
@@ -106,4 +105,4 @@ def _load_timeseries_data(
106105
)
107106

108107
if verbose:
109-
click.echo("Timeseries ID copy operation completed.")
108+
click.echo("Timeseries data copy operation completed.")

cwmscli/requirements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
cwms = {
66
"module": "cwms",
77
"package": "cwms-python",
8-
"version": "0.8.0",
8+
"version": "1.0.1",
99
"desc": "CWMS REST API Python client",
1010
"link": "https://github.com/HydrologicEngineeringCenter/cwms-python",
1111
}

poetry.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ authors = ["Eric Novotny <eric.v.novotny@usace.army.mil>", "Charles Graham <char
1818
python = "^3.9"
1919
click = "^8.1.8"
2020
hecdss = { version = ">=0.1.24", optional = true } # Via https://github.com/HydrologicEngineeringCenter/hec-python-library/blob/main/hec/shared.py#L9-10
21-
cwms-python = { version = ">=0.8.0", optional = true}
21+
cwms-python = { version = ">=1.0.1", optional = true}
2222

2323
[tool.poetry.group.dev.dependencies]
2424
black = "^24.2.0"

0 commit comments

Comments
 (0)