-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Guard NodeLogManager against recursive stdout/stderr forwarding #44844
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
Merged
+73
−4
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e1ecb96
Initial plan
Copilot 60e2f63
fix: avoid recursive stdout/stderr forwarding in evaluation logging
Copilot b1bb20b
fix: refine log writer test and recursion guard
Copilot 5098279
fix: align recursion guard typing with Set
Copilot a9cdb82
fix: address pylint line-too-long and protected-access warnings
nagkumar91 fb99cb7
Merge branch 'main' into copilot/fix-recursion-error-evaluation
nagkumar91 ed23741
Update test (#44868)
Wixee 4064310
Merge branch 'main' into copilot/fix-recursion-error-evaluation
nagkumar91 dee8d6c
Merge branch 'main' into copilot/fix-recursion-error-evaluation
nagkumar91 d38af4c
Merge branch 'main' into copilot/fix-recursion-error-evaluation
nagkumar91 17eca69
Merge branch 'main' into copilot/fix-recursion-error-evaluation
nagkumar91 3a1f755
Update CHANGELOG.md
nagkumar91 6860ee1
Merge branch 'main' into copilot/fix-recursion-error-evaluation
w-javed 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
42 changes: 42 additions & 0 deletions
42
sdk/evaluation/azure-ai-evaluation/tests/unittests/test_logging.py
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 |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import sys | ||
| from contextlib import ExitStack | ||
| from io import StringIO | ||
|
|
||
| import pytest | ||
|
|
||
| from azure.ai.evaluation._legacy._common._logging import NodeLogManager, NodeLogWriter | ||
|
|
||
|
|
||
| @pytest.mark.unittest | ||
| def test_node_log_writer_unwraps_nested_prev_out(monkeypatch): | ||
| base_out = StringIO() | ||
| inner = NodeLogWriter(base_out) | ||
| outer = NodeLogWriter(inner) | ||
|
|
||
| outer.write("hello") | ||
|
|
||
| assert base_out.getvalue() == "hello" | ||
|
|
||
|
|
||
| @pytest.mark.unittest | ||
| def test_nested_node_log_manager_does_not_recurse(monkeypatch): | ||
| base_out = StringIO() | ||
| base_err = StringIO() | ||
| monkeypatch.setattr(sys, "stdout", base_out) | ||
| monkeypatch.setattr(sys, "stderr", base_err) | ||
| monkeypatch.setattr(sys, "__stdout__", base_out) | ||
| monkeypatch.setattr(sys, "__stderr__", base_err) | ||
|
|
||
| original_limit = sys.getrecursionlimit() | ||
| sys.setrecursionlimit(300) | ||
| try: | ||
| with ExitStack() as stack: | ||
| for _ in range(500): | ||
| stack.enter_context(NodeLogManager()) | ||
| print("nested") | ||
| sys.stderr.write("stderr") | ||
| finally: | ||
| sys.setrecursionlimit(original_limit) | ||
|
|
||
| assert "nested" in base_out.getvalue() | ||
| assert "stderr" in base_err.getvalue() | ||
nagkumar91 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.