bnosac / taskscheduleR

Schedule R scripts/processes with the Windows task scheduler.
330 stars 72 forks source link

Version-independent task setup? #68

Closed sysilviakim closed 5 years ago

sysilviakim commented 5 years ago

Hi,

Thank you for setting up a great package. I noticed recently as I was updating my R from a version 3.5.1 to 3.6.0 that the tasks previously set all started to fail, because taskscheduler_create used Sys.getenv("R_HOME") which would contain version numbers, such as

C:/PROGRA~1/R/R-35~1.1

So when there was a new R and new path of C:/PROGRA~1/R/R-36~1.0, it no longer worked.

If R is included in the path, the Rexe argument can simply be substituted as "Rscript" and the task will run just fine. I wrote an if-statement that checks for R in path and then replacing Rexe. I am unsure how to undo the path-shortening for Sys.getenv("R_HOME") (apparently a DOS 8.3 naming convention?) so the grepl part is a little hacky.

I've only tested it on my machine/task, but let me know what you think.

jwijffels commented 5 years ago

Why not just use the Rexe argument to taskscheduler_create? As in taskscheduler_create(..., Rexe = “Rscript”)

sysilviakim commented 5 years ago

Sure---I mean, this is just for those who may be unaware of what is going to happen under the hood or those who may forget to set such arguments, so that at some points these tasks stop running. If you want to input a disclaimer about R version numbers instead, that would also suffice.

jwijffels commented 5 years ago

But your pull request basically always overwrites the Rexe if it is in the path. What happens if someone wants R.3.5.1 but has R.3.2.1 in his path?

sysilviakim commented 5 years ago

Hi,

I guess the function can be modified to read in the path, check for R entries, and output messages about versions that they may be unaware of (or all R versions in path, and that users should specify Rexe otherwise if they desire.)

Again, if you think it is better just to warn users with a message that the function will be using an existing R installation with the version numbers attached (“beware that if you upgrade R, the set tasks will stop” or something similar), that is fine. My impression is that—myself included—people will fail to look under the hood and remember to set Rexe, so thought the default of Rexe could be changed.

Cheers.


From: jwijffels notifications@github.com Sent: Monday, May 13, 2019 12:40 AM To: bnosac/taskscheduleR Cc: Kim, Seo Young (Silvia); Author Subject: Re: [bnosac/taskscheduleR] Version-independent task setup? (#68)

But your pull request basically always overwrites the Rexe if it is in the path. What happens if someone wants R.3.5.1 but has R.3.2.1 in his path?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/bnosac/taskscheduleR/pull/68#issuecomment-491710731, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE3AH7YSXMIXGROEQXTEKXLPVELODANCNFSM4HMJRQPQ.

jwijffels commented 5 years ago

I think it is better to give a message that it will use that specific R version, in case it is different than the R version in the path

sysilviakim commented 5 years ago

Sure. Thanks for the great package. Cheers.


From: jwijffels notifications@github.com Sent: Monday, May 13, 2019 1:48 AM To: bnosac/taskscheduleR Cc: Kim, Seo Young (Silvia); Author Subject: Re: [bnosac/taskscheduleR] Version-independent task setup? (#68)

I think it is better to give a message that it will use that specific R version, in case it is different than the R version in the path

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/bnosac/taskscheduleR/pull/68#issuecomment-491734106, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE3AH77MQLKGHPAM6R3CZYDPVETOXANCNFSM4HMJRQPQ.

jwijffels commented 5 years ago

Also note that the PATH of the R session launching the jobs can be different than the R session creating the jobs. This is not handled by this pull request. I'll close it.