Commit 9a120e3
feat: Timeseries Loader (#137)
# New Sub Command for Time Series
Takes in a ts group or tsid(s) and copies the data from one CDA instance
to another
`cwms-cli timeseries data -h`
gives
```bash
Usage: cwms-cli load timeseries data [OPTIONS]
Copy timeseries data for a single location in a target CDA from a source CDA.
Options:
-v, --verbose Increase verbosity (repeat for more detail).
--dry-run / --no-dry-run Show what would be written without storing to target. [default: no-dry-run]
--target-api-key TEXT Target API key (if required by the target CDA).
--target-cda TEXT Target CWMS Data API root. Default: http://localhost:8081/cwms-data/ [required]
--source-office TEXT Source office ID (e.g. SWT, SWL). [required]
--source-cda TEXT Source CWMS Data API root. Default: https://cwms-data.usace.army.mil/cwms-data/ [required]
--ts-id TEXT ID of the timeseries to copy (e.g. 'LocID.*').
--ts-group TEXT ID of the timeseries group to copy (e.g. 'GroupID.*').
--ts-group-category-id TEXT ID of the timeseries group category to copy.
--ts-group-category-office-id TEXT
ID of the timeseries group category office to copy.
--begin [%Y-%m-%dT%H:%M:%S%z|%Y-%m-%dT%H:%M:%S %Z]
Start date for timeseries data (e.g. '2022-01-01T00:00:00-06:00').
--end [%Y-%m-%dT%H:%M:%S%z|%Y-%m-%dT%H:%M:%S %Z]
End date for timeseries data (e.g. '2022-01-31T00:00:00-0600').
-h, --help Show this message and exit.
```
This pull request introduces a new CLI command for copying timeseries
data between CWMS Data Access (CDA) instances, along with several
supporting improvements and fixes. The main focus is on enabling users
to copy timeseries data for a single location or a group of timeseries,
with robust input validation and dry-run support. Additional changes
include dependency updates and minor bug fixes.
**New timeseries data copy functionality:**
* Added a new `data` subcommand to the `timeseries` CLI group, allowing
users to copy timeseries data for a specific timeseries ID or a
timeseries group from a source CDA to a target CDA, with options for
specifying time range and group/category details. Input validation
ensures correct option usage. (`cwmscli/load/timeseries/timeseries.py`,
`cwmscli/load/timeseries/timeseries_data.py`)
[[1]](diffhunk://#diff-bd8fc5ed7f637c754f4f37d0841bdeb960ca74246d2889fdb801df2b29a8b66bR57-R147)
[[2]](diffhunk://#diff-dbec006c6c9b478f5e30303a51327ea335a1bbf4d46355384afdc4b4f1b2c903R1-R109)
**Supporting improvements and fixes:**
* Updated the required `cwms-python` client library version from `0.8.0`
to `1.0.1` to ensure compatibility with new features.
(`cwmscli/utils/deps.py`)
* Fixed the order of `cwms.init_session` calls in `load_timeseries_ids`
to ensure the session is initialized for the target CDA before storing
timeseries data. (`cwmscli/load/timeseries/timeseries_ids.py`)
[[1]](diffhunk://#diff-34fd913442e086124d05e5474a9842b5aecc6bcdfb014a2c89bdf19a6eccd0b1L30-L31)
[[2]](diffhunk://#diff-34fd913442e086124d05e5474a9842b5aecc6bcdfb014a2c89bdf19a6eccd0b1R40)
* Removed an unnecessary import of `pd` from the `turtle` module in
`timeseries_ids.py`. (`cwmscli/load/timeseries/timeseries_ids.py`)
**Minor CLI output adjustment:**
* Changed the `verbose` check for printing "Done." in the
`load_locations` command to always print the message, regardless of
verbosity. (`cwmscli/load/location/location_ids.py`)
---------
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: krowvin <23619282+krowvin@users.noreply.github.com>1 parent 29f43dc commit 9a120e3
File tree
6 files changed
+439
-7
lines changed- cwmscli
- load
- location
- timeseries
- utils
- tests/load
6 files changed
+439
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
| 103 | + | |
| 104 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | 2 | | |
5 | 3 | | |
6 | 4 | | |
| |||
30 | 28 | | |
31 | 29 | | |
32 | 30 | | |
33 | | - | |
34 | | - | |
35 | 31 | | |
36 | 32 | | |
37 | 33 | | |
| |||
43 | 39 | | |
44 | 40 | | |
45 | 41 | | |
| 42 | + | |
46 | 43 | | |
47 | 44 | | |
48 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
0 commit comments