Skip to content

AB Experiments

Kartik Raj edited this page Jan 6, 2022 · 29 revisions

The Python extension often uses A/B testing for new features. To see if you are part of an experiment, you can check the first lines in the Python extension output channel. If you wish to opt-out of A/B testing, you can open the user settings.json file (View > Command Palette… and run Preferences: Open Settings (JSON)) and set the python.experiments.enabled setting to false.

Alternatively, you can opt-in and opt-out of specific experiments through the python.experiments.optInto and python.experiments.optOutFrom settings. You can rely on the auto completions in VS Code to see which experiments you can opt-into and out from.

Experiments

pythonDeprecatePythonPath

Hi👋 If you're one of the random people chosen in this experiment, this page is for you. We encourage you to provide feedback.

TL;DR

In short,

  • The python.pythonPath setting is no longer used by the Python extension.
  • A new optional setting python.defaultInterpreterPath is introduced in the user and workspace scope, from which the extension will read the value when loading a project for the first time.
  • Particularly at workspace scope,
    • Changes to the python.defaultInterpreterPath will not be picked up by the Python extension once an interpreter is already selected for the workspace. The extension will also not set nor change the value of this setting, it will only read from it.
    • A VSCode internal storage is introduced which will now store the interpreter settings in the workspace & workspace folder scope. i.e workspace settings are no longer stored in settings.json/.code-workspace, but an internal storage.
      • You can change the value stored in workspace settings using Python: Select Interpreter command.
      • See the Python output channel to check the value of the interpreter selected.
      • You can clear the value stored using Python: Clear Workspace Interpreter Setting command.
  • At user scope, extension uses python.defaultInterpreterPath to control the selected interpreter, and will pick up any changes made to it.

Description

The pythonDeprecatePythonPath experiment changes how the Python extension stores, and users set, the path to a Python interpreter for a given Workspace. Previously, the path to the interpreter was stored in the python.pythonPath setting, as specified in the settings.json file. However, this storage method caused problems for users that work on teams that don’t use the same OS, or simply work with interpreters that don’t share the same path. In these situations, the setting is not valid across the team, making the process of storing a project’s settings.json in version control difficult.

For those who do want to add this setting to version control, you can use the python.defaultInterpreterPath setting instead, which the Python the extension will read values from when loading the project for the first time. Changes to this value are not dynamically picked up, i.e. changes to this setting after an interpreter has already been selected on a workspace will not be applied. The Python extension will also not add this setting nor modify its value at any point.

Experience

• The path to the workspace interpreter will now be stored in VS Code’s persistent storage instead of the settings.json file.

• For users that want to set a default interpreter for a workspace, you can use the new setting python.defaultInterpreterPath.

• For 3rd party extensions that need access to the Python path, you can retrieve it using the extension API. It's also possible to retrieve it using the command ${command:python.interpreterPath}.

• You can change workspace-specific value using Python: Select Interpreter command. When using the command on the Command Palette, a new option exists to specify an interpreter path.

• You can clear the value stored in workspace settings using Python: Clear Workspace Interpreter Setting command.

Related Issues

https://github.com/microsoft/vscode-python/issues/7805

https://github.com/microsoft/vscode-python/issues/2125

FAQ

Q: Can I opt out of the experiment?

A: You can opt out of any experiment by opening the user settings.json file (View > Command Palette… and run Preferences: Open Settings (JSON)) and set the “python.experiments.optOutFrom” setting to [“All”], or to specific experiments you wish to opt out from.

Q: How do I know if I’m part of the experiment?

A: To see if you are part of an experiment, you can check the first lines in the Python extension output channel.

Q: How do I add myself to the experiment?

A: You can opt in to this functionality by adding the following line to your User settings. First, run Preferences: Open Settings (JSON) and then, once you’ve added the line, reload the window by running Developer: Reload Window. "python.experiments.optInto": ["pythonDeprecatePythonPath"]

Q: How do I report a problem I’m having with this experiment?

A: If you’re having a problem with the experiment or wish to provide feedback, please create a new issue at https://github.com/Microsoft/vscode-python/issues.

Clone this wiki locally