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

Suggestion of new function: get_dep_version() #793

Closed
rempsyc opened this issue Aug 5, 2023 · 5 comments · Fixed by #795
Closed

Suggestion of new function: get_dep_version() #793

rempsyc opened this issue Aug 5, 2023 · 5 comments · Fixed by #795
Labels
Feature idea 🔥 New feature or request

Comments

@rempsyc
Copy link
Sponsor Member

rempsyc commented Aug 5, 2023

Context

insight::check_if_installed() is a great alternative to rlang::is_installed().

During the review of my rempsyc paper at JOSS, it was pointed out that for suggested packages, the wrong package versions were checked. I assumed these functions were smart enough to check the DESCRIPTION document for the correct version, but this is not the case. So we need to specify the minimal version manually using the minimum_version or version arguments.

Problem and Solution

This is suboptimal because it creates additional maintenance: we have to update the version numbers not only in the DESCRIPTION file but also in every function that depends on those suggested packages (crazy I know!).

For this purpose, I created a function, get_dep_version(), that automatically detects the minimal version of a given package from the DESCRIPTION file.

Reprex:

rempsyc::get_dep_version(dep = "rstanarm", pkg = "insight")
#> [1] "2.21.1"

rempsyc::get_dep_version(dep = "see", pkg = "modelbased")
#> [1] "0.7.4"

Created on 2023-08-05 with reprex v2.0.2

This is useful because it can be directly integrated with insight::check_if_installed():

insight::check_if_installed("see", minimum_version = rempsyc::get_dep_version(
  dep = "see", pkg = "modelbased"))
#> Error: Package `see` is installed, but package version `0.7.4` is required.
#>   Please update it by running `install.packages(`see`)`.

Created on 2023-08-05 with reprex v2.0.2

In fact, this could be the default, should we want it. This would allow us to reduce maintenance in all easystats packages by changing the required version number only once: where it belongs in the DESCRIPTION file. Furthermore, making this the default in insight::check_if_installed() would show a CLEAR benefit of insight::check_if_installed() over rlang::is_installed().


Would you like this function to migrate from rempsyc to insight?

@rempsyc rempsyc added the Feature idea 🔥 New feature or request label Aug 5, 2023
@bwiernik
Copy link
Contributor

bwiernik commented Aug 6, 2023

This would be great, but maybe we don't need a separate exported function? Do folks need to check dep version outside of this case? Maybe just add the min version check internally to check_if_installed()?

@vincentarelbundock
Copy link
Contributor

Yes, this sounds like a cool feature. I agree with Brenton that this should be added as a feature to check_if_installed() (a new argument?) rather than a new function.

@rempsyc
Copy link
Sponsor Member Author

rempsyc commented Aug 6, 2023

Great, thanks! I'll submit a PR with the modified check_if_installed()!

@strengejacke
Copy link
Member

Is it possible to avoid naming the package from where the function is called? Cf rempsyc::get_dep_version(dep = "rstanarm", pkg = "insight"), where we need to specify "insight".

@rempsyc
Copy link
Sponsor Member Author

rempsyc commented Aug 6, 2023

Yes @strengejacke, in #795 this is now automatic :)

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

Successfully merging a pull request may close this issue.

4 participants