Skip to content

langchain.smith.evaluation.progress.ProgressBarCallback: Make output after progress bar ends configurable #31583

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
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dennism-tulcolabs
Copy link

@dennism-tulcolabs dennism-tulcolabs commented Jun 12, 2025

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 sets end="" in its print statement. To address the issue, This PR implements a small change in ProgressBarCallback._print_bar(), where it invokes print(..., end="") when self.counter < self.total, and print(..., end=self.end_with) otherwise, where end_with is a new __init__ param (default = "\n").

Outcomes

Current Behavior

Under the current behavior, running the following:

start = time.time()

progress_bar = ProgressBarCallback(total=10, ncols=50)
runnable.batch_as_completed(
    inputs=...,
    config=RunnableConfig(callbacks=[progress_bar])
)

end = time.time()
print(f"Total processing time: {round(end - start)} secs")

Produces something that looks like:

[------------------------------------------------->] 10/10Total processing time: 35 secs  # 'Total ...' would ideally be on new line

New Behavior

With the change in this PR, the output from the previous example would look like the following:

[------------------------------------------------->] 10/10
Total processing time: 35 secs

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:

[------------------------------------------------->] 10/10 DONE.
Total processing time: 35 secs

Copy link

vercel bot commented Jun 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Jun 12, 2025 3:53pm

Copy link

codspeed-hq bot commented Jun 12, 2025

CodSpeed Walltime Performance Report

Merging #31583 will not alter performance

Comparing dennism-tulcolabs:progressbar-newline-at-end (42824b9) with master (446a9d5)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched benchmarks

Copy link

codspeed-hq bot commented Jun 12, 2025

CodSpeed Instrumentation Performance Report

Merging #31583 will not alter performance

Comparing dennism-tulcolabs:progressbar-newline-at-end (42824b9) with master (446a9d5)

Summary

✅ 13 untouched benchmarks

@dennism-tulcolabs dennism-tulcolabs marked this pull request as ready for review June 12, 2025 16:05
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. langchain Related to the langchain package 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs labels Jun 12, 2025
@dennism-tulcolabs
Copy link
Author

@baskaryan - just checking in on whether you or anyone else on your team has had a chance to review this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
langchain Related to the langchain package 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant