razaali10 commited on
Commit
51ff382
·
verified ·
1 Parent(s): ebf1a1f

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. .github/workflows/deploy.yml +32 -0
  2. LICENSE +21 -0
  3. README.md +20 -7
  4. app.py +28 -0
  5. requirements.txt +4 -0
.github/workflows/deploy.yml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy to Hugging Face Spaces
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main # Trigger on push to the main branch
7
+
8
+ jobs:
9
+ deploy:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v3
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v4
18
+ with:
19
+ python-version: 3.11
20
+
21
+ - name: Install Hugging Face CLI
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install huggingface_hub
25
+
26
+ - name: Upload to Hugging Face Space
27
+ env:
28
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
29
+ run: |
30
+ huggingface-cli upload razaali10/WNTR_V . \
31
+ --repo-type=space --token $HF_TOKEN \
32
+ --exclude '.git/*'
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Raza Ali, M.Eng, P.Eng
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.
README.md CHANGED
@@ -1,14 +1,27 @@
1
  ---
2
- title: WNTR V
3
- emoji: 🔥
4
  colorFrom: blue
5
- colorTo: yellow
6
  sdk: streamlit
7
- sdk_version: 1.44.1
8
  app_file: app.py
9
  pinned: false
10
- license: mit
11
- short_description: Water distribution system modeling
12
  ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: EPANET Simulation API
3
+ emoji: 💧
4
  colorFrom: blue
5
+ colorTo: indigo
6
  sdk: streamlit
7
+ sdk_version: "1.32.2"
8
  app_file: app.py
9
  pinned: false
 
 
10
  ---
11
 
12
+ # 💧 EPANET Simulation API using WNTR
13
+
14
+ This Hugging Face Space hosts a web-based EPANET simulation interface using the **Water Network Tool for Resilience (WNTR)** and **Streamlit**. It enables users to upload `.inp` files, configure simulation parameters, and generate hydraulic analysis results including pressure and flow data.
15
+
16
+ ...
17
+
18
+ ## 📬 Contact
19
+
20
+ For bug reports, feature requests, or professional support, contact:
21
+
22
+ **Raza Ali, P.Eng.**
23
+ Civil Engineer, Ontario
24
+ Email: *[your email]*
25
+ Hugging Face: [@razaali10](https://huggingface.co/razaali10)
26
+
27
+ ---
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import wntr
3
+ import tempfile
4
+ import os
5
+ import pandas as pd
6
+ import matplotlib.pyplot as plt
7
+
8
+ st.set_page_config(page_title="EPANET Simulation API", layout="wide")
9
+ st.title("💧 EPANET Simulation with WNTR")
10
+
11
+ uploaded_file = st.file_uploader("Upload your EPANET .inp file", type=["inp"])
12
+ if uploaded_file:
13
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".inp") as temp:
14
+ temp.write(uploaded_file.read())
15
+ inp_path = temp.name
16
+
17
+ st.success("File uploaded. Starting simulation...")
18
+
19
+ wn = wntr.network.WaterNetworkModel(inp_path)
20
+ sim = wntr.sim.EpanetSimulator(wn)
21
+ results = sim.run_sim()
22
+
23
+ st.subheader("Simulation Complete")
24
+ pressure = results.node["pressure"]
25
+ st.line_chart(pressure)
26
+
27
+ st.download_button("Download Pressure Data (CSV)", data=pressure.to_csv().encode('utf-8'),
28
+ file_name="pressure_results.csv", mime="text/csv")
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ wntr
3
+ matplotlib
4
+ pandas