Convert to blocks
Browse files
app.py
CHANGED
|
@@ -147,7 +147,11 @@ def forecast_traffic(*day_selections):
|
|
| 147 |
red_patch = mpatches.Patch(color="red", label="Special Day")
|
| 148 |
ax.legend(handles=[blue_patch, green_patch, red_patch])
|
| 149 |
|
| 150 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
|
| 153 |
objects = load_objects()
|
|
@@ -162,12 +166,40 @@ day_buttons = [gr.Radio(value=choices[0], choices=choices, label=dn) for dn in d
|
|
| 162 |
weather = get_7day_weather(api_key)
|
| 163 |
|
| 164 |
|
| 165 |
-
iface = gr.Interface(
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
|
| 172 |
if __name__ == "__main__":
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
red_patch = mpatches.Patch(color="red", label="Special Day")
|
| 148 |
ax.legend(handles=[blue_patch, green_patch, red_patch])
|
| 149 |
|
| 150 |
+
return (
|
| 151 |
+
fig,
|
| 152 |
+
int(forecast.traffic.sum()),
|
| 153 |
+
weather[["ds", "conditions"]].rename(columns={"ds": "Date"}),
|
| 154 |
+
)
|
| 155 |
|
| 156 |
|
| 157 |
objects = load_objects()
|
|
|
|
| 166 |
weather = get_7day_weather(api_key)
|
| 167 |
|
| 168 |
|
| 169 |
+
# iface = gr.Interface(
|
| 170 |
+
# fn=forecast_traffic,
|
| 171 |
+
# inputs=[*day_buttons],
|
| 172 |
+
# outputs=[
|
| 173 |
+
# gr.Plot(show_label=False),
|
| 174 |
+
# gr.Text(label="Seven Day Traffic:"),
|
| 175 |
+
# gr.DataFrame(label="Weather Forecast:"),
|
| 176 |
+
# ],
|
| 177 |
+
# )
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
with gr.Blocks() as demo:
|
| 181 |
+
with gr.Column():
|
| 182 |
+
with gr.Row():
|
| 183 |
+
btn = gr.Button(value="Refresh")
|
| 184 |
+
map = gr.Plot()
|
| 185 |
+
demo.load(forecast_traffic, [*day_buttons], [
|
| 186 |
+
gr.Plot(show_label=False),
|
| 187 |
+
gr.Text(label="Seven Day Traffic:"),
|
| 188 |
+
gr.DataFrame(label="Weather Forecast:"),
|
| 189 |
+
])
|
| 190 |
+
btn.click(forecast_traffic, [*day_buttons], [
|
| 191 |
+
gr.Plot(show_label=False),
|
| 192 |
+
gr.Text(label="Seven Day Traffic:"),
|
| 193 |
+
gr.DataFrame(label="Weather Forecast:"),
|
| 194 |
+
])
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
|
| 199 |
|
| 200 |
|
| 201 |
if __name__ == "__main__":
|
| 202 |
+
demo.launch(share=True)
|
| 203 |
+
|
| 204 |
+
# if __name__ == "__main__":
|
| 205 |
+
# iface.launch()
|