Spaces:
Sleeping
Sleeping
yolo
Browse files- app/app.py +10 -3
- app/dashboard.ipynb +25 -6
app/app.py
CHANGED
@@ -131,6 +131,7 @@ dashboard_layout = html.Div([
|
|
131 |
], className='row'),
|
132 |
|
133 |
html.Div(id='recommended-wine-rating-info', style={'textAlign':'center'}),
|
|
|
134 |
html.Button('Reset', id='recommend-wine-from-form-reset', n_clicks=0),
|
135 |
# Button to submit the form
|
136 |
html.Button('Recommend Wine', id='recommend-wine-from-form', n_clicks=0),
|
@@ -149,15 +150,21 @@ def reset_form(n_clicks):
|
|
149 |
@app.callback(
|
150 |
Output('recommended-wine-rating-info', 'children'),
|
151 |
Output('submit-button', 'n_clicks'),
|
|
|
152 |
Input('submit-button', 'n_clicks'),
|
153 |
Input('dropdown-selection-wine-form', 'value'),
|
154 |
Input('input-wine-rating', 'value'),
|
|
|
155 |
)
|
156 |
-
def update_output(n_clicks, wine_name, rating):
|
157 |
if n_clicks > 0:
|
|
|
158 |
TEMPORARY_WINE_RECOMMENDATION_FORM_INFO[wine_name] = rating
|
159 |
-
|
160 |
-
|
|
|
|
|
|
|
161 |
|
162 |
@app.callback(
|
163 |
Output('recommended-wine-form-output', 'children'),
|
|
|
131 |
], className='row'),
|
132 |
|
133 |
html.Div(id='recommended-wine-rating-info', style={'textAlign':'center'}),
|
134 |
+
html.P(id='recommend-wine-from-form-text', style={'textAlign':'center'}),
|
135 |
html.Button('Reset', id='recommend-wine-from-form-reset', n_clicks=0),
|
136 |
# Button to submit the form
|
137 |
html.Button('Recommend Wine', id='recommend-wine-from-form', n_clicks=0),
|
|
|
150 |
@app.callback(
|
151 |
Output('recommended-wine-rating-info', 'children'),
|
152 |
Output('submit-button', 'n_clicks'),
|
153 |
+
Output('recommend-wine-from-form-text', 'children'),
|
154 |
Input('submit-button', 'n_clicks'),
|
155 |
Input('dropdown-selection-wine-form', 'value'),
|
156 |
Input('input-wine-rating', 'value'),
|
157 |
+
Input('recommend-wine-from-form-text', 'children'),
|
158 |
)
|
159 |
+
def update_output(n_clicks, wine_name, rating, text_value):
|
160 |
if n_clicks > 0:
|
161 |
+
print(f"Text Value: {text_value}")
|
162 |
TEMPORARY_WINE_RECOMMENDATION_FORM_INFO[wine_name] = rating
|
163 |
+
if not text_value:
|
164 |
+
text_value = "|"
|
165 |
+
text_value += f"{wine_name}: {rating} | "
|
166 |
+
return f'You rated {wine_name} with a score of {rating}', 0, text_value
|
167 |
+
return '', 0, text_value
|
168 |
|
169 |
@app.callback(
|
170 |
Output('recommended-wine-form-output', 'children'),
|
app/dashboard.ipynb
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
"outputs": [
|
8 |
{
|
9 |
"name": "stderr",
|
10 |
"output_type": "stream",
|
11 |
"text": [
|
12 |
-
"/var/folders/b4/lwfgccm95kqd2skcwvrt2fr00000gn/T/
|
13 |
"\n",
|
14 |
"Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
|
15 |
"\n"
|
@@ -30,7 +30,7 @@
|
|
30 |
" "
|
31 |
],
|
32 |
"text/plain": [
|
33 |
-
"<IPython.lib.display.IFrame at
|
34 |
]
|
35 |
},
|
36 |
"metadata": {},
|
@@ -48,6 +48,18 @@
|
|
48 |
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
49 |
"\n"
|
50 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
],
|
53 |
"source": [
|
@@ -184,6 +196,7 @@
|
|
184 |
" ], className='row'),\n",
|
185 |
"\n",
|
186 |
" html.Div(id='recommended-wine-rating-info', style={'textAlign':'center'}),\n",
|
|
|
187 |
" html.Button('Reset', id='recommend-wine-from-form-reset', n_clicks=0),\n",
|
188 |
" # Button to submit the form\n",
|
189 |
" html.Button('Recommend Wine', id='recommend-wine-from-form', n_clicks=0),\n",
|
@@ -202,15 +215,21 @@
|
|
202 |
"@app.callback(\n",
|
203 |
" Output('recommended-wine-rating-info', 'children'),\n",
|
204 |
" Output('submit-button', 'n_clicks'),\n",
|
|
|
205 |
" Input('submit-button', 'n_clicks'),\n",
|
206 |
" Input('dropdown-selection-wine-form', 'value'),\n",
|
207 |
" Input('input-wine-rating', 'value'),\n",
|
|
|
208 |
")\n",
|
209 |
-
"def update_output(n_clicks, wine_name, rating):\n",
|
210 |
" if n_clicks > 0:\n",
|
|
|
211 |
" TEMPORARY_WINE_RECOMMENDATION_FORM_INFO[wine_name] = rating\n",
|
212 |
-
"
|
213 |
-
"
|
|
|
|
|
|
|
214 |
"\n",
|
215 |
"@app.callback(\n",
|
216 |
" Output('recommended-wine-form-output', 'children'),\n",
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 11,
|
6 |
"metadata": {},
|
7 |
"outputs": [
|
8 |
{
|
9 |
"name": "stderr",
|
10 |
"output_type": "stream",
|
11 |
"text": [
|
12 |
+
"/var/folders/b4/lwfgccm95kqd2skcwvrt2fr00000gn/T/ipykernel_289/1621983180.py:99: FutureWarning:\n",
|
13 |
"\n",
|
14 |
"Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
|
15 |
"\n"
|
|
|
30 |
" "
|
31 |
],
|
32 |
"text/plain": [
|
33 |
+
"<IPython.lib.display.IFrame at 0x2a9e383d0>"
|
34 |
]
|
35 |
},
|
36 |
"metadata": {},
|
|
|
48 |
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
49 |
"\n"
|
50 |
]
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"name": "stdout",
|
54 |
+
"output_type": "stream",
|
55 |
+
"text": [
|
56 |
+
"Text Value: None\n",
|
57 |
+
"Text Value: Legado: 2\n",
|
58 |
+
"\n",
|
59 |
+
"Text Value: Legado: 2\n",
|
60 |
+
"Finca Flichman: 4\n",
|
61 |
+
"\n"
|
62 |
+
]
|
63 |
}
|
64 |
],
|
65 |
"source": [
|
|
|
196 |
" ], className='row'),\n",
|
197 |
"\n",
|
198 |
" html.Div(id='recommended-wine-rating-info', style={'textAlign':'center'}),\n",
|
199 |
+
" html.P(id='recommend-wine-from-form-text', style={'textAlign':'center'}),\n",
|
200 |
" html.Button('Reset', id='recommend-wine-from-form-reset', n_clicks=0),\n",
|
201 |
" # Button to submit the form\n",
|
202 |
" html.Button('Recommend Wine', id='recommend-wine-from-form', n_clicks=0),\n",
|
|
|
215 |
"@app.callback(\n",
|
216 |
" Output('recommended-wine-rating-info', 'children'),\n",
|
217 |
" Output('submit-button', 'n_clicks'),\n",
|
218 |
+
" Output('recommend-wine-from-form-text', 'children'),\n",
|
219 |
" Input('submit-button', 'n_clicks'),\n",
|
220 |
" Input('dropdown-selection-wine-form', 'value'),\n",
|
221 |
" Input('input-wine-rating', 'value'),\n",
|
222 |
+
" Input('recommend-wine-from-form-text', 'children'),\n",
|
223 |
")\n",
|
224 |
+
"def update_output(n_clicks, wine_name, rating, text_value):\n",
|
225 |
" if n_clicks > 0:\n",
|
226 |
+
" print(f\"Text Value: {text_value}\")\n",
|
227 |
" TEMPORARY_WINE_RECOMMENDATION_FORM_INFO[wine_name] = rating\n",
|
228 |
+
" if not text_value:\n",
|
229 |
+
" text_value = \"|\"\n",
|
230 |
+
" text_value += f\"{wine_name}: {rating} | \"\n",
|
231 |
+
" return f'You rated {wine_name} with a score of {rating}', 0, text_value\n",
|
232 |
+
" return '', 0, text_value\n",
|
233 |
"\n",
|
234 |
"@app.callback(\n",
|
235 |
" Output('recommended-wine-form-output', 'children'),\n",
|