From be63867b6ceeacdfe8f83496373e9d321922b346 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Fri, 20 Oct 2023 21:29:47 +0530 Subject: [PATCH] add price to bulk runner outputs --- recipes/BulkRunner.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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():