mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-30 23:02:50 +00:00
fix: address review comments - remove unused import and deduplicate log messages
Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -46,8 +46,7 @@ T = TypeVar("T")
|
|||||||
|
|
||||||
# Constants for log messages
|
# Constants for log messages
|
||||||
LOG_MESSAGES: Final[dict[str, str]] = {
|
LOG_MESSAGES: Final[dict[str, str]] = {
|
||||||
"save_state": "Saving flow state for ID: {}",
|
"save_state": "Saving flow state for ID: {} (storage: {})",
|
||||||
"save_state_location": "Saving flow state for ID: {} (storage: {})",
|
|
||||||
"save_error": "Failed to persist state for method {}: {}",
|
"save_error": "Failed to persist state for method {}: {}",
|
||||||
"state_missing": "Flow instance has no state",
|
"state_missing": "Flow instance has no state",
|
||||||
"id_missing": "Flow state must have an 'id' field for persistence",
|
"id_missing": "Flow state must have an 'id' field for persistence",
|
||||||
@@ -101,13 +100,6 @@ class PersistenceDecorator:
|
|||||||
if not flow_uuid:
|
if not flow_uuid:
|
||||||
raise ValueError("Flow state must have an 'id' field for persistence")
|
raise ValueError("Flow state must have an 'id' field for persistence")
|
||||||
|
|
||||||
# Log state saving only if verbose is True
|
|
||||||
if verbose:
|
|
||||||
PRINTER.print(
|
|
||||||
LOG_MESSAGES["save_state"].format(flow_uuid), color="cyan"
|
|
||||||
)
|
|
||||||
logger.info(LOG_MESSAGES["save_state"].format(flow_uuid))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
state_data = state._unwrap() if hasattr(state, "_unwrap") else state
|
state_data = state._unwrap() if hasattr(state, "_unwrap") else state
|
||||||
persistence_instance.save_state(
|
persistence_instance.save_state(
|
||||||
@@ -126,14 +118,10 @@ class PersistenceDecorator:
|
|||||||
storage_location = getattr(
|
storage_location = getattr(
|
||||||
persistence_instance, "db_path", type(persistence_instance).__name__
|
persistence_instance, "db_path", type(persistence_instance).__name__
|
||||||
)
|
)
|
||||||
|
msg = LOG_MESSAGES["save_state"].format(flow_uuid, storage_location)
|
||||||
if verbose:
|
if verbose:
|
||||||
msg = LOG_MESSAGES["save_state_location"].format(
|
|
||||||
flow_uuid, storage_location
|
|
||||||
)
|
|
||||||
PRINTER.print(msg, color="cyan")
|
PRINTER.print(msg, color="cyan")
|
||||||
logger.info(
|
logger.info(msg)
|
||||||
LOG_MESSAGES["save_state_location"].format(flow_uuid, storage_location)
|
|
||||||
)
|
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
error_msg = LOG_MESSAGES["state_missing"]
|
error_msg = LOG_MESSAGES["state_missing"]
|
||||||
if verbose:
|
if verbose:
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
"""Test flow state persistence functionality."""
|
"""Test flow state persistence functionality."""
|
||||||
|
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user