Add duration tracking to build_vertex function
This commit is contained in:
parent
d9abe93c42
commit
29bcf3e43f
2 changed files with 7 additions and 2 deletions
|
|
@ -287,6 +287,8 @@ async def build_vertex(
|
||||||
cache = chat_service.get_cache(flow_id)
|
cache = chat_service.get_cache(flow_id)
|
||||||
graph = cache.get("result")
|
graph = cache.get("result")
|
||||||
result_dict = {}
|
result_dict = {}
|
||||||
|
duration = ""
|
||||||
|
start_time = time.perf_counter()
|
||||||
if tweaks:
|
if tweaks:
|
||||||
graph = process_tweaks_on_graph(graph, tweaks)
|
graph = process_tweaks_on_graph(graph, tweaks)
|
||||||
if not isinstance(graph, Graph):
|
if not isinstance(graph, Graph):
|
||||||
|
|
@ -303,7 +305,8 @@ async def build_vertex(
|
||||||
# to the frontend
|
# to the frontend
|
||||||
vertex.set_artifacts()
|
vertex.set_artifacts()
|
||||||
artifacts = vertex.artifacts
|
artifacts = vertex.artifacts
|
||||||
result_dict = ResultDict(results=result_dict, artifacts=artifacts)
|
duration = format_elapsed_time(time.perf_counter() - start_time)
|
||||||
|
result_dict = ResultDict(results=result_dict, artifacts=artifacts, duration=duration)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
params = str(exc)
|
params = str(exc)
|
||||||
valid = False
|
valid = False
|
||||||
|
|
|
||||||
|
|
@ -221,9 +221,11 @@ class VerticesOrderResponse(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
class ResultDict(BaseModel):
|
class ResultDict(BaseModel):
|
||||||
|
"""Outputs of the vertex build process."""
|
||||||
|
|
||||||
results: Optional[Any] = Field(default_factory=dict)
|
results: Optional[Any] = Field(default_factory=dict)
|
||||||
artifacts: Optional[Any] = Field(default_factory=dict)
|
artifacts: Optional[Any] = Field(default_factory=dict)
|
||||||
"""Outputs of the vertex build process."""
|
duration: Optional[float] = None
|
||||||
|
|
||||||
|
|
||||||
class VertexBuildResponse(BaseModel):
|
class VertexBuildResponse(BaseModel):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue