-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix cache resource leaks and test failures #8744
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
Open
armoucar
wants to merge
1
commit into
stanfordnlp:main
Choose a base branch
from
armoucar:fix-cache-resource-leaks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+64
−29
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -24,7 +24,7 @@ def make_response(output_blocks): | |||||||||||||||||
model="openai/dspy-test-model", | ||||||||||||||||||
object="response", | ||||||||||||||||||
output=output_blocks, | ||||||||||||||||||
metadata = {}, | ||||||||||||||||||
metadata={}, | ||||||||||||||||||
parallel_tool_calls=False, | ||||||||||||||||||
temperature=1.0, | ||||||||||||||||||
tool_choice="auto", | ||||||||||||||||||
|
@@ -92,6 +92,8 @@ def test_dspy_cache(litellm_test_server, tmp_path): | |||||||||||||||||
|
||||||||||||||||||
assert len(usage_tracker.usage_data) == 0 | ||||||||||||||||||
|
||||||||||||||||||
# Cleanup | ||||||||||||||||||
cache.close() | ||||||||||||||||||
dspy.cache = original_cache | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
|
@@ -213,6 +215,7 @@ def test_reasoning_model_token_parameter(): | |||||||||||||||||
assert "max_tokens" in lm.kwargs | ||||||||||||||||||
assert lm.kwargs["max_tokens"] == 1000 | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
@pytest.mark.parametrize("model_name", ["openai/o1", "openai/gpt-5-nano"]) | ||||||||||||||||||
def test_reasoning_model_requirements(model_name): | ||||||||||||||||||
# Should raise assertion error if temperature or max_tokens requirements not met | ||||||||||||||||||
|
@@ -369,6 +372,8 @@ async def test_async_lm_call_with_cache(tmp_path): | |||||||||||||||||
assert len(cache.memory_cache) == 2 | ||||||||||||||||||
assert mock_alitellm_completion.call_count == 2 | ||||||||||||||||||
|
||||||||||||||||||
# Cleanup | ||||||||||||||||||
cache.close() | ||||||||||||||||||
dspy.cache = original_cache | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
|
@@ -407,6 +412,7 @@ def test_disable_history(): | |||||||||||||||||
model="openai/gpt-4o-mini", | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
def test_responses_api(litellm_test_server): | ||||||||||||||||||
api_base, _ = litellm_test_server | ||||||||||||||||||
expected_text = "This is a test answer from responses API." | ||||||||||||||||||
|
@@ -418,9 +424,7 @@ def test_responses_api(litellm_test_server): | |||||||||||||||||
"type": "message", | ||||||||||||||||||
"role": "assistant", | ||||||||||||||||||
"status": "completed", | ||||||||||||||||||
"content": [ | ||||||||||||||||||
{"type": "output_text", "text": expected_text, "annotations": []} | ||||||||||||||||||
], | ||||||||||||||||||
"content": [{"type": "output_text", "text": expected_text, "annotations": []}], | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] This formatting change appears to be unrelated to the cache resource leak fix. The original multi-line format was more readable for this nested dictionary structure.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||
} | ||||||||||||||||||
] | ||||||||||||||||||
) | ||||||||||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition
hasattr(self.memory_cache, "clear")
will always be false whenself.memory_cache
is an empty dict ({}
). When memory cache is disabled,self.memory_cache = {}
in the constructor, and dictionaries always have aclear()
method. This means the clear operation will be attempted even when memory cache is disabled, which is inconsistent with the intended behavior.Copilot uses AI. Check for mistakes.