Skip to content
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

adding attached parameter to session_info() and package_info() #42

Closed
engineerchange opened this issue Jan 23, 2021 · 5 comments
Closed
Labels
feature a feature request or enhancement

Comments

@engineerchange
Copy link

engineerchange commented Jan 23, 2021

Thank you for creating and maintaining such a useful package!

I think there is some use case to return the session_info() and package_info() for the attached packages only. Example here: https://www.tidymodels.org/learn/work/bayes-opt/

A parameter that allows for this would save some trimming on the user's side.

@gaborcsardi
Copy link
Member

You can filter the data frame that is returned, it has an attached column:

pi <- sessioninfo::package_info()
❯ subset(pi, attached)
 package * version    date       lib source
 cli     * 2.2.0.9000 2021-01-21 [1] local
 crayon  * 1.3.4.9000 2020-12-29 [1] local

[1] /Users/gaborcsardi/Library/R/4.0/library
[2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

If you want the complete session info, session_info() returns a list of platform and packages, and you can filter packages the same way.

@engineerchange
Copy link
Author

Thank you for getting back so quickly! I did look through the code yesterday, and I saw that packages was returned as a data.frame.

I guess the utility I see is being able to do:

> sessioninfo::session_info(attached=TRUE)

versus

> sessioninfo::platform_info()
> pi <- sessioninfo::package_info()
> subset(pi,attached)

The former is more elegant, and much easier to debug remotely what others got going on in their session with a single command versus three; it also has the output in a more compact form.


I took a stab at a PR, but apparently it's a bit more than just editing as:
package-info.R

package_info <- function(pkgs = NULL, include_base = FALSE, attached = FALSE,
                         dependencies = NA)

and

  if (attached) pkgs <- pkgs[pkgs$attached, ]

and additionally,
session-info.R

packages = package_info(pkgs, include_base = include_base, attached = attached)

The way dependencies are handled was a bit confusing for me, as I couldn't get the above to work locally, as expected.

@gaborcsardi
Copy link
Member

I am reluctant to add this, because it does not seem like a feature that is often needed (in fact, I don't really understand why you would want an incomplete session info in the first place), and because it (obviously) complicates the code base.

@gaborcsardi gaborcsardi added enhancement feature a feature request or enhancement and removed enhancement labels Jan 24, 2021
@gaborcsardi
Copy link
Member

OK, I'll think about this, maybe we could make the pkgs argument magical. FWIW to determine the attached packages, one needs to parse search().

@gaborcsardi
Copy link
Member

You can now write

session_info("!attached")

to list the attached packages only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants