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

Expose a unified way to retrieve Python Env Associated with Jupyter Notebooks #15987

Open
DonJayamanne opened this issue Sep 3, 2024 · 0 comments
Assignees
Labels
api-proposal debt Code quality issues

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Sep 3, 2024

Currently there's a private API that Pylance gets to use in order to determine the Python Env associated with Jupyter notebooks.
Unfortunately there are a few problems with this API:

  • Its built specifically for Pylance, other extensions cannot get this same information
  • Upon selecting a new Kernel, the Pylance extension won't always know that a new Python Env has been selected for a Jupyter Notebook
  • The API is inconsistent, currently there's an API in Python extension to get the Python Env associated with a Uri, but Jupyter Notebooks is not part of this (when Jupyter Notebooks are also just Uris).

Pros:

  • Unified approach to getting Python Environments for notebooks, Python files, workspaces etc.
  • No code change for extensions consuming the Python API
  • Resolves some bugs as well

Solution:

  • Keep the Python extension + Jupyter Extension API internal (as today)
  • Update the Python extension as follows:
export type ActiveEnvironmentPathChangeEvent = EnvironmentPath & {
    /**
     * Workspace folder the environment changed for.
     * Or Resource the environment changed for.
     */
    readonly resource: WorkspaceFolder | Uri | undefined;
};

Internally, the call to getActiveEnvironmentPath(resource?: Resource): EnvironmentPath; would now handle Uris a little differently. If the Uri is a notebook Uri, then get the interpreter from Jupyter extension (using existing code).
The check if the Uri is a notebook can optionally be passed into Jupyter as well, i.e. keep it super simple.

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug and removed bug Issue identified by VS Code Team member as probable bug labels Sep 3, 2024
@DonJayamanne DonJayamanne added debt Code quality issues feature-request Request for new features or functionality api-proposal and removed feature-request Request for new features or functionality labels Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-proposal debt Code quality issues
Projects
None yet
Development

No branches or pull requests

2 participants