mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-01 07:13:00 +00:00
fix: add flow_class param to base save_state signature for mypy
Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -46,7 +46,11 @@ class FlowPersistence(BaseModel, ABC):
|
|||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def save_state(
|
def save_state(
|
||||||
self, flow_uuid: str, method_name: str, state_data: dict[str, Any] | BaseModel
|
self,
|
||||||
|
flow_uuid: str,
|
||||||
|
method_name: str,
|
||||||
|
state_data: dict[str, Any] | BaseModel,
|
||||||
|
flow_class: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Persist the flow state after method completion.
|
"""Persist the flow state after method completion.
|
||||||
|
|
||||||
@@ -54,6 +58,7 @@ class FlowPersistence(BaseModel, ABC):
|
|||||||
flow_uuid: Unique identifier for the flow instance
|
flow_uuid: Unique identifier for the flow instance
|
||||||
method_name: Name of the method that just completed
|
method_name: Name of the method that just completed
|
||||||
state_data: Current state data (either dict or Pydantic model)
|
state_data: Current state data (either dict or Pydantic model)
|
||||||
|
flow_class: Optional name of the flow class for auto-restore support
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|||||||
@@ -110,21 +110,12 @@ class PersistenceDecorator:
|
|||||||
try:
|
try:
|
||||||
state_data = state._unwrap() if hasattr(state, "_unwrap") else state
|
state_data = state._unwrap() if hasattr(state, "_unwrap") else state
|
||||||
flow_class_name = type(flow_instance).__name__
|
flow_class_name = type(flow_instance).__name__
|
||||||
try:
|
persistence_instance.save_state(
|
||||||
persistence_instance.save_state(
|
flow_uuid=flow_uuid,
|
||||||
flow_uuid=flow_uuid,
|
method_name=method_name,
|
||||||
method_name=method_name,
|
state_data=state_data,
|
||||||
state_data=state_data,
|
flow_class=flow_class_name,
|
||||||
flow_class=flow_class_name,
|
)
|
||||||
)
|
|
||||||
except TypeError:
|
|
||||||
# Fallback for custom persistence backends that
|
|
||||||
# don't accept the flow_class parameter
|
|
||||||
persistence_instance.save_state(
|
|
||||||
flow_uuid=flow_uuid,
|
|
||||||
method_name=method_name,
|
|
||||||
state_data=state_data,
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = LOG_MESSAGES["save_error"].format(method_name, str(e))
|
error_msg = LOG_MESSAGES["save_error"].format(method_name, str(e))
|
||||||
if verbose:
|
if verbose:
|
||||||
|
|||||||
Reference in New Issue
Block a user