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

Resources on dependencies limitations #71

Open
maelle opened this issue Oct 21, 2022 · 4 comments
Open

Resources on dependencies limitations #71

maelle opened this issue Oct 21, 2022 · 4 comments

Comments

@maelle
Copy link
Member

maelle commented Oct 21, 2022

For info @oggioniale, these might be useful when reducing the number of Imports.

@micha-silver
Copy link
Contributor

micha-silver commented Dec 12, 2022

@oggioniale : I had a look at chapter 12 of Hadley Wickham's book.

  • We should (must) have all R dependency packages listed in the DESCRIPTION file under Imports:. As it is now. This insures that whoever installs ReLTER will also have all the dependencies installed (>200). Installing all dependencies is done, of course, only once when a new user installs ReLTER.

  • On the other hand, the packages listed in NAMESPACE file are actually loaded (attached) every time you load ReLTER. This takes some time and memory. And probably is not necessary for many cases. When we specify a function, i.e. worrms::wm_records_names() with the full package::function() format then the wm_records_names() function is found in the worrms package even if that package is not loaded (attached). And we have been careful from the start to specify all function calls with that full format. So we can remove many (most) of the @import and @importFrom lines from many of the function definitions, and rerun devtools::document() to rewrite the NAMESPACE file. Then all the rarely used packages will not be loaded from the start. This will make startup faster, avoid namespace collisions, and allow the package to use less memory.

@maelle : Any further comments on this??
Thanks

@maelle
Copy link
Member Author

maelle commented Dec 13, 2022

What's the specific question? In any case yes it is better to not import (in the NAMESPACE) a whole package when you use only a few functions of that package.

@micha-silver
Copy link
Contributor

Here's what I see (not sure if this is the correct way to test...)

direct_deps <- remotes::local_package_deps()
length(direct_deps)
[1] 46
all_deps <- renv::dependencies()
Finding R package dependencies ... Done!
length(all_deps$Package)
[1] 401

So we are declaring @import of 46 packages. And these are pulling along (recursively) another 350. And with all the importFrom() lines in NAMESPACE we are actually attaching all these right from the start. Is this a problem?

@maelle
Copy link
Member Author

maelle commented Dec 13, 2022

Yes it is a problem, especially as there is a hard CRAN limit on direct Imports in DESCRIPTION (20 if I remember correctly).

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

No branches or pull requests

2 participants