|
|
|
@ -1,4 +1,5 @@
|
|
|
|
import threading
|
|
|
|
import threading
|
|
|
|
|
|
|
|
from collections.abc import Sequence
|
|
|
|
from typing import Optional
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
|
|
|
|
import contexts
|
|
|
|
import contexts
|
|
|
|
@ -6,12 +7,7 @@ from core.repositories import SQLAlchemyWorkflowNodeExecutionRepository
|
|
|
|
from core.workflow.repository.workflow_node_execution_repository import OrderConfig
|
|
|
|
from core.workflow.repository.workflow_node_execution_repository import OrderConfig
|
|
|
|
from extensions.ext_database import db
|
|
|
|
from extensions.ext_database import db
|
|
|
|
from libs.infinite_scroll_pagination import InfiniteScrollPagination
|
|
|
|
from libs.infinite_scroll_pagination import InfiniteScrollPagination
|
|
|
|
from models.enums import WorkflowRunTriggeredFrom
|
|
|
|
from models import Account, App, EndUser, WorkflowNodeExecution, WorkflowRun, WorkflowRunTriggeredFrom
|
|
|
|
from models.model import App
|
|
|
|
|
|
|
|
from models.workflow import (
|
|
|
|
|
|
|
|
WorkflowNodeExecution,
|
|
|
|
|
|
|
|
WorkflowRun,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WorkflowRunService:
|
|
|
|
class WorkflowRunService:
|
|
|
|
@ -116,7 +112,12 @@ class WorkflowRunService:
|
|
|
|
|
|
|
|
|
|
|
|
return workflow_run
|
|
|
|
return workflow_run
|
|
|
|
|
|
|
|
|
|
|
|
def get_workflow_run_node_executions(self, app_model: App, run_id: str) -> list[WorkflowNodeExecution]:
|
|
|
|
def get_workflow_run_node_executions(
|
|
|
|
|
|
|
|
self,
|
|
|
|
|
|
|
|
app_model: App,
|
|
|
|
|
|
|
|
run_id: str,
|
|
|
|
|
|
|
|
user: Account | EndUser,
|
|
|
|
|
|
|
|
) -> Sequence[WorkflowNodeExecution]:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Get workflow run node execution list
|
|
|
|
Get workflow run node execution list
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
@ -128,13 +129,12 @@ class WorkflowRunService:
|
|
|
|
if not workflow_run:
|
|
|
|
if not workflow_run:
|
|
|
|
return []
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
# Use the repository to get the node executions
|
|
|
|
|
|
|
|
repository = SQLAlchemyWorkflowNodeExecutionRepository(
|
|
|
|
repository = SQLAlchemyWorkflowNodeExecutionRepository(
|
|
|
|
session_factory=db.engine, tenant_id=app_model.tenant_id, app_id=app_model.id
|
|
|
|
session_factory=db.engine, user=user, app_id=app_model.id
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Use the repository to get the node executions with ordering
|
|
|
|
# Use the repository to get the node executions with ordering
|
|
|
|
order_config = OrderConfig(order_by=["index"], order_direction="desc")
|
|
|
|
order_config = OrderConfig(order_by=["index"], order_direction="desc")
|
|
|
|
node_executions = repository.get_by_workflow_run(workflow_run_id=run_id, order_config=order_config)
|
|
|
|
node_executions = repository.get_db_models_by_workflow_run(workflow_run_id=run_id, order_config=order_config)
|
|
|
|
|
|
|
|
|
|
|
|
return list(node_executions)
|
|
|
|
return node_executions
|
|
|
|
|