-
-
Notifications
You must be signed in to change notification settings - Fork 877
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
use a single-line progress bar, addresses #1880 #2035
Conversation
- creates a globally accessible, bespoke progress bar `knit_progress()` - create `set_knit_progress()` to update value and/or printed text - also use `cat()` (instead of `message()` for printing information about processed files, to prevent mixing of streams from `stdout` and `stderr`
Hello, I just stumbled on this PR, and I was wondering if you had thought of a way to include chunk options as well. I find it useful to show them in the current progress bar, e.g:
Otherwise, this looks nice to me, so thanks |
Hi @etiennebacher, it would definitely be possible to print chunk options, though it would require some more changes. The challenge is that what can be overwritten (i.e., "updated") is only the current line, so everything that is supposed to be updated has to fit into a single line of the console. Printing chunk options to this single line would most likely make it rather unwieldy, which is why I opted against adding them. However, while working on the progress bar, I figured that the current implementation serves two rather distinct and partially conflicting purposes: The first being to inform about the processing status of the document, and the second to provide some kind of log. The new progress bar as I implemented it here (with |
Well I don't have a clear-cut opinion on how chunk options info should be displayed and implemented, I just wanted to make sure that they wouldn't be forgotten in the process of updating progress indicators. I see that you have already thought about that and have some ideas on how to include them, so I'll step aside and let you and |
@etiennebacher Thanks! I'll review this PR a couple of weeks later. For now, I just wonder if we could avoid copying code from base R. |
For the sake of at least mentioning them before committing to a decision, there are a few CRAN packages which offer progress bar tools:
There are probably other, but it interesting to know what is out there. Specifically because they have some options for the user to tweak the style and control the progress bar, while the developer (us) still controls what is reported and when. Regarding the discussion above, I agree we should try to not copying directly from base R. I believe we could adapt the logic to our need, and implement using usual style of this package. Here what I think we need and could do for the progress bar:
I guess the logic is similar than Anyway, just sharing thoughts on this. @yihui, feel free to reach out if you want to brainstorm more on this. Small feedback on the current PR: That would be best if we can start avoiding using some stringr functions. That would help us later for #1549 |
I just removed the stringr dependency. Regarding the copied code from base R: It was my impression that neither base-R functions, nor any of the simple progress-bar packages, provides progress bars where a message is updated side-by-side with a status bar. The progress package could be used to accomplish this goal, but I figured with its dependency graph, it was a bit over to the top. Therefore, I chose to use modified base-R code, because this seemed to me the most solid foundation to start from. |
⬆️ this. Perhaps it might make sense separate these two concerns:
This may conflicts/overlap with existing |
@cderv 👍
Isn't this what progressr does (already)? |
I want to invest some time to contribute in this PR. I understand from the discussion that packages for progress bar are available (like I very much agree with @maxheld83 that the progress bar is being used for two distinct purposes (report progress, and, logging information), and, that these systems should be separated. I can try to build a logging system in the way, but, maybe it should be treated in a different PR, I guess.... To maintain the code standard of I like very much of @cderv suggestions to store the current state of the progress bar in a environment. And to reuse the code standard of Therefore, For now, these ideas make sense to you? Did I understand something wrong? Is what you all meant in this discussion? |
@pedropark99 thanks for your interest. We are looking closer to the topic of progress bar for our next version. Main discussion is in #1880 We will take some time to think about the new design based on all the feedbacks for the different issues. Please do share your views so that we take it into account. Especially, we need to take time develop clearly the goals to identify the best path to tackle them before doing anything new in the code. |
Just a quick update: the current dev version of knitr uses a single-line progress bar now, and the PR #2196 allows users to choose their own custom progress bars. Feedback welcome! |
I've just verified that PR#2196 works with progressr. See my #2196 (comment) for how to set it up. Regarding @mariusbarth's comment on:
Note with progressr, this is not a problem, because progressr buffers any stdout, messages, and warnings until the next progress update is rendered. This means you can use |
Hi all,
along the lines of #1880, this is an attempt at creating a more compact progress bar.
knit_progress()
set_knit_progress()
to update value and/or printed textcat()
(instead ofmessage()
for printing information about processed files, to prevent mixing of streams fromstdout
andstderr
If
knitr::opts_knit$set(verbose = TRUE)
, new lines are added between the following lines:If
verbose = FALSE
, code bits are not printed, and all lines (exceptproceccing file: test.rmd
andoutput file: test.knit.md
) are overwritten. I hope this is quiet close to what @hadley had in mind.To avoid messages messing up the console (and the progress bar),
I now useEDIT: I came up with a better solution, a proper message handler, and could switch back tocapture.output(..., type = "message")
to first capture messages and thencat()
them above the progress bar. I'm fully aware that this might be a bit too much, but I couldn't come up with a better solution.withCallingHandlers()
.If there are any necessary changes, just let me know.