Procházet zdrojové kódy

fix: Replace generic exceptions with specific error classes in task p… (#12036)

Signed-off-by: -LAN- <laipz8200@outlook.com>
tags/0.15.0
-LAN- před 10 měsíci
rodič
revize
82134a1d50
Žádný účet není propojen s e-mailovou adresou tvůrce revize

+ 1
- 1
api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py Zobrazit soubor

else: else:
continue continue


raise Exception("Queue listening stopped unexpectedly.")
raise RuntimeError("queue listening stopped unexpectedly.")


def _to_stream_response( def _to_stream_response(
self, generator: Generator[StreamResponse, None, None] self, generator: Generator[StreamResponse, None, None]

+ 17
- 0
api/core/app/task_pipeline/exc.py Zobrazit soubor

class TaskPipilineError(ValueError):
pass


class RecordNotFoundError(TaskPipilineError):
def __init__(self, record_name: str, record_id: str):
super().__init__(f"{record_name} with id {record_id} not found")


class WorkflowRunNotFoundError(RecordNotFoundError):
def __init__(self, workflow_run_id: str):
super().__init__("WorkflowRun", workflow_run_id)


class WorkflowNodeExecutionNotFoundError(RecordNotFoundError):
def __init__(self, workflow_node_execution_id: str):
super().__init__("WorkflowNodeExecution", workflow_node_execution_id)

+ 4
- 2
api/core/app/task_pipeline/workflow_cycle_manage.py Zobrazit soubor

WorkflowRunStatus, WorkflowRunStatus,
) )


from .exc import WorkflowNodeExecutionNotFoundError, WorkflowRunNotFoundError



class WorkflowCycleManage: class WorkflowCycleManage:
_application_generate_entity: Union[AdvancedChatAppGenerateEntity, WorkflowAppGenerateEntity] _application_generate_entity: Union[AdvancedChatAppGenerateEntity, WorkflowAppGenerateEntity]
workflow_run = db.session.query(WorkflowRun).filter(WorkflowRun.id == workflow_run_id).first() workflow_run = db.session.query(WorkflowRun).filter(WorkflowRun.id == workflow_run_id).first()


if not workflow_run: if not workflow_run:
raise Exception(f"Workflow run not found: {workflow_run_id}")
raise WorkflowRunNotFoundError(workflow_run_id)


return workflow_run return workflow_run


workflow_node_execution = self._wip_workflow_node_executions.get(node_execution_id) workflow_node_execution = self._wip_workflow_node_executions.get(node_execution_id)


if not workflow_node_execution: if not workflow_node_execution:
raise Exception(f"Workflow node execution not found: {node_execution_id}")
raise WorkflowNodeExecutionNotFoundError(node_execution_id)


return workflow_node_execution return workflow_node_execution

Načítá se…
Zrušit
Uložit