Skip to content

Commit

Permalink
add price to bulk runner outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy committed Oct 28, 2023
1 parent 64d51af commit be63867
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions recipes/BulkRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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", {})
Expand All @@ -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:
Expand All @@ -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", {})
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit be63867

Please sign in to comment.