posit-dev / positron

Positron, a next-generation data science IDE
Other
2.41k stars 71 forks source link

Python (mostly): Support an environment "template" that can be used to make new workspaces #1529

Open juliasilge opened 11 months ago

juliasilge commented 11 months ago

In our Python OSS sync meeting this week, a new "environment template" idea was suggested. A user could create a environment template (say, a requirements.txt plus Python version) and then use that template to create a new workspace. Someone might have a template for Shiny apps, for ML projects, etc.

If the IDE can be a little pushy about this, it can encourage good practices for Python users. Not adopting these kinds of practices are a major problem for Connect users right now, and they get into big trouble when they try to deploy an app or doc or model.

I think this would mostly apply to Python users (much more than R users who have a happier time using one global set of packages), but there could be an analogous workflow for renv users.

jthomasmock commented 11 months ago

Would the template just be an environment or the full Workspace/Project folder structure/files as well?

If files/folders, I think that having this be extensible would be really cool. IE, folks could build extensions on top of the "Create New Project folder" button in Positron, or perhaps even follow something like "VS Code folder templates": https://github.com/Huuums/vscode-folder-templates but plug it directly into the UI based on my locally created project type from an extension/bundled types. There are also things like "Cookie Cutter Data Science": https://github.com/drivendata/cookiecutter-data-science but are limited to a CLI, and AFAIK doesn't have a VS Code extension.

Being able to define a minimal project structure would be AMAZING, even without having a .proj file, just relying on whatever files/sub-folders the user decides to bring along per their "Workspace definition".

I ran into a kind of related, somewhat awkward scenario around Workspaces/Projects where the Quarto extension allows creating a Project, but doesn't hook into the "New Project Folder" button, so you have to opt-in to using the Quarto Command Palette or CLI, rather than being able to create a Quarto Project directly from the UI. This is also awkward if you create a project first, and then decide to make it into a Quarto Project, the current tooling will create a sub-folder.

https://github.com/posit-dev/positron/assets/29187501/3603c0b6-e477-4d02-8bf3-d9513bcbd66a

juliasilge commented 11 months ago

I have run into that problem (creating a project in a subfolder when that's not what I meant) A LOT across lots of project helper tools, like R packages, bookdown projects, etc etc etc. For me, it happens most often when I create a mostly blank repo on GitHub, pull it down locally, and then try to make it something like an R package or Quarto website or similar. Super awkward.

I mean, clearly it's a lot easier for a tool to make a new folder than to deal with what's already there, but usethis::create_package() is an example of something that does handle an existing path quite well.

juliasilge commented 7 months ago

cc @sharon-wang for longer term plans for "new project" workflows