@@ -38,7 +38,7 @@ def forward(self, **kwargs):
38
38
def test_compile_with_predict_instances_no_explicit_lm ():
39
39
"""Test BootstrapFinetune compile with predictors that don't have explicit LMs."""
40
40
from unittest .mock import patch
41
-
41
+
42
42
# Create student and teacher modules without explicit LMs in predictors
43
43
student = SimpleModule ("input -> output" )
44
44
teacher = SimpleModule ("input -> output" )
@@ -50,20 +50,20 @@ def test_compile_with_predict_instances_no_explicit_lm():
50
50
# Verify that the predictor doesn't have an explicit LM
51
51
assert student .predictor .lm is None
52
52
bootstrap = BootstrapFinetune (metric = simple_metric )
53
-
53
+
54
54
# Mock all the components that would fail without proper setup
55
- with patch (' dspy.teleprompt.bootstrap_finetune.all_predictors_have_lms' ), \
56
- patch (' dspy.teleprompt.bootstrap_finetune.prepare_teacher' , return_value = teacher ), \
57
- patch (' dspy.teleprompt.bootstrap_finetune.bootstrap_trace_data' , return_value = []), \
58
- patch .object (bootstrap , ' _prepare_finetune_data' , return_value = ([], ' openai' )), \
59
- patch .object (bootstrap , ' finetune_lms' ) as mock_finetune_lms :
60
-
55
+ with patch (" dspy.teleprompt.bootstrap_finetune.all_predictors_have_lms" ), \
56
+ patch (" dspy.teleprompt.bootstrap_finetune.prepare_teacher" , return_value = teacher ), \
57
+ patch (" dspy.teleprompt.bootstrap_finetune.bootstrap_trace_data" , return_value = []), \
58
+ patch .object (bootstrap , " _prepare_finetune_data" , return_value = ([], " openai" )), \
59
+ patch .object (bootstrap , " finetune_lms" ) as mock_finetune_lms :
60
+
61
61
mock_finetune_lms .return_value = {(lm , None ): lm }
62
-
62
+
63
63
# This should not raise AttributeError due to the fix
64
64
compiled_student = bootstrap .compile (student , teacher = teacher , trainset = trainset )
65
-
65
+
66
66
assert compiled_student is not None , "Failed to compile student"
67
67
mock_finetune_lms .assert_called_once ()
68
-
68
+
69
69
0 commit comments