torchriver 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TorchRiver Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,281 @@
1
+ Metadata-Version: 2.4
2
+ Name: torchriver
3
+ Version: 2.0.0
4
+ Summary: River low-flow and drought forecasting with PyTorch
5
+ Author: TorchRiver Contributors
6
+ License: MIT
7
+ Project-URL: Repository, https://github.com/torchriver/torchriver
8
+ Project-URL: Notebooks, https://github.com/torchriver/torchriver/blob/main/notebooks/
9
+ Project-URL: Quick Start Notebook, https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb
10
+ Project-URL: Small Quick Start Notebook, https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb
11
+ Project-URL: Examples, https://github.com/torchriver/torchriver/tree/main/examples
12
+ Project-URL: Documentation, https://github.com/torchriver/torchriver/tree/main/docs
13
+ Project-URL: Tests, https://github.com/torchriver/torchriver/tree/main/tests
14
+ Keywords: rivers,drought,low-flow,pytorch,gradio,time-series,hydrology
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
24
+ Classifier: Topic :: Scientific/Engineering :: Hydrology
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: numpy>=1.23
29
+ Requires-Dist: pandas>=1.5
30
+ Requires-Dist: torch>=2.0
31
+ Requires-Dist: scikit-learn>=1.2
32
+ Requires-Dist: joblib>=1.2
33
+ Requires-Dist: matplotlib>=3.7
34
+ Requires-Dist: gradio>=4.0
35
+ Requires-Dist: opendatasets>=0.1.22
36
+ Requires-Dist: kaggle>=1.6
37
+ Requires-Dist: openpyxl>=3.1
38
+ Requires-Dist: pyarrow>=12
39
+ Provides-Extra: dev
40
+ Requires-Dist: pytest>=7; extra == "dev"
41
+ Requires-Dist: nbformat>=5; extra == "dev"
42
+ Requires-Dist: build>=1; extra == "dev"
43
+ Requires-Dist: twine>=5; extra == "dev"
44
+ Provides-Extra: ui
45
+ Requires-Dist: gradio>=4.0; extra == "ui"
46
+ Requires-Dist: gradio_client>=1.0; extra == "ui"
47
+ Provides-Extra: kaggle
48
+ Requires-Dist: opendatasets>=0.1.22; extra == "kaggle"
49
+ Requires-Dist: kaggle>=1.6; extra == "kaggle"
50
+ Provides-Extra: all
51
+ Requires-Dist: torchriver[dev,kaggle,ui]; extra == "all"
52
+ Dynamic: license-file
53
+
54
+ # TorchRiver
55
+
56
+ TorchRiver is a Python library for river low-flow and drought early warning. It provides a notebook-friendly workflow for loading river data, training forecasting models, predicting low-flow risk, saving `.triver` models, and launching an Arabic RTL Gradio interface.
57
+
58
+ The default architecture is `river_cnn_lstm`:
59
+
60
+ ```text
61
+ Conv1D -> ReLU -> MaxPool1D -> LSTM -> Dense -> probability/logit
62
+ ```
63
+
64
+ Available architectures:
65
+
66
+ | Name | Description |
67
+ | ---------------- | ------------------------------------------- |
68
+ | `river_cnn_lstm` | Conv1D + LSTM hybrid (default, recommended) |
69
+ | `cnn_lstm` | Alias for `river_cnn_lstm` |
70
+ | `lstm` | Pure LSTM recurrent model |
71
+ | `gru` | GRU recurrent model |
72
+ | `cnn` | Pure convolutional model |
73
+ | `mlp` | Multi-layer perceptron (fully connected) |
74
+ | `transformer` | Transformer encoder model |
75
+ | `custom` | Bring your own `nn.Module` |
76
+
77
+ Repository: https://github.com/torchriver/torchriver
78
+
79
+ ## Installation
80
+
81
+ ```bash
82
+ pip install torchriver
83
+ ```
84
+
85
+ In Google Colab:
86
+
87
+ ```python
88
+ %pip install -q torchriver
89
+ ```
90
+
91
+ ## TorchRiver Quick Start
92
+
93
+ Open the main full notebook:
94
+
95
+ * GitHub: https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb
96
+ * Colab: https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb
97
+
98
+ A smaller compact notebook is also included:
99
+
100
+ * GitHub: https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb
101
+ * Colab: https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb
102
+
103
+ ## Quick start in Python
104
+
105
+ ```python
106
+ from torchriver import RiverProject
107
+
108
+ project = RiverProject(title="TorchRiver", lang="ar", direction="rtl")
109
+
110
+ project.make_synthetic(
111
+ days=240,
112
+ station_codes=["R001", "R002", "R003"],
113
+ station_names={"R001": "River One", "R002": "River Two", "R003": "River Three"},
114
+ )
115
+
116
+ project.clean()
117
+ project.use_model(
118
+ "river_cnn_lstm",
119
+ horizons=[7, 14, 30],
120
+ lookback=30,
121
+ device="auto",
122
+ window_mode="per_station",
123
+ balance_classes=True,
124
+ )
125
+ project.train(epochs=2, batch_size=512, lr=0.001, seed=42)
126
+ print(project.predict_all(horizon=14))
127
+ project.save_model("river_warning_model.triver", include_recent_data=True)
128
+ ```
129
+
130
+ ## Kaggle example
131
+
132
+ ```python
133
+ import os, getpass
134
+ from torchriver import RiverProject
135
+
136
+ KAGGLE_URL = "https://www.kaggle.com/datasets/assemelqirsh/elbe-river-data-lake"
137
+ os.environ["KAGGLE_USERNAME"] = "YOUR_KAGGLE_USERNAME"
138
+ os.environ["KAGGLE_KEY"] = getpass.getpass("Paste Kaggle API key/token hidden: ")
139
+
140
+ project = RiverProject(title="TorchRiver", lang="ar", direction="rtl")
141
+ project.load_kaggle(KAGGLE_URL, nrows=200_000, fallback_synthetic=False)
142
+ project.clean()
143
+ project.use_model("river_cnn_lstm", horizons=[7, 14, 30], lookback=30, window_mode="per_station", balance_classes=True)
144
+ project.train(epochs=2, batch_size=512, lr=0.001)
145
+ print(project.predict_all(horizon=14))
146
+ ```
147
+
148
+ TorchRiver never stores Kaggle API keys. Use `KAGGLE_USERNAME` and `KAGGLE_KEY`, Kaggle's standard `~/.kaggle/kaggle.json`, or a hidden prompt.
149
+
150
+ ## Notebooks
151
+
152
+ All notebooks install TorchRiver from PyPI with `%pip install -q torchriver`.
153
+
154
+ | Notebook | Purpose | GitHub | Colab |
155
+ | -------------------------------------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
156
+ | `notebooks/TorchRiver_Quick_Start.ipynb` | Main full quick-start runner | https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb |
157
+ | `notebooks/TorchRiver_Quick_Start_small.ipynb` | Small compact quick start | https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb |
158
+ | `notebooks/02_quick_start_synthetic_train_predict.ipynb` | Synthetic training and prediction | https://github.com/torchriver/torchriver/blob/main/notebooks/02_quick_start_synthetic_train_predict.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/02_quick_start_synthetic_train_predict.ipynb |
159
+ | `notebooks/03_kaggle_url_train_river.ipynb` | Kaggle URL training | https://github.com/torchriver/torchriver/blob/main/notebooks/03_kaggle_url_train_river.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/03_kaggle_url_train_river.ipynb |
160
+ | `notebooks/08_save_load_triver.ipynb` | Save/load `.triver` models | https://github.com/torchriver/torchriver/blob/main/notebooks/08_save_load_triver.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/08_save_load_triver.ipynb |
161
+ | `notebooks/09_gradio_rtl_arabic.ipynb` | Arabic RTL Gradio UI | https://github.com/torchriver/torchriver/blob/main/notebooks/09_gradio_rtl_arabic.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/09_gradio_rtl_arabic.ipynb |
162
+
163
+ See `notebooks/00_INDEX.ipynb` for the full notebook list:
164
+
165
+ https://github.com/torchriver/torchriver/blob/main/notebooks/00_INDEX.ipynb
166
+
167
+ ## Examples
168
+
169
+ ```bash
170
+ pip install torchriver
171
+ python examples/01_train_synthetic.py
172
+ python examples/02_train_kaggle_url.py
173
+ ```
174
+
175
+ See `examples/README.md` for all script examples:
176
+
177
+ https://github.com/torchriver/torchriver/blob/main/examples/README.md
178
+
179
+ ## Compatible data format
180
+
181
+ Default columns:
182
+
183
+ ```text
184
+ date
185
+ station_code
186
+ station
187
+ discharge_m3s
188
+ low_flow_q10_threshold_m3s
189
+ sdi_30
190
+ precipitation_mm
191
+ temperature_c
192
+ ndwi
193
+ target_lowflow
194
+ ```
195
+
196
+ Custom schemas are supported through mapping:
197
+
198
+ ```python
199
+ project.load_file(
200
+ "my_river_data.csv",
201
+ mapping={
202
+ "date": "day",
203
+ "station": "gauge_id",
204
+ "station_name": "gauge_name",
205
+ "discharge": "Q_m3s",
206
+ "low_flow_threshold": "Q10",
207
+ "target": "low_flow_flag",
208
+ },
209
+ )
210
+ ```
211
+
212
+ If a threshold is missing, TorchRiver computes Q10 per station. If the target is missing, it creates:
213
+
214
+ ```python
215
+ target_lowflow = discharge_m3s < low_flow_q10_threshold_m3s
216
+ ```
217
+
218
+ ## Prediction
219
+
220
+ ```python
221
+ project.predict(station="501060", horizon=14)
222
+ project.predict_all(horizon=14)
223
+ project.diagnose_predictions(horizon=14)
224
+ ```
225
+
226
+ Prediction uses the last `lookback` days for the selected station. TorchRiver does not reuse the same last rows for every station.
227
+
228
+ ## Gradio API
229
+
230
+ ```python
231
+ project.launch_river_style(share=True, api=True, direction="rtl")
232
+ ```
233
+
234
+ Client usage:
235
+
236
+ ```python
237
+ from gradio_client import Client
238
+
239
+ client = Client("GRADIO_URL")
240
+ client.predict("501060 - DRESDEN", "+14 days", api_name="/predict")
241
+ ```
242
+
243
+ ## Save/load
244
+
245
+ ```python
246
+ project.save_model("river_warning_model.triver", include_recent_data=True)
247
+
248
+ from torchriver import load_river_model
249
+ loaded = load_river_model("river_warning_model.triver")
250
+ loaded.predict(station="501060", horizon=14)
251
+ ```
252
+
253
+ ## Tests
254
+
255
+ ```bash
256
+ pytest
257
+ ```
258
+
259
+ ## Repository folders
260
+
261
+ ```text
262
+ docs/ Documentation
263
+ examples/ Runnable Python examples
264
+ notebooks/ Colab and Jupyter notebooks
265
+ data/ Small sample datasets
266
+ tests/ Pytest tests
267
+ ```
268
+
269
+ ## Links
270
+
271
+ - Repository: <https://github.com/torchriver/torchriver>
272
+ - Notebooks: <https://github.com/torchriver/torchriver/blob/main/notebooks/>
273
+ - Quick Start Notebook: <https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb>
274
+ - Small Quick Start Notebook: <https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb>
275
+ - Examples: <https://github.com/torchriver/torchriver/tree/main/examples>
276
+ - Docs: <https://github.com/torchriver/torchriver/tree/main/docs>
277
+ - Tests: <https://github.com/torchriver/torchriver/tree/main/tests>
278
+
279
+ ## License
280
+
281
+ MIT
@@ -0,0 +1,228 @@
1
+ # TorchRiver
2
+
3
+ TorchRiver is a Python library for river low-flow and drought early warning. It provides a notebook-friendly workflow for loading river data, training forecasting models, predicting low-flow risk, saving `.triver` models, and launching an Arabic RTL Gradio interface.
4
+
5
+ The default architecture is `river_cnn_lstm`:
6
+
7
+ ```text
8
+ Conv1D -> ReLU -> MaxPool1D -> LSTM -> Dense -> probability/logit
9
+ ```
10
+
11
+ Available architectures:
12
+
13
+ | Name | Description |
14
+ | ---------------- | ------------------------------------------- |
15
+ | `river_cnn_lstm` | Conv1D + LSTM hybrid (default, recommended) |
16
+ | `cnn_lstm` | Alias for `river_cnn_lstm` |
17
+ | `lstm` | Pure LSTM recurrent model |
18
+ | `gru` | GRU recurrent model |
19
+ | `cnn` | Pure convolutional model |
20
+ | `mlp` | Multi-layer perceptron (fully connected) |
21
+ | `transformer` | Transformer encoder model |
22
+ | `custom` | Bring your own `nn.Module` |
23
+
24
+ Repository: https://github.com/torchriver/torchriver
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install torchriver
30
+ ```
31
+
32
+ In Google Colab:
33
+
34
+ ```python
35
+ %pip install -q torchriver
36
+ ```
37
+
38
+ ## TorchRiver Quick Start
39
+
40
+ Open the main full notebook:
41
+
42
+ * GitHub: https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb
43
+ * Colab: https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb
44
+
45
+ A smaller compact notebook is also included:
46
+
47
+ * GitHub: https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb
48
+ * Colab: https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb
49
+
50
+ ## Quick start in Python
51
+
52
+ ```python
53
+ from torchriver import RiverProject
54
+
55
+ project = RiverProject(title="TorchRiver", lang="ar", direction="rtl")
56
+
57
+ project.make_synthetic(
58
+ days=240,
59
+ station_codes=["R001", "R002", "R003"],
60
+ station_names={"R001": "River One", "R002": "River Two", "R003": "River Three"},
61
+ )
62
+
63
+ project.clean()
64
+ project.use_model(
65
+ "river_cnn_lstm",
66
+ horizons=[7, 14, 30],
67
+ lookback=30,
68
+ device="auto",
69
+ window_mode="per_station",
70
+ balance_classes=True,
71
+ )
72
+ project.train(epochs=2, batch_size=512, lr=0.001, seed=42)
73
+ print(project.predict_all(horizon=14))
74
+ project.save_model("river_warning_model.triver", include_recent_data=True)
75
+ ```
76
+
77
+ ## Kaggle example
78
+
79
+ ```python
80
+ import os, getpass
81
+ from torchriver import RiverProject
82
+
83
+ KAGGLE_URL = "https://www.kaggle.com/datasets/assemelqirsh/elbe-river-data-lake"
84
+ os.environ["KAGGLE_USERNAME"] = "YOUR_KAGGLE_USERNAME"
85
+ os.environ["KAGGLE_KEY"] = getpass.getpass("Paste Kaggle API key/token hidden: ")
86
+
87
+ project = RiverProject(title="TorchRiver", lang="ar", direction="rtl")
88
+ project.load_kaggle(KAGGLE_URL, nrows=200_000, fallback_synthetic=False)
89
+ project.clean()
90
+ project.use_model("river_cnn_lstm", horizons=[7, 14, 30], lookback=30, window_mode="per_station", balance_classes=True)
91
+ project.train(epochs=2, batch_size=512, lr=0.001)
92
+ print(project.predict_all(horizon=14))
93
+ ```
94
+
95
+ TorchRiver never stores Kaggle API keys. Use `KAGGLE_USERNAME` and `KAGGLE_KEY`, Kaggle's standard `~/.kaggle/kaggle.json`, or a hidden prompt.
96
+
97
+ ## Notebooks
98
+
99
+ All notebooks install TorchRiver from PyPI with `%pip install -q torchriver`.
100
+
101
+ | Notebook | Purpose | GitHub | Colab |
102
+ | -------------------------------------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
103
+ | `notebooks/TorchRiver_Quick_Start.ipynb` | Main full quick-start runner | https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb |
104
+ | `notebooks/TorchRiver_Quick_Start_small.ipynb` | Small compact quick start | https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb |
105
+ | `notebooks/02_quick_start_synthetic_train_predict.ipynb` | Synthetic training and prediction | https://github.com/torchriver/torchriver/blob/main/notebooks/02_quick_start_synthetic_train_predict.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/02_quick_start_synthetic_train_predict.ipynb |
106
+ | `notebooks/03_kaggle_url_train_river.ipynb` | Kaggle URL training | https://github.com/torchriver/torchriver/blob/main/notebooks/03_kaggle_url_train_river.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/03_kaggle_url_train_river.ipynb |
107
+ | `notebooks/08_save_load_triver.ipynb` | Save/load `.triver` models | https://github.com/torchriver/torchriver/blob/main/notebooks/08_save_load_triver.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/08_save_load_triver.ipynb |
108
+ | `notebooks/09_gradio_rtl_arabic.ipynb` | Arabic RTL Gradio UI | https://github.com/torchriver/torchriver/blob/main/notebooks/09_gradio_rtl_arabic.ipynb | https://colab.research.google.com/github/torchriver/torchriver/blob/main/notebooks/09_gradio_rtl_arabic.ipynb |
109
+
110
+ See `notebooks/00_INDEX.ipynb` for the full notebook list:
111
+
112
+ https://github.com/torchriver/torchriver/blob/main/notebooks/00_INDEX.ipynb
113
+
114
+ ## Examples
115
+
116
+ ```bash
117
+ pip install torchriver
118
+ python examples/01_train_synthetic.py
119
+ python examples/02_train_kaggle_url.py
120
+ ```
121
+
122
+ See `examples/README.md` for all script examples:
123
+
124
+ https://github.com/torchriver/torchriver/blob/main/examples/README.md
125
+
126
+ ## Compatible data format
127
+
128
+ Default columns:
129
+
130
+ ```text
131
+ date
132
+ station_code
133
+ station
134
+ discharge_m3s
135
+ low_flow_q10_threshold_m3s
136
+ sdi_30
137
+ precipitation_mm
138
+ temperature_c
139
+ ndwi
140
+ target_lowflow
141
+ ```
142
+
143
+ Custom schemas are supported through mapping:
144
+
145
+ ```python
146
+ project.load_file(
147
+ "my_river_data.csv",
148
+ mapping={
149
+ "date": "day",
150
+ "station": "gauge_id",
151
+ "station_name": "gauge_name",
152
+ "discharge": "Q_m3s",
153
+ "low_flow_threshold": "Q10",
154
+ "target": "low_flow_flag",
155
+ },
156
+ )
157
+ ```
158
+
159
+ If a threshold is missing, TorchRiver computes Q10 per station. If the target is missing, it creates:
160
+
161
+ ```python
162
+ target_lowflow = discharge_m3s < low_flow_q10_threshold_m3s
163
+ ```
164
+
165
+ ## Prediction
166
+
167
+ ```python
168
+ project.predict(station="501060", horizon=14)
169
+ project.predict_all(horizon=14)
170
+ project.diagnose_predictions(horizon=14)
171
+ ```
172
+
173
+ Prediction uses the last `lookback` days for the selected station. TorchRiver does not reuse the same last rows for every station.
174
+
175
+ ## Gradio API
176
+
177
+ ```python
178
+ project.launch_river_style(share=True, api=True, direction="rtl")
179
+ ```
180
+
181
+ Client usage:
182
+
183
+ ```python
184
+ from gradio_client import Client
185
+
186
+ client = Client("GRADIO_URL")
187
+ client.predict("501060 - DRESDEN", "+14 days", api_name="/predict")
188
+ ```
189
+
190
+ ## Save/load
191
+
192
+ ```python
193
+ project.save_model("river_warning_model.triver", include_recent_data=True)
194
+
195
+ from torchriver import load_river_model
196
+ loaded = load_river_model("river_warning_model.triver")
197
+ loaded.predict(station="501060", horizon=14)
198
+ ```
199
+
200
+ ## Tests
201
+
202
+ ```bash
203
+ pytest
204
+ ```
205
+
206
+ ## Repository folders
207
+
208
+ ```text
209
+ docs/ Documentation
210
+ examples/ Runnable Python examples
211
+ notebooks/ Colab and Jupyter notebooks
212
+ data/ Small sample datasets
213
+ tests/ Pytest tests
214
+ ```
215
+
216
+ ## Links
217
+
218
+ - Repository: <https://github.com/torchriver/torchriver>
219
+ - Notebooks: <https://github.com/torchriver/torchriver/blob/main/notebooks/>
220
+ - Quick Start Notebook: <https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb>
221
+ - Small Quick Start Notebook: <https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb>
222
+ - Examples: <https://github.com/torchriver/torchriver/tree/main/examples>
223
+ - Docs: <https://github.com/torchriver/torchriver/tree/main/docs>
224
+ - Tests: <https://github.com/torchriver/torchriver/tree/main/tests>
225
+
226
+ ## License
227
+
228
+ MIT
@@ -0,0 +1,80 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "torchriver"
7
+ version = "2.0.0"
8
+ description = "River low-flow and drought forecasting with PyTorch"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "TorchRiver Contributors" }
14
+ ]
15
+ keywords = [
16
+ "rivers",
17
+ "drought",
18
+ "low-flow",
19
+ "pytorch",
20
+ "gradio",
21
+ "time-series",
22
+ "hydrology"
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 3 - Alpha",
26
+ "Intended Audience :: Science/Research",
27
+ "Intended Audience :: Developers",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.9",
30
+ "Programming Language :: Python :: 3.10",
31
+ "Programming Language :: Python :: 3.11",
32
+ "Programming Language :: Python :: 3.12",
33
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
34
+ "Topic :: Scientific/Engineering :: Hydrology"
35
+ ]
36
+ dependencies = [
37
+ "numpy>=1.23",
38
+ "pandas>=1.5",
39
+ "torch>=2.0",
40
+ "scikit-learn>=1.2",
41
+ "joblib>=1.2",
42
+ "matplotlib>=3.7",
43
+ "gradio>=4.0",
44
+ "opendatasets>=0.1.22",
45
+ "kaggle>=1.6",
46
+ "openpyxl>=3.1",
47
+ "pyarrow>=12"
48
+ ]
49
+
50
+ [project.optional-dependencies]
51
+ dev = [
52
+ "pytest>=7",
53
+ "nbformat>=5",
54
+ "build>=1",
55
+ "twine>=5"
56
+ ]
57
+ ui = [
58
+ "gradio>=4.0",
59
+ "gradio_client>=1.0"
60
+ ]
61
+ kaggle = [
62
+ "opendatasets>=0.1.22",
63
+ "kaggle>=1.6"
64
+ ]
65
+ all = [
66
+ "torchriver[dev,kaggle,ui]"
67
+ ]
68
+
69
+ [project.urls]
70
+ Repository = "https://github.com/torchriver/torchriver"
71
+ Notebooks = "https://github.com/torchriver/torchriver/blob/main/notebooks/"
72
+ "Quick Start Notebook" = "https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start.ipynb"
73
+ "Small Quick Start Notebook" = "https://github.com/torchriver/torchriver/blob/main/notebooks/TorchRiver_Quick_Start_small.ipynb"
74
+ Examples = "https://github.com/torchriver/torchriver/tree/main/examples"
75
+ Documentation = "https://github.com/torchriver/torchriver/tree/main/docs"
76
+ Tests = "https://github.com/torchriver/torchriver/tree/main/tests"
77
+
78
+ [tool.setuptools.packages.find]
79
+ include = ["torchriver*"]
80
+ exclude = ["tests*", "notebooks*", "docs*", "examples*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,23 @@
1
+ """TorchRiver: low-flow / drought forecasting for river time-series data."""
2
+
3
+ from .configs import RiverDataConfig, RiverModelConfig, RiverTrainConfig, RiverUIConfig, TorchRiverWorkflow
4
+ from .data import make_synthetic_data
5
+ from .models import MODEL_REGISTRY, RiverCNNLSTM, build_model
6
+ from .project import RiverProject
7
+ from .serialization import load_river_model
8
+
9
+ __version__ = "2.0.0"
10
+
11
+ __all__ = [
12
+ "RiverProject",
13
+ "load_river_model",
14
+ "RiverDataConfig",
15
+ "RiverModelConfig",
16
+ "RiverTrainConfig",
17
+ "RiverUIConfig",
18
+ "TorchRiverWorkflow",
19
+ "RiverCNNLSTM",
20
+ "MODEL_REGISTRY",
21
+ "build_model",
22
+ "make_synthetic_data",
23
+ ]
@@ -0,0 +1,40 @@
1
+ """Command-line helpers for TorchRiver."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ from pathlib import Path
8
+
9
+ from . import __version__
10
+ from .project import RiverProject
11
+
12
+
13
+ def smoke() -> None:
14
+ """Print package information; useful after pip install."""
15
+ print(f"torchriver {__version__} installed successfully")
16
+
17
+
18
+ def synthetic_demo() -> None:
19
+ """Train a tiny synthetic demo and optionally save a .triver model."""
20
+ parser = argparse.ArgumentParser(description="Run a tiny TorchRiver synthetic training demo.")
21
+ parser.add_argument("--days", type=int, default=120)
22
+ parser.add_argument("--epochs", type=int, default=1)
23
+ parser.add_argument("--output", type=str, default="", help="Optional .triver output path")
24
+ args = parser.parse_args()
25
+
26
+ project = RiverProject(title="TorchRiver synthetic demo")
27
+ project.make_synthetic(days=args.days, station_codes=["R001", "R002"])
28
+ project.use_model("river_cnn_lstm", horizons=[7], lookback=14, hidden_dim=16)
29
+ project.train(epochs=args.epochs, batch_size=128, min_windows=3, verbose=False)
30
+ result = project.predict(station="R001", horizon=7)
31
+ print(json.dumps(result, ensure_ascii=False, indent=2))
32
+
33
+ if args.output:
34
+ output = Path(args.output)
35
+ project.save_model(output, include_recent_data=True)
36
+ print(f"saved: {output}")
37
+
38
+
39
+ if __name__ == "__main__":
40
+ smoke()