quiet namespace load is noisy

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

quiet namespace load is noisy

Lenth, Russell V
Dear R-devel,

Consider the following clip (in R version 3.6.0, Windows):

    > requireNamespace("ggplot2", quietly = TRUE)
    Registered S3 methods overwritten by 'ggplot2':
      method         from
      [.quosures     rlang
      c.quosures     rlang
      print.quosures rlang

It seems to me that if one specifies 'quietly = TRUE', then messages about S3 method overrides should be quieted along with everything else. After all, other package startup messages ARE suppressed, and even error messages are suppressed:

    > requireNamespace("xyz", quietly = TRUE)
    > ## (it is silent even though there is no "xyz" package)

Thanks

Russ Lenth
U of Iowa

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: quiet namespace load is noisy

Lionel Henry
Hello,

I think `quietly` should only silence normal masking messages
intended for users and providing information about normal
behaviour, such as masking.  This is not the case here as the
message is about overriding of S3 methods, which has global
effect and is rather problematic. It may change behaviour of
package and script code in unpredictable ways.

This is not something that the user can act upon, the developers
of the parties involved need to be contacted by users so they can
fix it (the developers of the conflicting methods might not be
aware if the generic is from a third party package, such as
base::print()). In the case of ggplot2 vs rlang, you can update
ggplot2 to the latest version to fix these messages.

> After all, other package startup messages ARE suppressed, and
> even error messages are suppressed

Note that `quietly = TRUE` does not really suppress error
messages for missing packages. The errors are converted to a
boolean return value, and thus become normal behaviour, for which
it makes sense to suppress the message. This does not imply the
S3 overriding message should be suppressed as well.

Best,
Lionel


> On 23 Jul 2019, at 06:29, Lenth, Russell V <[hidden email]> wrote:
>
> Dear R-devel,
>
> Consider the following clip (in R version 3.6.0, Windows):
>
>> requireNamespace("ggplot2", quietly = TRUE)
>    Registered S3 methods overwritten by 'ggplot2':
>      method         from
>      [.quosures     rlang
>      c.quosures     rlang
>      print.quosures rlang
>
> It seems to me that if one specifies 'quietly = TRUE', then messages about S3 method overrides should be quieted along with everything else. After all, other package startup messages ARE suppressed, and even error messages are suppressed:
>
>> requireNamespace("xyz", quietly = TRUE)
>> ## (it is silent even though there is no "xyz" package)
>
> Thanks
>
> Russ Lenth
> U of Iowa
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [External] Re: quiet namespace load is noisy

Lenth, Russell V
Lionel,

Thanks for your response. I understand that method overriding can be a serious issue, but as you say, this is not something that the user can act upon. Yet the message lands at the user’s feet.

In my case, the messages are cluttering my package vignettes, and may or may not represent what users see if they themselves run the vignette code, depending on what version of ggplot2, etc. they have. I will certainly update my ggplot2 installation and that will help. But basically I don’t ever want these kinds of messages to appear in my vignettes, so I will seek some other workaround.

Russ

Sent from my iPhone

> On Jul 23, 2019, at 1:32 AM, Lionel Henry <[hidden email]> wrote:
>
> Hello,
>
> I think `quietly` should only silence normal masking messages
> intended for users and providing information about normal
> behaviour, such as masking.  This is not the case here as the
> message is about overriding of S3 methods, which has global
> effect and is rather problematic. It may change behaviour of
> package and script code in unpredictable ways.
>
> This is not something that the user can act upon, the developers
> of the parties involved need to be contacted by users so they can
> fix it (the developers of the conflicting methods might not be
> aware if the generic is from a third party package, such as
> base::print()). In the case of ggplot2 vs rlang, you can update
> ggplot2 to the latest version to fix these messages.
>
>> After all, other package startup messages ARE suppressed, and
>> even error messages are suppressed
>
> Note that `quietly = TRUE` does not really suppress error
> messages for missing packages. The errors are converted to a
> boolean return value, and thus become normal behaviour, for which
> it makes sense to suppress the message. This does not imply the
> S3 overriding message should be suppressed as well.
>
> Best,
> Lionel
>
>
>> On 23 Jul 2019, at 06:29, Lenth, Russell V <[hidden email]> wrote:
>>
>> Dear R-devel,
>>
>> Consider the following clip (in R version 3.6.0, Windows):
>>
>>> requireNamespace("ggplot2", quietly = TRUE)
>>   Registered S3 methods overwritten by 'ggplot2':
>>     method         from
>>     [.quosures     rlang
>>     c.quosures     rlang
>>     print.quosures rlang
>>
>> It seems to me that if one specifies 'quietly = TRUE', then messages about S3 method overrides should be quieted along with everything else. After all, other package startup messages ARE suppressed, and even error messages are suppressed:
>>
>>> requireNamespace("xyz", quietly = TRUE)
>>> ## (it is silent even though there is no "xyz" package)
>>
>> Thanks
>>
>> Russ Lenth
>> U of Iowa
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [External] Re: quiet namespace load is noisy

bbolker

  Does setting message=FALSE in the chunk options of the vignette help?

  Or less preferably, using supressMessages() ?

On 2019-07-23 9:36 a.m., Lenth, Russell V wrote:

> Lionel,
>
> Thanks for your response. I understand that method overriding can be a serious issue, but as you say, this is not something that the user can act upon. Yet the message lands at the user’s feet.
>
> In my case, the messages are cluttering my package vignettes, and may or may not represent what users see if they themselves run the vignette code, depending on what version of ggplot2, etc. they have. I will certainly update my ggplot2 installation and that will help. But basically I don’t ever want these kinds of messages to appear in my vignettes, so I will seek some other workaround.
>
> Russ
>
> Sent from my iPhone
>
>> On Jul 23, 2019, at 1:32 AM, Lionel Henry <[hidden email]> wrote:
>>
>> Hello,
>>
>> I think `quietly` should only silence normal masking messages
>> intended for users and providing information about normal
>> behaviour, such as masking.  This is not the case here as the
>> message is about overriding of S3 methods, which has global
>> effect and is rather problematic. It may change behaviour of
>> package and script code in unpredictable ways.
>>
>> This is not something that the user can act upon, the developers
>> of the parties involved need to be contacted by users so they can
>> fix it (the developers of the conflicting methods might not be
>> aware if the generic is from a third party package, such as
>> base::print()). In the case of ggplot2 vs rlang, you can update
>> ggplot2 to the latest version to fix these messages.
>>
>>> After all, other package startup messages ARE suppressed, and
>>> even error messages are suppressed
>>
>> Note that `quietly = TRUE` does not really suppress error
>> messages for missing packages. The errors are converted to a
>> boolean return value, and thus become normal behaviour, for which
>> it makes sense to suppress the message. This does not imply the
>> S3 overriding message should be suppressed as well.
>>
>> Best,
>> Lionel
>>
>>
>>> On 23 Jul 2019, at 06:29, Lenth, Russell V <[hidden email]> wrote:
>>>
>>> Dear R-devel,
>>>
>>> Consider the following clip (in R version 3.6.0, Windows):
>>>
>>>> requireNamespace("ggplot2", quietly = TRUE)
>>>   Registered S3 methods overwritten by 'ggplot2':
>>>     method         from
>>>     [.quosures     rlang
>>>     c.quosures     rlang
>>>     print.quosures rlang
>>>
>>> It seems to me that if one specifies 'quietly = TRUE', then messages about S3 method overrides should be quieted along with everything else. After all, other package startup messages ARE suppressed, and even error messages are suppressed:
>>>
>>>> requireNamespace("xyz", quietly = TRUE)
>>>> ## (it is silent even though there is no "xyz" package)
>>>
>>> Thanks
>>>
>>> Russ Lenth
>>> U of Iowa
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [External] Re: quiet namespace load is noisy

Henrik Singmann-2
Dear Russ,

I had the same problem in my vignettes and setting both message and warning
to FALSE seems to remove all unwanted output:

```{r message=FALSE, warning=FALSE}
library("afex")
library("ggplot2")
library("cowplot")
theme_set(theme_grey())
```

Result:
https://cran.r-project.org/web/packages/afex/vignettes/afex_plot_introduction.html

Best,
Henrik


Am Di., 23. Juli 2019 um 14:52 Uhr schrieb Ben Bolker <[hidden email]>:

>
>   Does setting message=FALSE in the chunk options of the vignette help?
>
>   Or less preferably, using supressMessages() ?
>
> On 2019-07-23 9:36 a.m., Lenth, Russell V wrote:
> > Lionel,
> >
> > Thanks for your response. I understand that method overriding can be a
> serious issue, but as you say, this is not something that the user can act
> upon. Yet the message lands at the user’s feet.
> >
> > In my case, the messages are cluttering my package vignettes, and may or
> may not represent what users see if they themselves run the vignette code,
> depending on what version of ggplot2, etc. they have. I will certainly
> update my ggplot2 installation and that will help. But basically I don’t
> ever want these kinds of messages to appear in my vignettes, so I will seek
> some other workaround.
> >
> > Russ
> >
> > Sent from my iPhone
> >
> >> On Jul 23, 2019, at 1:32 AM, Lionel Henry <[hidden email]> wrote:
> >>
> >> Hello,
> >>
> >> I think `quietly` should only silence normal masking messages
> >> intended for users and providing information about normal
> >> behaviour, such as masking.  This is not the case here as the
> >> message is about overriding of S3 methods, which has global
> >> effect and is rather problematic. It may change behaviour of
> >> package and script code in unpredictable ways.
> >>
> >> This is not something that the user can act upon, the developers
> >> of the parties involved need to be contacted by users so they can
> >> fix it (the developers of the conflicting methods might not be
> >> aware if the generic is from a third party package, such as
> >> base::print()). In the case of ggplot2 vs rlang, you can update
> >> ggplot2 to the latest version to fix these messages.
> >>
> >>> After all, other package startup messages ARE suppressed, and
> >>> even error messages are suppressed
> >>
> >> Note that `quietly = TRUE` does not really suppress error
> >> messages for missing packages. The errors are converted to a
> >> boolean return value, and thus become normal behaviour, for which
> >> it makes sense to suppress the message. This does not imply the
> >> S3 overriding message should be suppressed as well.
> >>
> >> Best,
> >> Lionel
> >>
> >>
> >>> On 23 Jul 2019, at 06:29, Lenth, Russell V <[hidden email]>
> wrote:
> >>>
> >>> Dear R-devel,
> >>>
> >>> Consider the following clip (in R version 3.6.0, Windows):
> >>>
> >>>> requireNamespace("ggplot2", quietly = TRUE)
> >>>   Registered S3 methods overwritten by 'ggplot2':
> >>>     method         from
> >>>     [.quosures     rlang
> >>>     c.quosures     rlang
> >>>     print.quosures rlang
> >>>
> >>> It seems to me that if one specifies 'quietly = TRUE', then messages
> about S3 method overrides should be quieted along with everything else.
> After all, other package startup messages ARE suppressed, and even error
> messages are suppressed:
> >>>
> >>>> requireNamespace("xyz", quietly = TRUE)
> >>>> ## (it is silent even though there is no "xyz" package)
> >>>
> >>> Thanks
> >>>
> >>> Russ Lenth
> >>> U of Iowa
> >>>
> >>> ______________________________________________
> >>> [hidden email] mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-devel
> >>
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


--
Dr. Henrik Singmann
Assistant Professor, Department of Psychology
University of Warwick, UK
http://singmann.org

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [External] Re: quiet namespace load is noisy

Lenth, Russell V
Ben and Henrik,

My package tends to load other packages ‘ namespaces on an as-needed basis, e.g. ggplot2 when a plotting function is called. I have been thinking I would use suppressMessages() in my code, but it is probably a better idea to instead have a setup chunk in each vignette that loads all the needed namespaces or libraries. That way the package user would see those messages in their own session when they could be relevant.

Thanks

Russ

Sent from my iPhone

On Jul 23, 2019, at 9:28 AM, Henrik Singmann <[hidden email]<mailto:[hidden email]>> wrote:

Dear Russ,

I had the same problem in my vignettes and setting both message and warning to FALSE seems to remove all unwanted output:

```{r message=FALSE, warning=FALSE}
library("afex")
library("ggplot2")
library("cowplot")
theme_set(theme_grey())
```

Result: https://cran.r-project.org/web/packages/afex/vignettes/afex_plot_introduction.html

Best,
Henrik


Am Di., 23. Juli 2019 um 14:52 Uhr schrieb Ben Bolker <[hidden email]<mailto:[hidden email]>>:

  Does setting message=FALSE in the chunk options of the vignette help?

  Or less preferably, using supressMessages() ?

On 2019-07-23 9:36 a.m., Lenth, Russell V wrote:

> Lionel,
>
> Thanks for your response. I understand that method overriding can be a serious issue, but as you say, this is not something that the user can act upon. Yet the message lands at the user’s feet.
>
> In my case, the messages are cluttering my package vignettes, and may or may not represent what users see if they themselves run the vignette code, depending on what version of ggplot2, etc. they have. I will certainly update my ggplot2 installation and that will help. But basically I don’t ever want these kinds of messages to appear in my vignettes, so I will seek some other workaround.
>
> Russ
>
> Sent from my iPhone
>
>> On Jul 23, 2019, at 1:32 AM, Lionel Henry <[hidden email]<mailto:[hidden email]>> wrote:
>>
>> Hello,
>>
>> I think `quietly` should only silence normal masking messages
>> intended for users and providing information about normal
>> behaviour, such as masking.  This is not the case here as the
>> message is about overriding of S3 methods, which has global
>> effect and is rather problematic. It may change behaviour of
>> package and script code in unpredictable ways.
>>
>> This is not something that the user can act upon, the developers
>> of the parties involved need to be contacted by users so they can
>> fix it (the developers of the conflicting methods might not be
>> aware if the generic is from a third party package, such as
>> base::print()). In the case of ggplot2 vs rlang, you can update
>> ggplot2 to the latest version to fix these messages.
>>
>>> After all, other package startup messages ARE suppressed, and
>>> even error messages are suppressed
>>
>> Note that `quietly = TRUE` does not really suppress error
>> messages for missing packages. The errors are converted to a
>> boolean return value, and thus become normal behaviour, for which
>> it makes sense to suppress the message. This does not imply the
>> S3 overriding message should be suppressed as well.
>>
>> Best,
>> Lionel
>>
>>
>>> On 23 Jul 2019, at 06:29, Lenth, Russell V <[hidden email]<mailto:[hidden email]>> wrote:
>>>
>>> Dear R-devel,
>>>
>>> Consider the following clip (in R version 3.6.0, Windows):
>>>
>>>> requireNamespace("ggplot2", quietly = TRUE)
>>>   Registered S3 methods overwritten by 'ggplot2':
>>>     method         from
>>>     [.quosures     rlang
>>>     c.quosures     rlang
>>>     print.quosures rlang
>>>
>>> It seems to me that if one specifies 'quietly = TRUE', then messages about S3 method overrides should be quieted along with everything else. After all, other package startup messages ARE suppressed, and even error messages are suppressed:
>>>
>>>> requireNamespace("xyz", quietly = TRUE)
>>>> ## (it is silent even though there is no "xyz" package)
>>>
>>> Thanks
>>>
>>> Russ Lenth
>>> U of Iowa
>>>
>>> ______________________________________________
>>> [hidden email]<mailto:[hidden email]> mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
> ______________________________________________
> [hidden email]<mailto:[hidden email]> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
[hidden email]<mailto:[hidden email]> mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


--
Dr. Henrik Singmann
Assistant Professor, Department of Psychology
University of Warwick, UK
http://singmann.org

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [External] Re: quiet namespace load is noisy

Yihui Xie-2
In reply to this post by Henrik Singmann-2
I mentioned the same thing a couple of months ago but didn't get a
response: https://stat.ethz.ch/pipermail/r-devel/2019-May/077774.html

In your case of package vignettes, it is easy enough to suppress the
messages via the knitr chunk option message = FALSE. However, I still
wonder if it will be a better idea if requireNamespace(quietly = TRUE)
can suppress such messages, because in the past, we can test if a
package is loadable via

  if (requireNamespace(pkg, quietly = TRUE)) { ... }

And now we have to use suppressMessages() or
suppressPackageStartupMessages() plus quietly = TRUE:

  if (suppressPackageStartupMessages(requireNamespace(pkg, quietly =
TRUE))) { ... }

I'm aware of the fact that if a package has packageStartupMessage() in
its .onLoad(), requireNamespace(quietly = TRUE) won't suppress such
messages, and we still have use suppressPackageStartupMessages(). This
statement in Russ's post was incorrect:

> After all, other package startup messages ARE suppressed

but I feel it is a nice feature request for quietly = TRUE to call
suppressPackageStartupMessages() automatically.

Regards,
Yihui
--
https://yihui.name

On Tue, Jul 23, 2019 at 9:29 AM Henrik Singmann <[hidden email]> wrote:

>
> Dear Russ,
>
> I had the same problem in my vignettes and setting both message and warning
> to FALSE seems to remove all unwanted output:
>
> ```{r message=FALSE, warning=FALSE}
> library("afex")
> library("ggplot2")
> library("cowplot")
> theme_set(theme_grey())
> ```
>
> Result:
> https://cran.r-project.org/web/packages/afex/vignettes/afex_plot_introduction.html
>
> Best,
> Henrik
>
>
> Am Di., 23. Juli 2019 um 14:52 Uhr schrieb Ben Bolker <[hidden email]>:
>
> >
> >   Does setting message=FALSE in the chunk options of the vignette help?
> >
> >   Or less preferably, using supressMessages() ?
> >
> > On 2019-07-23 9:36 a.m., Lenth, Russell V wrote:
> > > Lionel,
> > >
> > > Thanks for your response. I understand that method overriding can be a
> > serious issue, but as you say, this is not something that the user can act
> > upon. Yet the message lands at the user’s feet.
> > >
> > > In my case, the messages are cluttering my package vignettes, and may or
> > may not represent what users see if they themselves run the vignette code,
> > depending on what version of ggplot2, etc. they have. I will certainly
> > update my ggplot2 installation and that will help. But basically I don’t
> > ever want these kinds of messages to appear in my vignettes, so I will seek
> > some other workaround.
> > >
> > > Russ
> > >
> > > Sent from my iPhone
> > >
> > >> On Jul 23, 2019, at 1:32 AM, Lionel Henry <[hidden email]> wrote:
> > >>
> > >> Hello,
> > >>
> > >> I think `quietly` should only silence normal masking messages
> > >> intended for users and providing information about normal
> > >> behaviour, such as masking.  This is not the case here as the
> > >> message is about overriding of S3 methods, which has global
> > >> effect and is rather problematic. It may change behaviour of
> > >> package and script code in unpredictable ways.
> > >>
> > >> This is not something that the user can act upon, the developers
> > >> of the parties involved need to be contacted by users so they can
> > >> fix it (the developers of the conflicting methods might not be
> > >> aware if the generic is from a third party package, such as
> > >> base::print()). In the case of ggplot2 vs rlang, you can update
> > >> ggplot2 to the latest version to fix these messages.
> > >>
> > >>> After all, other package startup messages ARE suppressed, and
> > >>> even error messages are suppressed
> > >>
> > >> Note that `quietly = TRUE` does not really suppress error
> > >> messages for missing packages. The errors are converted to a
> > >> boolean return value, and thus become normal behaviour, for which
> > >> it makes sense to suppress the message. This does not imply the
> > >> S3 overriding message should be suppressed as well.
> > >>
> > >> Best,
> > >> Lionel
> > >>
> > >>
> > >>> On 23 Jul 2019, at 06:29, Lenth, Russell V <[hidden email]>
> > wrote:
> > >>>
> > >>> Dear R-devel,
> > >>>
> > >>> Consider the following clip (in R version 3.6.0, Windows):
> > >>>
> > >>>> requireNamespace("ggplot2", quietly = TRUE)
> > >>>   Registered S3 methods overwritten by 'ggplot2':
> > >>>     method         from
> > >>>     [.quosures     rlang
> > >>>     c.quosures     rlang
> > >>>     print.quosures rlang
> > >>>
> > >>> It seems to me that if one specifies 'quietly = TRUE', then messages
> > about S3 method overrides should be quieted along with everything else.
> > After all, other package startup messages ARE suppressed, and even error
> > messages are suppressed:
> > >>>
> > >>>> requireNamespace("xyz", quietly = TRUE)
> > >>>> ## (it is silent even though there is no "xyz" package)
> > >>>
> > >>> Thanks
> > >>>
> > >>> Russ Lenth
> > >>> U of Iowa
> > >>>
> > >>> ______________________________________________
> > >>> [hidden email] mailing list
> > >>> https://stat.ethz.ch/mailman/listinfo/r-devel
> > >>
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> > >
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
>
> --
> Dr. Henrik Singmann
> Assistant Professor, Department of Psychology
> University of Warwick, UK
> http://singmann.org
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel