-
Notifications
You must be signed in to change notification settings - Fork 9
fix: reduce exec output size #38
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
Closed
Closed
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| import pathlib | ||
| import requests | ||
| from packaging.version import parse as parse_version | ||
| from .constants import DEFAULT_MAX_LINES, DEFAULT_MAX_CHARS | ||
|
|
||
|
|
||
| # Env/arg helper functions | ||
|
|
@@ -124,10 +125,6 @@ def smooth_update( | |
|
|
||
|
|
||
| # Other helper functions | ||
| DEFAULT_MAX_LINES = 50 | ||
| DEFAULT_MAX_CHARS = 5000 | ||
|
|
||
|
|
||
| def truncate_output(output: str, max_lines: int = DEFAULT_MAX_LINES, max_chars: int = DEFAULT_MAX_CHARS) -> str: | ||
| """Truncate the output to a reasonable size.""" | ||
| lines = output.splitlines() | ||
|
|
@@ -137,10 +134,21 @@ def truncate_output(output: str, max_lines: int = DEFAULT_MAX_LINES, max_chars: | |
| chars_truncated = len(output) > max_chars | ||
|
|
||
| # Apply truncations to the original output | ||
| if lines_truncated: | ||
| # When both limits apply, use the one that results in smaller output | ||
| if lines_truncated and chars_truncated: | ||
| lines_output = "\n".join(lines[-max_lines:]) | ||
| chars_output = output[-max_chars:] | ||
|
|
||
| # Use whichever produces smaller result | ||
| if len(lines_output) <= len(chars_output): | ||
| output = lines_output | ||
| chars_truncated = False # Only show line truncation message | ||
| else: | ||
| output = chars_output | ||
| lines_truncated = False # Only show char truncation message | ||
|
||
| elif lines_truncated: | ||
| output = "\n".join(lines[-max_lines:]) | ||
|
|
||
| if chars_truncated: | ||
| elif chars_truncated: | ||
| output = output[-max_chars:] | ||
|
|
||
| # Add prefixes for truncations that were applied | ||
|
|
||
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.
Setting flags to False to control message display creates confusing logic. Consider using a separate variable to track which truncation method was applied instead of modifying the original detection flags.