Spaces:
Build error
Build error
updating gradio
Browse files- app.py +20 -9
- app2.py +6 -0
- debug.ipynb +234 -7
- requirements-llm.txt +0 -11
- scheduler.py +1 -1
app.py
CHANGED
|
@@ -2,19 +2,30 @@ import gradio as gr
|
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
| 4 |
import random
|
|
|
|
|
|
|
| 5 |
|
| 6 |
from datetime import datetime, timedelta
|
| 7 |
now = datetime.now()
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
with gr.Blocks() as demo:
|
| 17 |
-
gr.
|
| 18 |
-
gr.
|
| 19 |
|
| 20 |
-
demo.launch()
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
| 4 |
import random
|
| 5 |
+
import os
|
| 6 |
+
import hopsworks
|
| 7 |
|
| 8 |
from datetime import datetime, timedelta
|
| 9 |
now = datetime.now()
|
| 10 |
|
| 11 |
+
api_key = os.getenv('HOPSWORKS_API_KEY')
|
| 12 |
+
project_name = os.getenv('HOPSWORKS_PROJECT')
|
| 13 |
+
|
| 14 |
+
project = hopsworks.login(project=project_name, api_key_value=api_key)
|
| 15 |
+
fs = project.get_feature_store()
|
| 16 |
+
|
| 17 |
+
air_quality_fg = fs.get_feature_group(
|
| 18 |
+
name='air_quality',
|
| 19 |
+
version=1,
|
| 20 |
+
)
|
| 21 |
+
air_quality_df = air_quality_fg.read()
|
| 22 |
+
air_quality_df
|
| 23 |
+
|
| 24 |
+
print(air_quality_df.info())
|
| 25 |
+
print(air_quality_df)
|
| 26 |
|
| 27 |
with gr.Blocks() as demo:
|
| 28 |
+
gr.Markdown("Helsingborg Air Quality Forecast")
|
| 29 |
+
gr.LinePlot(air_quality_df, x="date", y="pm25")
|
| 30 |
|
| 31 |
+
demo.launch()
|
app2.py
AD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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
"outputs": [],
|
| 12 |
-
"source": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
],
|
| 15 |
"metadata": {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
"language_info": {
|
| 17 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
},
|
| 20 |
"nbformat": 4,
|
|
|
|
| 2 |
"cells": [
|
| 3 |
{
|
| 4 |
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [
|
| 8 |
+
{
|
| 9 |
+
"name": "stderr",
|
| 10 |
+
"output_type": "stream",
|
| 11 |
+
"text": [
|
| 12 |
+
"/home/robert/Documents/scalable-ml/hbg-weather/.venv/lib/python3.12/site-packages/gradio_client/documentation.py:106: UserWarning: Could not get documentation group for <class 'gradio.mix.Parallel'>: No known documentation group for module 'gradio.mix'\n",
|
| 13 |
+
" warnings.warn(f\"Could not get documentation group for {cls}: {exc}\")\n",
|
| 14 |
+
"/home/robert/Documents/scalable-ml/hbg-weather/.venv/lib/python3.12/site-packages/gradio_client/documentation.py:106: UserWarning: Could not get documentation group for <class 'gradio.mix.Series'>: No known documentation group for module 'gradio.mix'\n",
|
| 15 |
+
" warnings.warn(f\"Could not get documentation group for {cls}: {exc}\")\n"
|
| 16 |
+
]
|
| 17 |
}
|
| 18 |
+
],
|
| 19 |
+
"source": [
|
| 20 |
+
"import gradio as gr\n",
|
| 21 |
+
"import pandas as pd\n",
|
| 22 |
+
"import numpy as np\n",
|
| 23 |
+
"import random\n",
|
| 24 |
+
"import os \n",
|
| 25 |
+
"import hopsworks"
|
| 26 |
+
]
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"cell_type": "code",
|
| 30 |
+
"execution_count": 2,
|
| 31 |
+
"metadata": {},
|
| 32 |
+
"outputs": [
|
| 33 |
+
{
|
| 34 |
+
"name": "stdout",
|
| 35 |
+
"output_type": "stream",
|
| 36 |
+
"text": [
|
| 37 |
+
"Connected. Call `.close()` to terminate connection gracefully.\n",
|
| 38 |
+
"\n",
|
| 39 |
+
"Logged in to project, explore it here https://c.app.hopsworks.ai:443/p/1160340\n",
|
| 40 |
+
"2024-11-19 17:58:26,633 WARNING: using legacy validation callback\n",
|
| 41 |
+
"Connected. Call `.close()` to terminate connection gracefully.\n",
|
| 42 |
+
"Finished: Reading data from Hopsworks, using Hopsworks Feature Query Service (2.16s) \n",
|
| 43 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
| 44 |
+
"RangeIndex: 1589 entries, 0 to 1588\n",
|
| 45 |
+
"Data columns (total 6 columns):\n",
|
| 46 |
+
" # Column Non-Null Count Dtype \n",
|
| 47 |
+
"--- ------ -------------- ----- \n",
|
| 48 |
+
" 0 date 1589 non-null object \n",
|
| 49 |
+
" 1 pm25 1589 non-null float32\n",
|
| 50 |
+
" 2 country 1589 non-null object \n",
|
| 51 |
+
" 3 city 1589 non-null object \n",
|
| 52 |
+
" 4 street 1589 non-null object \n",
|
| 53 |
+
" 5 url 1589 non-null object \n",
|
| 54 |
+
"dtypes: float32(1), object(5)\n",
|
| 55 |
+
"memory usage: 68.4+ KB\n",
|
| 56 |
+
"None\n",
|
| 57 |
+
" date pm25 country city street \\\n",
|
| 58 |
+
"0 2024-02-23 18.0 Sweden Helsingborg Drottninggatan \n",
|
| 59 |
+
"1 2021-09-22 36.0 Sweden Helsingborg Drottninggatan \n",
|
| 60 |
+
"2 2022-09-25 55.0 Sweden Helsingborg Drottninggatan \n",
|
| 61 |
+
"3 2024-08-25 24.0 Sweden Helsingborg Drottninggatan \n",
|
| 62 |
+
"4 2023-01-06 18.0 Sweden Helsingborg Drottninggatan \n",
|
| 63 |
+
"\n",
|
| 64 |
+
" url \n",
|
| 65 |
+
"0 https://api.waqi.info/feed/@12519/ \n",
|
| 66 |
+
"1 https://api.waqi.info/feed/@12519/ \n",
|
| 67 |
+
"2 https://api.waqi.info/feed/@12519/ \n",
|
| 68 |
+
"3 https://api.waqi.info/feed/@12519/ \n",
|
| 69 |
+
"4 https://api.waqi.info/feed/@12519/ \n"
|
| 70 |
+
]
|
| 71 |
+
}
|
| 72 |
+
],
|
| 73 |
+
"source": [
|
| 74 |
+
"\n",
|
| 75 |
+
"from datetime import datetime, timedelta\n",
|
| 76 |
+
"now = datetime.now()\n",
|
| 77 |
+
"\n",
|
| 78 |
+
"api_key = os.getenv('HOPSWORKS_API_KEY')\n",
|
| 79 |
+
"project_name = os.getenv('HOPSWORKS_PROJECT')\n",
|
| 80 |
+
"\n",
|
| 81 |
+
"project = hopsworks.login(project=project_name, api_key_value=api_key)\n",
|
| 82 |
+
"fs = project.get_feature_store() \n",
|
| 83 |
+
"\n",
|
| 84 |
+
"air_quality_fg = fs.get_feature_group(\n",
|
| 85 |
+
" name='air_quality',\n",
|
| 86 |
+
" version=1,\n",
|
| 87 |
+
")\n",
|
| 88 |
+
"air_quality_df = air_quality_fg.read()\n",
|
| 89 |
+
"air_quality_df\n",
|
| 90 |
+
"\n",
|
| 91 |
+
"print(air_quality_df.info())\n",
|
| 92 |
+
"print(air_quality_df.head())"
|
| 93 |
+
]
|
| 94 |
+
},
|
| 95 |
+
{
|
| 96 |
+
"cell_type": "code",
|
| 97 |
+
"execution_count": 7,
|
| 98 |
+
"metadata": {},
|
| 99 |
+
"outputs": [
|
| 100 |
+
{
|
| 101 |
+
"data": {
|
| 102 |
+
"text/html": [
|
| 103 |
+
"<div>\n",
|
| 104 |
+
"<style scoped>\n",
|
| 105 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 106 |
+
" vertical-align: middle;\n",
|
| 107 |
+
" }\n",
|
| 108 |
+
"\n",
|
| 109 |
+
" .dataframe tbody tr th {\n",
|
| 110 |
+
" vertical-align: top;\n",
|
| 111 |
+
" }\n",
|
| 112 |
+
"\n",
|
| 113 |
+
" .dataframe thead th {\n",
|
| 114 |
+
" text-align: right;\n",
|
| 115 |
+
" }\n",
|
| 116 |
+
"</style>\n",
|
| 117 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 118 |
+
" <thead>\n",
|
| 119 |
+
" <tr style=\"text-align: right;\">\n",
|
| 120 |
+
" <th></th>\n",
|
| 121 |
+
" <th>date</th>\n",
|
| 122 |
+
" <th>pm25</th>\n",
|
| 123 |
+
" </tr>\n",
|
| 124 |
+
" </thead>\n",
|
| 125 |
+
" <tbody>\n",
|
| 126 |
+
" <tr>\n",
|
| 127 |
+
" <th>0</th>\n",
|
| 128 |
+
" <td>2024-02-23</td>\n",
|
| 129 |
+
" <td>18.0</td>\n",
|
| 130 |
+
" </tr>\n",
|
| 131 |
+
" <tr>\n",
|
| 132 |
+
" <th>1</th>\n",
|
| 133 |
+
" <td>2021-09-22</td>\n",
|
| 134 |
+
" <td>36.0</td>\n",
|
| 135 |
+
" </tr>\n",
|
| 136 |
+
" <tr>\n",
|
| 137 |
+
" <th>2</th>\n",
|
| 138 |
+
" <td>2022-09-25</td>\n",
|
| 139 |
+
" <td>55.0</td>\n",
|
| 140 |
+
" </tr>\n",
|
| 141 |
+
" <tr>\n",
|
| 142 |
+
" <th>3</th>\n",
|
| 143 |
+
" <td>2024-08-25</td>\n",
|
| 144 |
+
" <td>24.0</td>\n",
|
| 145 |
+
" </tr>\n",
|
| 146 |
+
" <tr>\n",
|
| 147 |
+
" <th>4</th>\n",
|
| 148 |
+
" <td>2023-01-06</td>\n",
|
| 149 |
+
" <td>18.0</td>\n",
|
| 150 |
+
" </tr>\n",
|
| 151 |
+
" <tr>\n",
|
| 152 |
+
" <th>...</th>\n",
|
| 153 |
+
" <td>...</td>\n",
|
| 154 |
+
" <td>...</td>\n",
|
| 155 |
+
" </tr>\n",
|
| 156 |
+
" <tr>\n",
|
| 157 |
+
" <th>1584</th>\n",
|
| 158 |
+
" <td>2022-11-26</td>\n",
|
| 159 |
+
" <td>42.0</td>\n",
|
| 160 |
+
" </tr>\n",
|
| 161 |
+
" <tr>\n",
|
| 162 |
+
" <th>1585</th>\n",
|
| 163 |
+
" <td>2021-02-27</td>\n",
|
| 164 |
+
" <td>35.0</td>\n",
|
| 165 |
+
" </tr>\n",
|
| 166 |
+
" <tr>\n",
|
| 167 |
+
" <th>1586</th>\n",
|
| 168 |
+
" <td>2021-10-26</td>\n",
|
| 169 |
+
" <td>36.0</td>\n",
|
| 170 |
+
" </tr>\n",
|
| 171 |
+
" <tr>\n",
|
| 172 |
+
" <th>1587</th>\n",
|
| 173 |
+
" <td>2022-05-12</td>\n",
|
| 174 |
+
" <td>21.0</td>\n",
|
| 175 |
+
" </tr>\n",
|
| 176 |
+
" <tr>\n",
|
| 177 |
+
" <th>1588</th>\n",
|
| 178 |
+
" <td>2024-11-16</td>\n",
|
| 179 |
+
" <td>34.0</td>\n",
|
| 180 |
+
" </tr>\n",
|
| 181 |
+
" </tbody>\n",
|
| 182 |
+
"</table>\n",
|
| 183 |
+
"<p>1589 rows × 2 columns</p>\n",
|
| 184 |
+
"</div>"
|
| 185 |
+
],
|
| 186 |
+
"text/plain": [
|
| 187 |
+
" date pm25\n",
|
| 188 |
+
"0 2024-02-23 18.0\n",
|
| 189 |
+
"1 2021-09-22 36.0\n",
|
| 190 |
+
"2 2022-09-25 55.0\n",
|
| 191 |
+
"3 2024-08-25 24.0\n",
|
| 192 |
+
"4 2023-01-06 18.0\n",
|
| 193 |
+
"... ... ...\n",
|
| 194 |
+
"1584 2022-11-26 42.0\n",
|
| 195 |
+
"1585 2021-02-27 35.0\n",
|
| 196 |
+
"1586 2021-10-26 36.0\n",
|
| 197 |
+
"1587 2022-05-12 21.0\n",
|
| 198 |
+
"1588 2024-11-16 34.0\n",
|
| 199 |
+
"\n",
|
| 200 |
+
"[1589 rows x 2 columns]"
|
| 201 |
+
]
|
| 202 |
+
},
|
| 203 |
+
"execution_count": 7,
|
| 204 |
+
"metadata": {},
|
| 205 |
+
"output_type": "execute_result"
|
| 206 |
+
}
|
| 207 |
+
],
|
| 208 |
+
"source": [
|
| 209 |
+
"air_quality_df[['date', 'pm25']]"
|
| 210 |
+
]
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"cell_type": "code",
|
| 214 |
+
"execution_count": null,
|
| 215 |
+
"metadata": {},
|
| 216 |
"outputs": [],
|
| 217 |
+
"source": [
|
| 218 |
+
"\n",
|
| 219 |
+
"with gr.Blocks() as demo:\n",
|
| 220 |
+
" gr.Markdown(\"Helsingborg Air Quality Forecast\")\n",
|
| 221 |
+
" gr.LinePlot(air_quality_df, x=\"time\", y=\"price\")\n",
|
| 222 |
+
" gr.ScatterPlot(air_quality_df['pm25'], x=\"time\", y=\"price\", color=\"origin\")\n",
|
| 223 |
+
"\n",
|
| 224 |
+
"demo.launch() "
|
| 225 |
+
]
|
| 226 |
}
|
| 227 |
],
|
| 228 |
"metadata": {
|
| 229 |
+
"kernelspec": {
|
| 230 |
+
"display_name": ".venv",
|
| 231 |
+
"language": "python",
|
| 232 |
+
"name": "python3"
|
| 233 |
+
},
|
| 234 |
"language_info": {
|
| 235 |
+
"codemirror_mode": {
|
| 236 |
+
"name": "ipython",
|
| 237 |
+
"version": 3
|
| 238 |
+
},
|
| 239 |
+
"file_extension": ".py",
|
| 240 |
+
"mimetype": "text/x-python",
|
| 241 |
+
"name": "python",
|
| 242 |
+
"nbconvert_exporter": "python",
|
| 243 |
+
"pygments_lexer": "ipython3",
|
| 244 |
+
"version": "3.12.4"
|
| 245 |
}
|
| 246 |
},
|
| 247 |
"nbformat": 4,
|
requirements-llm.txt
DELETED
|
@@ -1,11 +0,0 @@
|
|
| 1 |
-
# LLM libraries
|
| 2 |
-
gradio==3.40.1
|
| 3 |
-
getpass4==0.0.14.1
|
| 4 |
-
|
| 5 |
-
transformers==4.38.2
|
| 6 |
-
langchain==0.1.10
|
| 7 |
-
bitsandbytes==0.42.0
|
| 8 |
-
accelerate==0.27.2
|
| 9 |
-
|
| 10 |
-
# OpenAI
|
| 11 |
-
openai==1.14.3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scheduler.py
CHANGED
|
@@ -2,6 +2,6 @@ import modal
|
|
| 2 |
|
| 3 |
app = modal.App('scheduler')
|
| 4 |
|
| 5 |
-
@app.function(schedule=modal.Period(
|
| 6 |
def update():
|
| 7 |
print('Updating...')
|
|
|
|
| 2 |
|
| 3 |
app = modal.App('scheduler')
|
| 4 |
|
| 5 |
+
@app.function(schedule=modal.Period(minutes=1))
|
| 6 |
def update():
|
| 7 |
print('Updating...')
|