-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Standardize printing of MessageTransforms #2308
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2308 +/- ##
===========================================
- Coverage 38.14% 15.54% -22.60%
===========================================
Files 78 78
Lines 7865 7880 +15
Branches 1683 1824 +141
===========================================
- Hits 3000 1225 -1775
- Misses 4615 6627 +2012
+ Partials 250 28 -222
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@microsoft-github-policy-service agree |
@giorgossideris thank you for the PR! I have one question regarding the |
This is a valid question and maybe it is a good idea, to extend |
The first iteration of this feature could stay simple; the method should return a string to print to the console for example. I'm only saying this because I can't anticipate the users' behavior/needs. |
Yes, your points are reasonable and I agree that we should probably keep it simple at the beginning.
About returning a string, I was thinking that since the string is meant for printing, it would better to be printed inside the function. Why do you think that returning a string is a better option? |
To add to (2), formatting the print statement will stay consistent across different transforms |
Sounds good, I will make this change. |
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.
Just an initial review before you implement the discussed changes
Update requirements
d6d97dc
to
ffbb67b
Compare
538a83d
to
7d99055
Compare
@giorgossideris I apologize for the delay, I got pretty busy this week. We added a few tests in transform messages related to the token limiter that needs to be moved to the new file you created. #2364
I'm still not convinced about naming the new method |
Thank you very much @WaelKarkoub, I made the changes, let me know if there is anything to add! |
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.
Looks good, great PR!
* Standardize printing of MessageTransforms * Fix pre-commit black failure * Add test for transform_messages printing * Return str instead of printing * Rename to_print_stats to verbose * Cleanup * t i# This is a combination of 3 commits. Update requirements * Remove lazy-fixture * Avoid calling apply_transform in two code paths * Format * Replace stats with logs * Handle no content messages in TokenLimiter get_logs() * Move tests from test_transform_messages to test_transforms --------- Co-authored-by: Wael Karkoub <wael.karkoub96@gmail.com>
Why are these changes needed?
Through these changes better printing of the MessageTransforms stats is achieved. Before, printing was executed both in
MessageTransform.apply_transform
methods and theTransformMessages._transform_messages
method (the last one incorrectly, as the required condition was always false as metioned in #2307). Also, there was no option to avoid these print statements.This PR aims to fix all these problems, by including a
print_stats
method in theMessageTransform
Protocol. In this way the printing is decoubled by the transforming. Also,to_print_stats
argument has been added toTransformMessages
constructor to indicate whether to print the transformations' stats or not.Related issue number
Closes #2307.
Checks