Closed richardrawstronMOH closed 3 years ago
The cronR package does not store the job identifier.
sprintf("job_%s", digest::digest(runif(1)))
as https://github.com/bnosac/cronR/blob/master/R/cron_rstudioaddin.R#L76 which is every time different unless your R startup code sets the seed somewhereThe package does store the 'Rscript repository path' at file.path(system.file("extdata", package="cronR"), ".RscriptRepository.rds")
as you can see in the code at `https://github.com/bnosac/cronR/blob/master/R/cron_rstudioaddin.R#L25 in order not to have to type that path in there every time.
If you have multiple users, just let them install the cronR package again (in their own user folders) instead of having a system-wide cronR package. That will solve your remark as the package will then be loaded from their own folders as it will load cronR from the first location where it finds it in .libPaths()
Thanks for looking at this.
Apologies for incorrectly including the default job identifier. You are correct this is a unique value every time the cronR Addin is opened. It is only the Rscript repository path that is retained.
Unfortunately the solution you propose (allow each user to install their own cronR package) will not work in our environment.
Environment setup
The environment was setup in this manner to provide a more consistent managed environment for the R community in my organisation.
So the short of this is that:
Would you consider changing the cronR package to use the Sys.getenv("HOME") value for the Rscript repository path location? Or making this a configurable option? This would result in a per user entry.
On a related note a workmate is looking through the code with a view to provide a suggestion for you. Thanks
If you have a proposal of code changes, feel free to provide these here or as a pull request. I'm open towards any changes regarding this, either by changing the path of .RscriptRepository.rds
or the default of the Rscript repository path: launch & log location
in the user interface.
Note however that CRAN policy is as follows (https://cran.r-project.org/web/packages/policies.html)
Packages should not write in the user’s home filespace (including clipboards), nor anywhere else on the file system apart from the R session’s temporary directory (or during installation in the location pointed to by TMPDIR: and such usage should be cleaned up). Installing into the system’s R installation (e.g., scripts to its bin directory) is not allowed.
Current implementation also writes in the package extdata folder so this went unnoticed probably due to this code https://github.com/bnosac/cronR/blob/master/R/cron_rstudioaddin.R#L26
Either way, feel free to provide solutions.
Thanks for being open to changes and for pointing out the CRAN policy. I was unaware of that but it clarifies why cronR behaves as it does. With that in mind it's less immediately clear what a good solution would be.
I'll lean on my workmate and see what we can do.
I see the following 2 options:
cron_rstudioaddin <- function(RscriptRepository = Sys.getenv("CRON_LIVE", unset = getwd())) {
Hi,
I work with Richard who has raised the request above.
I tried call the cronR add-in from the command line like so which defaulted to my current working directory.
cronR::cron_rstudioaddin(getwd())
So if proposed option 2 works similar to that above to default to the current working directory this would be perfect for us. If we have any users who wish to default their location, they could always set the by CRON_LIVE environment variable else it will default to the current working directory. If this is how the proposed change will work it will be great.
Thanks Steve
If you can prepare a request, I'll review it.
This PR removes the reliance on extdata completely -- I wasn't sure if that's what you were suggesting. Thanks for your time to review it. #40
In RStudio Server the the cronR Addin can be used to schedule a task. When scheduling a task it appears the following values are retained from previous scheduling actions.
Steps to Reproduce:
This was raised with RStudio support who advised the issue is with the cronR package. _When we run this for the first time in a new session in a local RStudio Server Pro environment, we see the following output: The image shows that the function starts a shiny app for the cronR UI, and does not use the RStudio Server Pro IDE UI.
One thing to note is that value in the launch, and log location seems to be stored somewhere. From the following screenshot, you can see the path loaded after starting a completely new session:
The value above is one we updated in an old session. Somewhere the cronR package is storing this information. And we believe the package maintainers will have a better idea as to where the value is cached._
Environment RStudio Server Pro Version 1.4.1106-5 Red Hat Enterprise Linux 8 cronR 0.4.2