rrtools icon indicating copy to clipboard operation
rrtools copied to clipboard

integrate with rstudio projects template feature?

Open benmarwick opened this issue 6 years ago • 4 comments

Following Matt's suggestion, consider this: https://rstudio.github.io/rstudio-extensions/rstudio_project_templates.html

benmarwick avatar Sep 13 '17 19:09 benmarwick

I think this is a really cool idea and is compatible with the rrtools package philosophy. I tested this out a bit and while successful in creating a template and launching a new rrtools package, ran into the obvious hurdle. The way in which rrtools starts a new RStudio session after use_compendium() breaks the function sequence. Briefly, here are the ways that I came up with to approach this (by no means the only ways):

  1. have project template call an init function that calls use_compendium() and subsequent functions based on selections in UI.
  2. have the template call an init function that calls a modified use_compendium() that includes calls to subsequent functions based on parameters passed to it from the UI
  3. create a new function that executes on load once the new package is re-opened in RStudio. It will execute subsequent setup functions based on parameters read from a file passed in from the UI

So how is that working out?

  1. Not good. Once use_compendium() is called, any subsequent function calls in the init functions error.
  2. Pretty much the same as above. Perhaps some more room to work with this approach, but it suffers from trying to call functions on a workspace that is not yet open. Will have to think about it more.
  3. Have not tried it and don't know how to run functions on project open, but there may be a way? that function would then readline the attributes from the init function and run subsequent setup function (e.g. use_travis()) to create the project as selected in the UI.

So there is room to work here and I will keep at it.

mrecos avatar Sep 14 '17 02:09 mrecos

Great progress thanks to the answers here: (I went with option 3 from above, but others are still possible) https://community.rstudio.com/t/project-templates-and-rprofile/82

I have it working successfully to open the project template UI, select some options, the init script then digests the UI options and writes two file 1) ProjectTemplate a simple record of all the options passed from the UI, 2) a .Rprofile file that executes the subsequent rrtools functions and then renames itself to archive the setup script without interfering with operations later on. TO DO now is to get all the options in the UI and right the logic to test/check them. issues:

  • there is no pop-ups or validation features in the project template UI; it works or it doesn't.
  • the prompts to ok file overwrites from rrtools could get in the way
  • this will not handle complex or highly customized rrtools setups.

mrecos avatar Sep 15 '17 01:09 mrecos

Thanks for these updates, this is great. Seems like RStudio 1.1 isn't quite ready for me, as I encounter a few problems when trying this template:

rr1

rr2

rr5

Some problem when creating from the template:

rr7

Click OK and get another problem:

rr8

Try opening the project from the .RProj file that was created:

rr9

I guess I need to wait for RStudio 1.1 to be more mature before I can enjoy this.

benmarwick avatar Sep 19 '17 18:09 benmarwick

@mrecos it might be that RStudio is more robust with pkg templates now, would you like to see this can work now? Thank you!

benmarwick avatar Mar 19 '20 18:03 benmarwick