-
Notifications
You must be signed in to change notification settings - Fork 12
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
Detect registered progress handler #155
Comments
Hello.
No, I don't think that's possible. To generalize your question, what you're after is a way to see if it's possible to detect, from withCallingHandlers({
foo()
}, some_handler = function(cond) {
...
}) I don't think that's possible in R, but I'm not 100% sure. If you could, please reach out on R-devel and ask about this - it could be an interesting feature to have in R. In progressr, I could of course have
What are you really trying to achieve here? Note, even if you could know that there are progression handlers actively "listening", you would not know how they report on the progress. For example, |
Thanks, that solves my problem assuming everyone uses the global option (which may not be a reasonable assumption).
I'll try to see if I can make that happen.
I think that would be very useful for my use case, see below.
Short story: I want to set different default behavior in a function depending on whether progress handler is enabled or not. Long story: My use case is a function that splits a potentially memory hungry task into smaller subtasks which are handled separately, and progress is reported for every completed subtask via With smaller dimensional data input to the function, memory consumption is not an issue, but the computation time still increases. These cases can be identified based on the input. In these cases, the only reason for doing the splitting is if the user wants to display the computation progress. If the user has not registered a progress handler, it would be preferable to not split the tasks to save some computation time. So, if I could detect whether the user has enabled progress reporting (of any kind), I can set the default behavior to do task splitting when it is enabled, and disable the task splitting if progress reporting is not enabled by the user. |
I strongly recommend against this. The user might have enabled the global progress handler for other reasons that are unrelated to your package and your function. It's important to always remember that our packages and functions can be used in contexts that we as developers cannot predict or know why and when. Some developers use similar things like |
I highly value your recommendations on this. If a progress handler is enabled, the 'visual behavior' of the call to The behavior of other functions, packages and global parameters are not changed depending on whether the package with the function It would be very helpful if you could elaborate on your view related to this. |
Hi
Say I have a function
foo()
which contains code displaying a progress bar withprogressr
.Is there a simple way to detect whether either a global handler is registered in the current session, or whether
foo()
is wrapped withinwith_progress
such that foo() will display a progress bar in my console?Thanks!
The text was updated successfully, but these errors were encountered: