ropensci / jagstargets

Reproducible Bayesian data analysis pipelines with targets and JAGS
https://docs.ropensci.org/jagstargets
Other
10 stars 6 forks source link

Allow package to build if JAGS is not installed via lazy-loading #22

Closed jeroen closed 3 years ago

jeroen commented 3 years ago

Prework

Related GitHub issues and pull requests

Summary

This allows the package to be be built and loaded even on servers when JAGS is not installed. By removing the ImportsFrom entry, the rjags / R2jags packages will be lazy-loaded when needed and hence are not required at installation time.

Of course the unit tests / examples will still fail, you would need to condition those to pass CMD check (but for r-universe it is not required to pass check).

wlandau commented 3 years ago

Thanks for the idea, @jeroen. Interesting how that works.

Would I then need to move rjags and R2jags to Suggests: too?

wlandau commented 3 years ago

Actually, sorry, I reverted this one in #24 because I have more questions/concerns.

If rjags and R2jags are still in Imports: in the DESCRIPTION, that seems to mean those packages are still required at install time (at least when I tried it locally just now). But I am a bit uncomfortable moving those packages to Suggests: and asserting them at runtime because these are essential dependencies the user will need to fully utilize jagstargets.

Also, I noticed the pkgdown site still builds and deploys to https://docs.ropensci.org/jagstargets, vignettes and all. Does that part of r-universe have JAGS?

Is there a different way to handle #18?

jeroen commented 3 years ago

You don't need to move those packages to Suggests, better leave them in Imports. It is fine to require rjags and R2jags at install time. The issue only concerns if the external JAGS program needs to be installed.

Packages that are in Imports: and that are loaded in the code via rjags::xyz() and R2jags::xyz() will get lazy loaded, which is usually cleaner than importing everything in your NAMESPACE.