Transform Ben's "library" - code into R-package.
Closed this issue ยท 8 comments
- Release to CRAN not without consent from BL and he still wants to make some changes
- alternative 1: private github -> install via devtools with github token via devtools::install_github("user/repo", ref = "main", auth_token = Sys.getenv("GITHUBTOKEN"))
- alternative 2: upload compressed package in this github project and install via download and install.packages("path/to/compressed/file", source = TRUE, repos=NULL)
- if package construction was successful it should be possible to include R package with library(csmTools) in R
Yes, I guess CRAN package wasn't intended anyway.
But that we have UC only in a private repo is super annoying, in particular since we want to cooperate with other measures / TAs. Not sure whether you got a "no" from Ben regarding making his repo public. Discussing this and making the UC-repo public is different issue (#6). @patrick-koenig
Whether alternative 1 or 2 is more practical, should be decided by you and @JensKrumsieck.
I did not think about putting it to CRAN. That's a thing benjamin can do if he likes. We just enable him to do so with this issue.
Furthermore i think alternative 1 is the way to go, he/we is/are doing this already with the crop calendars package in the Dockerfile.
This needs to be possible with csmTools so you can use its modules without loading the contents of the source files.
side note: does anyone know why the line's contents aren't rendered like here https://github.com/fairagro/m4.4_UC6_cwl_test_1?tab=readme-ov-file#24062024-1700-jk ???
It would be great to have a repository for this if we get his permission and find out what license he prefers (maybe he would also like to make some changes first).
Overall, Benjamin has built his project using the recommended package structure and is already using roxygen2 comments, which is great. I'm not sure if he wants to export all of his functions, that could be a default option. I have made some minor changes to a few imports and commented out a function call in get_soil_data.R.
There are still some warnings and notes that I need to resolve before it should be available anywhere, but I think I can install the package csmTools locally on my system with install.packages("path/to/compressed/package", source = TRUE, repos=NULL).
For a github repo you would have to execute use_github and use_read_me_rmd with devtools, but it shouldn't be that complicated (I could test it for a private repo?). Then it would be possible to use it like cropCalendars (if it is public). It would maybe make sense to add tests for the functions at some point
As far as i can see his repo is public now: https://github.com/fairagro/uc6_csmTools ๐
I created a new branch in BLs Repo called feature/package_management
to add proper package management tooling, namely renv
. This turned out crucial for reproducibility, as the rdwd
package is not pushed to CRAN for patchlevel updates but updates it's data nonetheless. That bug got me for a few hour which was just because of CRAN not installing the latest package. Furthermore DSSATs R packages does not work in the latest version because of writing not working WTH files...
Installation can not be done by renv::restore()
after clone or pull. --> #13
I did some fixing of functions that were not exported, the @importFrom
annotations and rerun roxygen2::roxygenise()
to rebuild the package data.
The package is now installable using remote::install_local(".")
or from github using the specified branch and passes all required checks (devtools::check()
). --> #14
For the sake of reproducibility i added an optional devcontainer
file which installs all requirements on container creation and compiles the DSSAT program. Turned out you have to also clone the data repository for DSSAT to work. This can be done using install_dssat.sh
. Data explicitly needs to be in the same directory as the dssat executable and the path length is not allowed to surpass 80 characters (LOL!).
For the system requirements there is also a install_requirements.sh
- i dont know how this is handled in R usually but i think on linux all R packages come without their system requirements!?
--> #15, #16
The sample pipeline now works in a well defined environment with the limitation of the DSSAT paths still being hardcoded.
Warning
A thing that cost me hours is that the pipeline does not work with the current HEAD of DSSAT, i used the version BL used instead, which seems to work.
Furthermore i updated the README with installation notes. A full comparison can be viewed here: fairagro/uc6_csmTools@main...feature/package_management
However BLs script still produces a whole ot of warnings^^
The Script runs multiple minutes (most time consumed for downloading from dwd) which makes the use of workflows, which you can restart e.g. with different paramerters at a specific points quite a good solution.
Docker container added in fairagro/uc6_csmTools@bea7f7c (#16 )
CI based integration test now runs in BLs Repo (#10)
#10 (comment)