Skip to content

Commit

Permalink
Merge pull request #1552 from chenmoneygithub/fix-logging-warning
Browse files Browse the repository at this point in the history
Fix misleading warning
  • Loading branch information
okhat authored Sep 27, 2024
2 parents dac7030 + 87768c4 commit b1631ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
7 changes: 1 addition & 6 deletions dspy/evaluate/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import signal
import sys
import threading
import traceback
import types
from typing import Any
import traceback

import pandas as pd
import tqdm
Expand Down Expand Up @@ -69,11 +69,6 @@ def __init__(
self.return_all_scores = return_all_scores
self.return_outputs = return_outputs
self.provide_traceback = provide_traceback
if "display" in _kwargs:
dspy.logger.warning(
"DeprecationWarning: 'display' has been deprecated. To see all information for debugging,"
" use 'dspy.set_log_level('debug')'. In the future this will raise an error.",
)

def _execute_single_thread(self, wrapped_program, devset, display_progress):
ncorrect = 0
Expand Down
17 changes: 10 additions & 7 deletions dspy/teleprompt/copro_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ def __init__(
self.prompt_model = prompt_model
self.track_stats = track_stats

if "verbose" in _kwargs:
dspy.logger.warning("DeprecationWarning: 'verbose' has been deprecated. To see all information for debugging, use 'dspy.set_log_level('debug')'. In the future this will raise an error.")

def _check_candidates_equal(self, candidate1, candidate2):
for p1, p2 in zip(candidate1["program"].predictors(), candidate2["program"].predictors()):
if self._get_signature(p1).instructions != self._get_signature(p2).instructions:
Expand Down Expand Up @@ -199,9 +196,11 @@ def compile(self, student, *, trainset, eval_kwargs):
for p_i, (p_old, p_new) in enumerate(zip(module.predictors(), module_clone.predictors())):
candidates_ = latest_candidates[id(p_old)] # Use the most recently generated candidates for evaluation
if len(module.predictors()) > 1:
# Unless our program has multiple predictors, in which case we need to reevaluate all prompts with
# the new prompt(s) for the other predictor(s).
candidates_ = all_candidates[
id(p_old)
] # Unless our program has multiple predictors, in which case we need to reevaluate all prompts with the new prompt(s) for the other predictor(s)
]

# For each candidate
for c_i, c in enumerate(candidates_):
Expand All @@ -225,7 +224,8 @@ def compile(self, student, *, trainset, eval_kwargs):
dspy.logger.debug(f"Predictor {i+1}")
self._print_signature(predictor)
dspy.logger.info(
f"At Depth {d+1}/{self.depth}, Evaluating Prompt Candidate #{c_i+1}/{len(candidates_)} for Predictor {p_i+1} of {len(module.predictors())}.",
f"At Depth {d+1}/{self.depth}, Evaluating Prompt Candidate #{c_i+1}/{len(candidates_)} for "
f"Predictor {p_i+1} of {len(module.predictors())}.",
)
score = evaluate(module_clone, devset=trainset, **eval_kwargs)
if self.prompt_model:
Expand Down Expand Up @@ -270,7 +270,8 @@ def compile(self, student, *, trainset, eval_kwargs):
self._set_signature(p_new, updated_signature)

dspy.logger.debug(
f"Updating Predictor {id(p_old)} to:\ni: {best_candidate['instruction']}\np: {best_candidate['prefix']}",
f"Updating Predictor {id(p_old)} to:\ni: {best_candidate['instruction']}\n"
f"p: {best_candidate['prefix']}",
)
dspy.logger.debug("Full predictor with update: ")
for i, predictor in enumerate(module_clone.predictors()):
Expand Down Expand Up @@ -321,7 +322,9 @@ def compile(self, student, *, trainset, eval_kwargs):
)(attempted_instructions=attempts)

if self.prompt_model:
dspy.logger.debug(f"(self.prompt_model.inspect_history(n=1)) {self.prompt_model.inspect_history(n=1)}")
dspy.logger.debug(
f"(self.prompt_model.inspect_history(n=1)) {self.prompt_model.inspect_history(n=1)}"
)
# Get candidates for each predictor
new_candidates[id(p_base)] = instr.completions
all_candidates[id(p_base)].proposed_instruction.extend(instr.completions.proposed_instruction)
Expand Down

0 comments on commit b1631ae

Please sign in to comment.