-
Notifications
You must be signed in to change notification settings - Fork 129
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
Option to display stderr output in real time #588
Comments
I think the most relevant threads are #212, #400, #401, futureverse/future#25, and futureverse/future#171. As you alluded to, some modes of parallel execution interfere with stderr, so It is possible to still print messages in real time. The quickest fix is to remove the call to Lines 19 to 36 in 69ec117
However, this causes messages to print twice. #> make(plan, targets = "a")
target a
Running...
Still going...
Done
Target a messages:
Running...
Still going...
Done @lorenzwalthert, what do you think? Are real-time messages worth messy duplication? |
Personally, I would be perfectly happy with an additional logical argument ( Just spitballing here, but an idea for down the road would be to allow this to be set on a target-by-target basis. I could definitely envision cases where I want the output of some steps to be suppressed and others to be verbose. |
The extra modularity should help #588
Good ideas. In the case of |
I think I found a compromise. In bc06e8c, stderr is still delayed in the console, but it prints to library(drake)
drake::clean(destroy = TRUE)
f1 <- function() {
message("Running...")
warning("warning 1")
Sys.sleep(5)
message("Still going...")
warning("warning 2")
Sys.sleep(5)
message("Done")
warning("warning 3")
stop(":)")
}
plan <- drake_plan(a = f1())
make(plan, console_log_file = "log.txt")
#> target a
#> Warning: target a warnings:
#> warning 1
#> warning 2
#> warning 3
#> Target a messages:
#> Running...
#> Still going...
#> Done
#> fail a
#> Error: Target `a` failed. Call `diagnose(a)` for details. Error message:
#> :)
#> In addition: Warning messages:
#> 1: In f1() : warning 1
#> 2: In f1() : warning 2
#> 3: In f1() : warning 3
cat(readLines("log.txt"), sep = "\n")
#> target a
#> Running...
#> Warning: warning 1
#> Still going...
#> Warning: warning 2
#> Done
#> Warning: warning 3
#> fail a
#> Error: Target `a` failed. Call `diagnose(a)` for details. Error message:
#> :) |
This looks great, thanks for the quick fix! For the record, with the new fix, to have the messages print to the console in real time, I can run this as: |
Glad this works for you. And thanks for the tip about Some final remarks: due to tidyverse/reprex#118 and related issues, library(drake)
knitr::opts_chunk$set(message = FALSE)
drake::clean(destroy = TRUE)
f1 <- function() {
message("Running...")
warning("warning 1")
Sys.sleep(5)
message("Still going...")
warning("warning 2")
Sys.sleep(5)
message("Done")
warning("warning 3")
stop(":)")
}
plan <- drake_plan(a = f1())
make(plan, console_log_file = "log.txt")
#> target a
#> Running...
#> Warning in f1(): warning 1
#> Still going...
#> Warning in f1(): warning 2
#> Done
#> Warning in f1(): warning 3
#> Warning: target a warnings:
#> warning 1
#> warning 2
#> warning 3
#> Target a messages:
#> Running...
#> Still going...
#> Done
#> fail a
#> Error: Target `a` failed. Call `diagnose(a)` for details. Error message:
#> :)
cat(readLines("log.txt"), sep = "\n")
#> target a
#> Running...
#> Warning: warning 1
#> Still going...
#> Warning: warning 2
#> Done
#> Warning: warning 3
#> fail a
#> Error: Target `a` failed. Call `diagnose(a)` for details. Error message:
#> :) Created on 2018-11-28 by the reprex package (v0.2.1) |
Sometimes you just wait and other people solve things so your (uninformed) opinion is not needed :-) |
futureverse/future#25 is now resolved. Does this affect this issue? |
That's good news. I will let you know once I have a chance to try it. |
|
(Sorry if this has already been addressed. I looked for an answer in the issues and documentation, but couldn't find anything.)
For long-running targets, it would be nice to be able to look for diagnostic messages/progress bars in the
stderr
stream in real time. Currently,drake::make
withholds allstderr
output until a target is built and then prints it out all at once, which is useful for parallel workflows, but not ideal for sequential, interactive workflows.For example:
It would be nice to see the
Going...
andStill going...
messages as targeta
is being built, and especially nice to see the progress bar as targetb
is being built.It's worth noting that
print
statements and base R'stxtProgressBar
both work as expected because they usestdout
. Onlystderr
is being redirected.The text was updated successfully, but these errors were encountered: