Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Parallel Executor #2031

Open
wants to merge 7 commits into
base: fix-streaming
Choose a base branch
from

Conversation

CyrusNuevoDia
Copy link
Collaborator

No description provided.

@CyrusNuevoDia CyrusNuevoDia changed the base branch from main to fix-streaming January 9, 2025 10:56
Comment on lines -71 to -106
def test_multi_thread_evaluate_call_cancelled(monkeypatch):
# slow LM that sleeps for 1 second before returning the answer
class SlowLM(DummyLM):
def __call__(self, *args, **kwargs):
import time

time.sleep(1)
return super().__call__(*args, **kwargs)

dspy.settings.configure(lm=SlowLM({"What is 1+1?": {"answer": "2"}, "What is 2+2?": {"answer": "4"}}))

devset = [new_example("What is 1+1?", "2"), new_example("What is 2+2?", "4")]
program = Predict("question -> answer")
assert program(question="What is 1+1?").answer == "2"

# spawn a thread that will sleep for .1 seconds then send a KeyboardInterrupt
def sleep_then_interrupt():
import time

time.sleep(0.1)
import os

os.kill(os.getpid(), signal.SIGINT)

input_thread = threading.Thread(target=sleep_then_interrupt)
input_thread.start()

with pytest.raises(KeyboardInterrupt):
ev = Evaluate(
devset=devset,
metric=answer_exact_match,
display_progress=False,
num_threads=2,
)
score = ev(program)
assert score == 100.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effectively got moved to tests/utils/test_parallelizer.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant