Discussion:
Progress package
Pierre de Villemereuil
2018-11-02 20:26:57 UTC
Permalink
Hi,

Is there any reason why the "progress" package doesn't display progress bars in RKWard?

E.g. this code:

library(progress)

pb <- progress_bar$new(total = 100)
f <- function() {
pb$tick(0)
Sys.sleep(3)
for (i in 1:100) {
pb$tick()
Sys.sleep(1 / 100)
}
}
f()

should display a progress bar (which then disappears in R console), but doesn't. I've also tried for (my initial) slower code and still nothing appear while the progress bar is there for the ~40 minutes of computation in R console.

Anything I need to do to make RKWard work nicely with "progress"? Would be sad that a GUI cannot display a progress bar where the CLI can! ;)

Cheers,
Pierre.
Thomas Friedrichsmeier
2018-11-02 21:55:24 UTC
Permalink
Hi,

On Fri, 02 Nov 2018 21:26:57 +0100
Post by Pierre de Villemereuil
Is there any reason why the "progress" package doesn't display
progress bars in RKWard?
I have not quite figured out the details, but essentially: It doesn't
want to display the bar, because it thinks it's not supported, for
some reason.
Post by Pierre de Villemereuil
Anything I need to do to make RKWard work nicely with "progress"?
Would be sad that a GUI cannot display a progress bar where the CLI
can! ;)
Try
pb <- progress_bar$new(total = 100, force=TRUE)
# ...
f ()

This may be something to raise with the maintainers of progress.
Although, again, I have not fully understood the details of _why_ the
package believes it cannot display a progress bar in RKWard, yet.

Regards
Thomas
meik michalke
2018-11-02 22:42:40 UTC
Permalink
hi,
Post by Thomas Friedrichsmeier
On Fri, 02 Nov 2018 21:26:57 +0100
Post by Pierre de Villemereuil
Is there any reason why the "progress" package doesn't display progress bars in RKWard?
I have not quite figured out the details, but essentially: It doesn't
want to display the bar, because it thinks it's not supported, for
some reason.
without looking at any of the code of the package, the precise list of
applications where the package will run to me reads like it needed special
implementation to reach that goal. so it probably checks its environment to
decide which implementation to use, and doesn't find one for RKWard.

just a hunch.
Post by Thomas Friedrichsmeier
Post by Pierre de Villemereuil
Anything I need to do to make RKWard work nicely with "progress"?
Would be sad that a GUI cannot display a progress bar where the CLI
can! ;)
FWIW, it's not that RKWard is incapable of showing progress bars --
utils::txtProgressBar() works well[*]. the progress package seems to demand
some special treatment. if my hunch goes in the right direction, it's probably
something the package authors need to fix, not us.


viele grüße :: m.eik


[*] @thomas: we could actually capture that and replace it by a GUI progress
bar instead of the R console, couldn't we?
--
dipl. psych. meik michalke
institut f"ur experimentelle psychologie
abt. f"ur diagnostik und differentielle psychologie
heinrich-heine-universit"at d-40204 d"usseldorf
Pierre de Villemereuil
2018-11-03 07:31:05 UTC
Permalink
Hi,

Thanks for your input. I'll report that to the maintainer of "progress" and see what gives.

Cheers,
Pierre.
Post by meik michalke
hi,
Post by Thomas Friedrichsmeier
On Fri, 02 Nov 2018 21:26:57 +0100
Post by Pierre de Villemereuil
Is there any reason why the "progress" package doesn't display
progress bars in RKWard?
I have not quite figured out the details, but essentially: It doesn't
want to display the bar, because it thinks it's not supported, for
some reason.
without looking at any of the code of the package, the precise list of
applications where the package will run to me reads like it needed special
implementation to reach that goal. so it probably checks its environment to
decide which implementation to use, and doesn't find one for RKWard.
just a hunch.
Post by Thomas Friedrichsmeier
Post by Pierre de Villemereuil
Anything I need to do to make RKWard work nicely with "progress"?
Would be sad that a GUI cannot display a progress bar where the CLI
can! ;)
FWIW, it's not that RKWard is incapable of showing progress bars --
utils::txtProgressBar() works well[*]. the progress package seems to demand
some special treatment. if my hunch goes in the right direction, it's probably
something the package authors need to fix, not us.
viele grüße :: m.eik
bar instead of the R console, couldn't we?
Thomas Friedrichsmeier
2018-11-03 08:07:39 UTC
Permalink
Hi,

