diff --git a/recipes/BulkRunner.py b/recipes/BulkRunner.py index a6f6f0540..d36f780a3 100644 --- a/recipes/BulkRunner.py +++ b/recipes/BulkRunner.py @@ -2,7 +2,6 @@ import io import typing -from django.utils.timesince import timesince from fastapi import HTTPException from furl import furl from pydantic import BaseModel, Field @@ -162,6 +161,8 @@ def render_form_v2(self): with visible_col1: st.write("##### Inputs") + with hidden_col1: + st.write("##### Inputs") input_columns_old = st.session_state.pop("input_columns", {}) input_columns_new = st.session_state.setdefault("input_columns", {}) @@ -184,6 +185,8 @@ def render_form_v2(self): with visible_col2: st.write("##### Outputs") + with hidden_col2: + st.write("##### Outputs") # only show the first output field by default, and hide others try: @@ -198,11 +201,10 @@ def render_form_v2(self): "run_url": "Run URL", } hidden_out_fields = { - k: v for k, v in output_fields.items() if k not in visible_out_fields - } | { + "price": "Price", "run_time": "Run Time", "error_msg": "Error Msg", - } + } | {k: v for k, v in output_fields.items() if k not in visible_out_fields} output_columns_old = st.session_state.pop("output_columns", {}) output_columns_new = st.session_state.setdefault("output_columns", {}) @@ -274,9 +276,14 @@ def run_v2( ) result.get(disable_sync_subtasks=False) sr.refresh_from_db() + + run_time = datetime.timedelta( + seconds=int(sr.run_time.total_seconds()) + ) state = sr.to_dict() - state["run_time"] = timesince(datetime.datetime.now() - sr.run_time) state["run_url"] = sr.get_app_url() + state["price"] = sr.price + state["run_time"] = str(run_time) state["error_msg"] = sr.error_msg for field, col in request.output_columns.items(): diff --git a/routers/root.py b/routers/root.py index cdbfac43b..f02c2b1c5 100644 --- a/routers/root.py +++ b/routers/root.py @@ -72,6 +72,25 @@ async def favicon(): return FileResponse("static/favicon.ico") +@app.post("/handleError/") +async def handle_error(request: Request): + context = {"request": request, "settings": settings} + + def not_found(): + st.html(templates.get_template("errors/404.html").render(**context)) + + def unknown_error(): + st.html(templates.get_template("errors/unknown.html").render(**context)) + + body = await request.json() + + match body["status"]: + case 404: + return st.runner(lambda: page_wrapper(request, not_found)) + case _: + return st.runner(lambda: page_wrapper(request, unknown_error)) + + @app.get("/login/") def login(request: Request): if request.user and not request.user.is_anonymous: diff --git a/templates/404.html b/templates/404.html deleted file mode 100644 index 7389e5072..000000000 --- a/templates/404.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'base.html' %} - -{% block content %} - {% include 'login_container.html' %} -