DSPy: The framework for programming—not prompting—language models
Python
warning for deep copy
chenmoneygithub1408999bed34
diff --git a/dspy/primitives/module.py b/dspy/primitives/module.pyindex bcbf42b35..5df2b308d 100644--- a/dspy/primitives/module.py+++ b/dspy/primitives/module.py@@ -1,4 +1,5 @@import copy+import loggingfrom collections import dequefrom collections.abc import Generator@@ -125,6 +126,10 @@ class BaseModule:# Try to deep copy the attributesetattr(new_instance, attr, copy.deepcopy(value))except Exception:+ logging.warning(+ f"Failed to deep copy attribute '{attr}' of {self.__class__.__name__}, "+ "falling back to shallow copy or reference copy."+ )try:# Fallback to shallow copy if deep copy failssetattr(new_instance, attr, copy.copy(value))