On Fri, 02 Nov 2018 23:42:40 +0100
Post by meik michalke
without looking at any of the code of the package, the precise list
of applications where the package will run to me reads like it needed
special implementation to reach that goal. so it probably checks its
environment to decide which implementation to use, and doesn't find
one for RKWard.
well, the really annoying thing is that it does _not_ need any special
implementation. Use it with force=TRUE, and it works just fine in
RKWard. But without force, it simply gives up without even trying.

Regards
Thomas
Pierre de Villemereuil
2018-11-03 08:49:38 UTC
Permalink
Yes, Thomas you are right. I see it correctly when using force = TRUE.

I've submitted a bug report there:
https://github.com/r-lib/progress/issues/74

I'm going to mention this.

Cheers,
Pierre.
Post by Thomas Friedrichsmeier
Hi,
On Fri, 02 Nov 2018 23:42:40 +0100
Post by meik michalke
without looking at any of the code of the package, the precise list
of applications where the package will run to me reads like it needed
special implementation to reach that goal. so it probably checks its
environment to decide which implementation to use, and doesn't find
one for RKWard.
well, the really annoying thing is that it does _not_ need any special
implementation. Use it with force=TRUE, and it works just fine in
RKWard. But without force, it simply gives up without even trying.
Regards
Thomas
Pierre de Villemereuil
2018-11-03 12:04:44 UTC
Permalink
The dev is asking whether there is a way to detect RKWard. Is there?

If so, I might be able to submit a PR to "progress". At least, I'll try...

Cheers,
Pierre.
Post by Pierre de Villemereuil
Yes, Thomas you are right. I see it correctly when using force = TRUE.
https://github.com/r-lib/progress/issues/74
I'm going to mention this.
Cheers,
Pierre.
Post by Thomas Friedrichsmeier
Hi,
On Fri, 02 Nov 2018 23:42:40 +0100
Post by meik michalke
without looking at any of the code of the package, the precise list
of applications where the package will run to me reads like it needed
special implementation to reach that goal. so it probably checks its
environment to decide which implementation to use, and doesn't find
one for RKWard.
well, the really annoying thing is that it does _not_ need any special
implementation. Use it with force=TRUE, and it works just fine in
RKWard. But without force, it simply gives up without even trying.
Regards
Thomas
meik michalke
2018-11-03 12:43:18 UTC
Permalink
Post by Pierre de Villemereuil
The dev is asking whether there is a way to detect RKWard. Is there?
how about this:

"rkward" %in% (.packages())

RKWard loads its own R package which is also not available without RKWard, so
when an R package called "rkward" is currently loaded, you can assume the
session is running in RKWard.
Post by Pierre de Villemereuil
If so, I might be able to submit a PR to "progress". At least, I'll try...
+1


viele grüße :: m.eik
--
dipl. psych. meik michalke
institut f"ur experimentelle psychologie
abt. f"ur diagnostik und differentielle psychologie
heinrich-heine-universit"at d-40204 d"usseldorf
Pierre de Villemereuil
2018-11-03 13:04:01 UTC
Permalink
It seems to work indeed. I'll try to implement something for progress based on this... when I have the time! ;)

Cheers,
Pierre
Post by meik michalke
Post by Pierre de Villemereuil
The dev is asking whether there is a way to detect RKWard. Is there?
"rkward" %in% (.packages())
RKWard loads its own R package which is also not available without RKWard, so
when an R package called "rkward" is currently loaded, you can assume the
session is running in RKWard.
Post by Pierre de Villemereuil
If so, I might be able to submit a PR to "progress". At least, I'll try...
+1
viele grüße :: m.eik
Thomas Friedrichsmeier
2018-11-03 16:48:43 UTC
Permalink
Hi,

On Sat, 03 Nov 2018 13:04:44 +0100
Post by Pierre de Villemereuil
The dev is asking whether there is a way to detect RKWard. Is there?
well, as far as I can see, the function in question is
progress:::is_supported. That checks if the output stream isatty().
(Not sure, whether this even works on Windows, but so what).

Perhaps a better check would be something like:

(is_stdout(stream) || is_stderr(stream)) && interactive()

Untested, but might work without adding a special case for every single
GUI out there.

(I suppose the main intention of the check is to avoid writing progress
bars to a file. But in that case, R is either not interactive() -
esp. when there is a shell-redirection - or a sink() is in place.
progress:::is_stdout() seems to check for the latter, already).

Regards
Thomas

Loading...