mirror of
https://github.com/langgenius/dify.git
synced 2026-01-22 11:42:05 +08:00
Some checks are pending
autofix.ci / autofix (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Main CI Pipeline / Check Changed Files (push) Waiting to run
Main CI Pipeline / API Tests (push) Blocked by required conditions
Main CI Pipeline / Web Tests (push) Blocked by required conditions
Main CI Pipeline / Style Check (push) Waiting to run
Main CI Pipeline / VDB Tests (push) Blocked by required conditions
Main CI Pipeline / DB Migration Test (push) Blocked by required conditions
This commit: 1. Convert `pause_reason` to `pause_reasons` in `GraphExecution` and relevant classes. Change the field from a scalar value to a list that can contain multiple `PauseReason` objects, ensuring all pause events are properly captured. 2. Introduce a new `WorkflowPauseReason` model to record reasons associated with a specific `WorkflowPause`. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
77 lines
2.5 KiB
Python
77 lines
2.5 KiB
Python
"""
|
|
Domain entities for workflow pause management.
|
|
|
|
This module contains the domain model for workflow pause, which is used
|
|
by the core workflow module. These models are independent of the storage mechanism
|
|
and don't contain implementation details like tenant_id, app_id, etc.
|
|
"""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from collections.abc import Sequence
|
|
from datetime import datetime
|
|
|
|
from core.workflow.entities.pause_reason import PauseReason
|
|
|
|
|
|
class WorkflowPauseEntity(ABC):
|
|
"""
|
|
Abstract base class for workflow pause entities.
|
|
|
|
This domain model represents a paused workflow execution state,
|
|
without implementation details like tenant_id, app_id, etc.
|
|
It provides the interface for managing workflow pause/resume operations
|
|
and state persistence through file storage.
|
|
|
|
The `WorkflowPauseEntity` is never reused. If a workflow execution pauses multiple times,
|
|
it will generate multiple `WorkflowPauseEntity` records.
|
|
"""
|
|
|
|
@property
|
|
@abstractmethod
|
|
def id(self) -> str:
|
|
"""The identifier of current WorkflowPauseEntity"""
|
|
pass
|
|
|
|
@property
|
|
@abstractmethod
|
|
def workflow_execution_id(self) -> str:
|
|
"""The identifier of the workflow execution record the pause associated with.
|
|
Correspond to `WorkflowExecution.id`.
|
|
"""
|
|
|
|
@abstractmethod
|
|
def get_state(self) -> bytes:
|
|
"""
|
|
Retrieve the serialized workflow state from storage.
|
|
|
|
This method should load and return the workflow execution state
|
|
that was saved when the workflow was paused. The state contains
|
|
all necessary information to resume the workflow execution.
|
|
|
|
Returns:
|
|
bytes: The serialized workflow state containing
|
|
execution context, variable values, node states, etc.
|
|
|
|
"""
|
|
...
|
|
|
|
@property
|
|
@abstractmethod
|
|
def resumed_at(self) -> datetime | None:
|
|
"""`resumed_at` return the resumption time of the current pause, or `None` if
|
|
the pause is not resumed yet.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_pause_reasons(self) -> Sequence[PauseReason]:
|
|
"""
|
|
Retrieve detailed reasons for this pause.
|
|
|
|
Returns a sequence of `PauseReason` objects describing the specific nodes and
|
|
reasons for which the workflow execution was paused.
|
|
This information is related to, but distinct from, the `PauseReason` type
|
|
defined in `api/core/workflow/entities/pause_reason.py`.
|
|
"""
|
|
...
|