Fix task status handling and update custom
component field
This commit is contained in:
parent
026b16977a
commit
e08843485f
1 changed files with 12 additions and 0 deletions
|
|
@ -160,6 +160,10 @@ async def get_task_status(task_id: str):
|
||||||
result = None
|
result = None
|
||||||
if task.ready():
|
if task.ready():
|
||||||
result = task.result
|
result = task.result
|
||||||
|
# If result isinstance of Exception, can we get the traceback?
|
||||||
|
if isinstance(result, Exception):
|
||||||
|
logger.exception(task.traceback)
|
||||||
|
|
||||||
if isinstance(result, dict) and "result" in result:
|
if isinstance(result, dict) and "result" in result:
|
||||||
result = result["result"]
|
result = result["result"]
|
||||||
elif hasattr(result, "result"):
|
elif hasattr(result, "result"):
|
||||||
|
|
@ -167,6 +171,10 @@ async def get_task_status(task_id: str):
|
||||||
|
|
||||||
if task is None:
|
if task is None:
|
||||||
raise HTTPException(status_code=404, detail="Task not found")
|
raise HTTPException(status_code=404, detail="Task not found")
|
||||||
|
if task.status == "FAILURE":
|
||||||
|
result = str(task.result)
|
||||||
|
logger.error(f"Task {task_id} failed: {task.traceback}")
|
||||||
|
|
||||||
return TaskStatusResponse(status=task.status, result=result)
|
return TaskStatusResponse(status=task.status, result=result)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -237,3 +245,7 @@ async def custom_component_update(
|
||||||
component_node = build_langchain_template_custom_component(component, user_id=user.id, update_field=raw_code.field)
|
component_node = build_langchain_template_custom_component(component, user_id=user.id, update_field=raw_code.field)
|
||||||
# Update the field
|
# Update the field
|
||||||
return component_node
|
return component_node
|
||||||
|
# Update the field
|
||||||
|
return component_node
|
||||||
|
# Update the field
|
||||||
|
return component_node
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue