-
Notifications
You must be signed in to change notification settings - Fork 93
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
Create new Venv for Python-based Project #3289
Conversation
Conda is not yet supported, so don't allow it as a python env provider when creating the new project.
Next: start the runtime in the Venv
src/vs/workbench/services/positronNewProject/common/positronNewProjectService.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo a couple of questions.
this._contextService.getWorkspace().folders[0]; | ||
if (!workspaceFolder) { | ||
this._logService.error( | ||
'Could not determine workspace folder for new project. Cannot create Python environment.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an error occurs that prevents us from creating the project's Python environment, I think we should show it to the user in a warning-level toast, instead of (or in addition to) logging it here, along with whatever context we can gather. Same with the errors below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -220,8 +220,11 @@ export class PythonRuntimeManager implements IPythonRuntimeManager { | |||
throw new Error(`Python interpreter path is missing: ${extraData.pythonPath}`); | |||
} | |||
|
|||
// Replace the metadata if we can find the runtime in the registered runtimes, | |||
const registeredMetadata = this.registeredPythonRuntimes.get(extraData.pythonPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this rely on discovery happening before we validate? (seems like it might be necessary for us to hydrate the full metadata from the path to avoid this but maybe I'm missing something)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we won't have done discovery yet, but since we call validateMetadata
in doAutoStartRuntime
, we'll receive the full metadata at that point.
The full metadata will be registered (in the extension and in positron) upon the creation of the Venv through the python extension. We won't have the runtime manager info in positron, but positron will ask for the manager via the extension host proxy.
I think this means we won't need to rely on discover to occur first!
I added a commit to log when we hydrate the metadata in runtimeSession.ts doAutoStartRuntime()
Env tasks can take a while, but creating the blank files is quick. This way, the blank files are interact-able while the env is set up in the background.
A note from Wasim to double-check the new Venv interpreter startup behaviour here, once #3298 is resolved. The changes there will auto-start the newly created Venv interpreter, which may result in some weirdness when we try to start the affiliated runtime here. I'll rebase this PR once the new project git init PR is merged, then merge this if no further comments! |
47baee1
to
f0774e0
Compare
Intent
Demo
new_venv_project.mp4
Approach
python extension
interpreterPath
to theCreateEnvironmentOptionsInternal
options so we can skip user input via quickpick, as we'll already have the interpreterPath for a global python installationVenvCreationProvider.createEnvironment()
to useinterpreterPath
if providedvalidateMetadata
to return a corresponding registered runtimeMetadata based on thepythonPath
-- this allows us to pass in a runtimeMetadata object which only contains apythonPath
and receive an actual filled-out runtimeMetadata objectnew project service
ipykernel
in the created environmentproject wizard dialog
pythonEnvProviderName
to omit Conda envs from the project config, since we don't currently support Conda (support will be added via Project Wizard: Python project environment step - Conda #2839)ipykernel
for existing interpreters, since new environments will be handled by the new project serviceQA Notes
Suggested steps
Expected outputs
.venv
directory should be created after a few moments, withipykernel
installed