Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cwmscli/load/timeseries/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def load_timeseries_ids_all(

@timeseries.command(
"data",
help="Copy timeseries data for a single location in a target CDA from a source CDA.",
help="Copy timeseries data (by timeseries ID or timeseries group) into a target CDA from a source CDA.",
)
@shared_source_target_options
@click.option(
Expand Down
27 changes: 13 additions & 14 deletions cwmscli/load/timeseries/timeseries_data.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# cwmscli/load/timeseries_ids.py
import json
# cwmscli/load/timeseries/timeseries_data.py
import logging
from datetime import datetime
from typing import Optional

import click
import pandas as pd
from cwms import JSON


def _load_timeseries_data(
Expand All @@ -16,10 +14,10 @@ def _load_timeseries_data(
target_api_key: Optional[str],
verbose: int,
dry_run: bool,
ts_id: str,
ts_group: str,
ts_group_category_id: str,
ts_group_category_office_id: str,
ts_id: Optional[str] = None,
ts_group: Optional[str] = None,
ts_group_category_id: Optional[str] = None,
ts_group_category_office_id: Optional[str] = None,
begin: Optional[datetime] = None,
end: Optional[datetime] = None,
):
Expand All @@ -33,12 +31,13 @@ def _load_timeseries_data(
cwms.init_session(api_root=source_cda, api_key=None)
# User has a ts_id
if ts_id and not ts_group:
ts_data = [
cwms.get_timeseries(
ts_id=ts_id, office_id=source_office, begin=begin, end=end
)
]
# only grab time_ids for locations that are in the target database
ts_data = cwms.get_timeseries(
ts_id=ts_id,
office_id=source_office,
begin=begin,
end=end,
)
# store the retrieved timeseries data into the target database
try:
if dry_run:
click.echo("Dry run enabled. No changes will be made.")
Expand Down Expand Up @@ -106,4 +105,4 @@ def _load_timeseries_data(
)

if verbose:
click.echo("Timeseries ID copy operation completed.")
click.echo("Timeseries data copy operation completed.")
2 changes: 1 addition & 1 deletion cwmscli/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
cwms = {
"module": "cwms",
"package": "cwms-python",
"version": "0.8.0",
"version": "1.0.1",
"desc": "CWMS REST API Python client",
"link": "https://github.com/HydrologicEngineeringCenter/cwms-python",
}
Expand Down
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ authors = ["Eric Novotny <eric.v.novotny@usace.army.mil>", "Charles Graham <char
python = "^3.9"
click = "^8.1.8"
hecdss = { version = ">=0.1.24", optional = true } # Via https://github.com/HydrologicEngineeringCenter/hec-python-library/blob/main/hec/shared.py#L9-10
cwms-python = { version = ">=0.8.0", optional = true}
cwms-python = { version = ">=1.0.1", optional = true}

[tool.poetry.group.dev.dependencies]
black = "^24.2.0"
Expand Down