langchain.smith.evaluation.progress.ProgressBarCallback: Make output after progress bar ends configurable #31583
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.
Description
As currently written, any print/logging statements that occur after the progress bar has reached 100% end up sandwiched against the progress bar output, because
ProgressBarCallback._print_bar()
always setsend=""
in itsprint
statement. To address the issue, This PR implements a small change inProgressBarCallback._print_bar()
, where it invokesprint(..., end="")
whenself.counter < self.total
, andprint(..., end=self.end_with)
otherwise, whereend_with
is a new__init__
param (default ="\n"
).Outcomes
Current Behavior
Under the current behavior, running the following:
Produces something that looks like:
New Behavior
With the change in this PR, the output from the previous example would look like the following:
Now, suppose the user wants to print "DONE." once the progress bar is complete, and have the "Total time ..." message to appear on the next line. They can now accomplish this via `progress_bar = ProgressBarCallback(total=10, ncols=50, end_with=" Done.\n"), which produces: