Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate with rstudio projects template feature? #41

Closed
benmarwick opened this issue Sep 13, 2017 · 4 comments
Closed

integrate with rstudio projects template feature? #41

benmarwick opened this issue Sep 13, 2017 · 4 comments

Comments

@benmarwick
Copy link
Owner

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

@mrecos
Copy link

mrecos commented Sep 14, 2017

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
Copy link

mrecos commented Sep 15, 2017

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.

@benmarwick
Copy link
Owner Author

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
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants