github-actions[bot] commited on
Commit
2bc81c7
·
1 Parent(s): 1ec1fc0

Update from GitHub Actions

Browse files
Files changed (9) hide show
  1. .gitignore +10 -0
  2. .python-version +1 -0
  3. README.md +0 -14
  4. app.py +17 -0
  5. fetch_data.py +49 -0
  6. main.py +6 -0
  7. pyproject.toml +7 -0
  8. requirements.txt +13 -0
  9. test.ipynb +178 -0
.gitignore ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.13
README.md CHANGED
@@ -1,14 +0,0 @@
1
- ---
2
- title: Mlops Git Hf
3
- emoji: 📈
4
- colorFrom: gray
5
- colorTo: indigo
6
- sdk: gradio
7
- sdk_version: 5.42.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- short_description: new
12
- ---
13
-
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from fetch_data import get_weather_data
3
+
4
+ st.set_page_config(page_title="🌤 Weather App", layout="centered")
5
+
6
+ st.title("🌤 Weather Dashboard")
7
+ st.write("Enter a city name to get real-time weather data from OpenWeather.")
8
+
9
+ city = st.text_input("City Name", value="Dumka")
10
+
11
+ if st.button("Get Weather"):
12
+ df, error = get_weather_data(city)
13
+ if error:
14
+ st.error(error)
15
+ else:
16
+ st.dataframe(df)
17
+ st.success(f"Weather data for {city} loaded successfully!")
fetch_data.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import required modules
2
+ import requests,json
3
+ import os
4
+ from dotenv import load_dotenv
5
+ import pandas as pd
6
+ load_dotenv()
7
+ api_key =os.getenv("OPENWEATHER_API_KEY")
8
+ #input_city = "Kolkata"
9
+ def get_weather(input_city):
10
+
11
+ base_url = "http://api.openweathermap.org/data/2.5/weather"
12
+
13
+ url=f"{base_url}?q={input_city}&appid={api_key}"
14
+ r = requests.get(url)
15
+ data = r.json()
16
+ return data
17
+
18
+ # make a function to get the above data
19
+
20
+ def get_weather_data(city):
21
+ """Process weather data and return a pandas DataFrame + error message."""
22
+ data = get_weather(city)
23
+
24
+ # API error handling
25
+ if not isinstance(data, dict) or data.get("cod") != 200:
26
+ return None, f"Error: {data.get('message', 'Unknown error')}"
27
+
28
+ try:
29
+ weather_data = {
30
+ 'City': data['name'],
31
+ 'Country': data['sys']['country'],
32
+ 'Longitude': data['coord']['lon'],
33
+ 'Latitude': data['coord']['lat'],
34
+ 'Weather Description': data['weather'][0]['description'],
35
+ 'Temperature (°C)': round(data['main']['temp'] - 273.15, 2),
36
+ 'Pressure (hPa)': data['main']['pressure'],
37
+ 'Humidity (%)': data['main']['humidity'],
38
+ 'Wind Speed (m/s)': data['wind']['speed'],
39
+ 'Wind Direction (°)': data['wind'].get('deg', None),
40
+ 'Cloudiness (%)': data['clouds']['all'],
41
+ 'Sunrise (UTC)': pd.to_datetime(data['sys']['sunrise'], unit='s'),
42
+ 'Sunset (UTC)': pd.to_datetime(data['sys']['sunset'], unit='s')
43
+ }
44
+
45
+ df = pd.DataFrame([weather_data])
46
+ return df, None
47
+
48
+ except Exception as e:
49
+ return None, f"Processing error: {str(e)}"
main.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ def main():
2
+ print("Hello from opne-weatherui!")
3
+
4
+
5
+ if __name__ == "__main__":
6
+ main()
pyproject.toml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "opne-weatherui"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ dependencies = []
requirements.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ scikit-learn
4
+ matplotlib
5
+ seaborn
6
+ joblib
7
+ requests
8
+ streamlit
9
+ huggingface_hub
10
+ dotenv
11
+ python-dotenv
12
+ gradio
13
+ streamlit
test.ipynb ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 17,
6
+ "id": "1ab5f09d",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "# import required modules\n",
11
+ "import requests,json\n",
12
+ "import os\n",
13
+ "from dotenv import load_dotenv\n",
14
+ "import pandas as pd\n",
15
+ "load_dotenv()\n",
16
+ "api_key =os.getenv(\"OPENWEATHER_API_KEY\") \n",
17
+ "input_city = \"Kolkata\"\n",
18
+ "def get_weather(input_city):\n",
19
+ " \n",
20
+ " base_url = \"http://api.openweathermap.org/data/2.5/weather\"\n",
21
+ "\n",
22
+ " url=f\"{base_url}?q={input_city}&appid={api_key}\"\n",
23
+ " r = requests.get(url)\n",
24
+ " data = r.json()\n",
25
+ " return data\n",
26
+ "\n",
27
+ "# make a function to get the above data\n",
28
+ "def get_weather_data(input_city):\n",
29
+ " data = get_weather(input_city)\n",
30
+ " weather_data = { \n",
31
+ " 'City': data['name'],\n",
32
+ " 'Country': data['sys']['country'],\n",
33
+ " 'Longitude': data['coord']['lon'],\n",
34
+ " 'Latitude': data['coord']['lat'],\n",
35
+ " 'Weather Description': data['weather'][0]['description'],\n",
36
+ " 'Temperature (K)': data['main']['temp'],\n",
37
+ " 'Pressure (hPa)': data['main']['pressure'],\n",
38
+ " 'Humidity (%)': data['main']['humidity'],\n",
39
+ " 'Wind Speed (m/s)': data['wind']['speed'],\n",
40
+ " 'Wind Direction (degrees)': data['wind']['deg'],\n",
41
+ " 'Cloudiness (%)': data['clouds']['all'],\n",
42
+ " 'Sunrise (UTC)': pd.to_datetime(data['sys']['sunrise'], unit='s'),\n",
43
+ " 'Sunset (UTC)': pd.to_datetime(data['sys']['sunset'], unit='s')\n",
44
+ " }\n",
45
+ " return pd.DataFrame([weather_data])\n"
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "code",
50
+ "execution_count": 18,
51
+ "id": "5480d192",
52
+ "metadata": {},
53
+ "outputs": [
54
+ {
55
+ "data": {
56
+ "text/html": [
57
+ "<div>\n",
58
+ "<style scoped>\n",
59
+ " .dataframe tbody tr th:only-of-type {\n",
60
+ " vertical-align: middle;\n",
61
+ " }\n",
62
+ "\n",
63
+ " .dataframe tbody tr th {\n",
64
+ " vertical-align: top;\n",
65
+ " }\n",
66
+ "\n",
67
+ " .dataframe thead th {\n",
68
+ " text-align: right;\n",
69
+ " }\n",
70
+ "</style>\n",
71
+ "<table border=\"1\" class=\"dataframe\">\n",
72
+ " <thead>\n",
73
+ " <tr style=\"text-align: right;\">\n",
74
+ " <th></th>\n",
75
+ " <th>City</th>\n",
76
+ " <th>Country</th>\n",
77
+ " <th>Longitude</th>\n",
78
+ " <th>Latitude</th>\n",
79
+ " <th>Weather Description</th>\n",
80
+ " <th>Temperature (K)</th>\n",
81
+ " <th>Pressure (hPa)</th>\n",
82
+ " <th>Humidity (%)</th>\n",
83
+ " <th>Wind Speed (m/s)</th>\n",
84
+ " <th>Wind Direction (degrees)</th>\n",
85
+ " <th>Cloudiness (%)</th>\n",
86
+ " <th>Sunrise (UTC)</th>\n",
87
+ " <th>Sunset (UTC)</th>\n",
88
+ " </tr>\n",
89
+ " </thead>\n",
90
+ " <tbody>\n",
91
+ " <tr>\n",
92
+ " <th>0</th>\n",
93
+ " <td>Kolkata</td>\n",
94
+ " <td>IN</td>\n",
95
+ " <td>88.3697</td>\n",
96
+ " <td>22.5697</td>\n",
97
+ " <td>overcast clouds</td>\n",
98
+ " <td>301.81</td>\n",
99
+ " <td>1004</td>\n",
100
+ " <td>80</td>\n",
101
+ " <td>4.06</td>\n",
102
+ " <td>181</td>\n",
103
+ " <td>100</td>\n",
104
+ " <td>2025-08-10 23:41:58</td>\n",
105
+ " <td>2025-08-11 12:41:41</td>\n",
106
+ " </tr>\n",
107
+ " </tbody>\n",
108
+ "</table>\n",
109
+ "</div>"
110
+ ],
111
+ "text/plain": [
112
+ " City Country Longitude Latitude Weather Description Temperature (K) \\\n",
113
+ "0 Kolkata IN 88.3697 22.5697 overcast clouds 301.81 \n",
114
+ "\n",
115
+ " Pressure (hPa) Humidity (%) Wind Speed (m/s) Wind Direction (degrees) \\\n",
116
+ "0 1004 80 4.06 181 \n",
117
+ "\n",
118
+ " Cloudiness (%) Sunrise (UTC) Sunset (UTC) \n",
119
+ "0 100 2025-08-10 23:41:58 2025-08-11 12:41:41 "
120
+ ]
121
+ },
122
+ "execution_count": 18,
123
+ "metadata": {},
124
+ "output_type": "execute_result"
125
+ }
126
+ ],
127
+ "source": [
128
+ "data = get_weather_data(input_city)\n",
129
+ "data"
130
+ ]
131
+ },
132
+ {
133
+ "cell_type": "code",
134
+ "execution_count": null,
135
+ "id": "87459352",
136
+ "metadata": {},
137
+ "outputs": [],
138
+ "source": []
139
+ },
140
+ {
141
+ "cell_type": "code",
142
+ "execution_count": null,
143
+ "id": "5d22db19",
144
+ "metadata": {},
145
+ "outputs": [],
146
+ "source": []
147
+ },
148
+ {
149
+ "cell_type": "code",
150
+ "execution_count": null,
151
+ "id": "9404e33b",
152
+ "metadata": {},
153
+ "outputs": [],
154
+ "source": []
155
+ }
156
+ ],
157
+ "metadata": {
158
+ "kernelspec": {
159
+ "display_name": "base",
160
+ "language": "python",
161
+ "name": "python3"
162
+ },
163
+ "language_info": {
164
+ "codemirror_mode": {
165
+ "name": "ipython",
166
+ "version": 3
167
+ },
168
+ "file_extension": ".py",
169
+ "mimetype": "text/x-python",
170
+ "name": "python",
171
+ "nbconvert_exporter": "python",
172
+ "pygments_lexer": "ipython3",
173
+ "version": "3.12.7"
174
+ }
175
+ },
176
+ "nbformat": 4,
177
+ "nbformat_minor": 5
178
+ }