Skip to content

Commit

Permalink
Add more logging for Python interpreter discovery (#5494)
Browse files Browse the repository at this point in the history
Addresses #5286 with some additional logging so we can start to
understand why we sometimes see this failure in smoke tests

### QA Notes

No changes for when the right Python interpreter _is_ found from the
`interpreterService`. If we again see this in tests, we should see
something like this in the Developer Tools console:

> ERR Interpreter
/Users/juliasilge/.pyenv/versions/3.11.7/envs/polars-testing/bin/python
not found in available Python interpreters:
/Users/juliasilge/.pyenv/versions/3.10.12/bin/python,/Users/juliasilge/.pyenv/versions/3.10.13/bin/python,/Users/juliasilge/.pyenv/versions/3.10.9/bin/python,/Users/juliasilge/.pyenv/versions/3.11.5/bin/python,/Users/juliasilge/.pyenv/versions/3.11.6/bin/python,/Users/juliasilge/.pyenv/versions/3.11.7/bin/python,/Users/juliasilge/.pyenv/versions/3.10.13/envs/bundle/bin/python,/Users/juliasilge/.pyenv/versions/3.10.12/envs/openai-testing/bin/python,/Users/juliasilge/.pyenv/versions/3.10.12/envs/positron/bin/python,/Users/juliasilge/.virtualenvs/r-tensorflow/bin/python,/usr/bin/python3,/Users/juliasilge/miniforge3/bin/python,/opt/homebrew/bin/python3.12,/Users/juliasilge/miniforge3/envs/emoji/bin/python,/Users/juliasilge/miniforge3/envs/keras-connect/bin/python,/Users/juliasilge/miniforge3/envs/my-first-pkg/bin/python,/Users/juliasilge/miniforge3/envs/pins-dev/bin/python,/Users/juliasilge/miniforge3/envs/test05-env/bin/python,/Users/juliasilge/miniforge3/envs/test06-env/bin/python,/Users/juliasilge/miniforge3/envs/tf_env/bin/python,/opt/homebrew/bin/python3.10,/opt/homebrew/bin/python3.11,/opt/homebrew/bin/python3.9,/Users/juliasilge/miniforge3/envs/another-test06-env/bin/python,/Users/juliasilge/.pyenv/versions/3.11.7/envs/positron-test-env/bin/python,

Kind of hard to read in a real situation, but seems like the best way
for us to find out what's going wrong occasionally in the tests is to
see all the interpreters the service thinks is there, plus what is was
looking for.

---------

Signed-off-by: Julia Silge <[email protected]>
Co-authored-by: sharon <[email protected]>
  • Loading branch information
juliasilge and sharon-wang authored Nov 27, 2024
1 parent 37a78a1 commit 7a118ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion extensions/positron-python/src/client/positron/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ export class PythonRuntimeSession implements positron.LanguageRuntimeSession, vs

const interpreter = interpreterService.getInterpreters().find((i) => i.id === extraData.pythonEnvironmentId);
if (!interpreter) {
throw new Error(`Interpreter not found: ${extraData.pythonEnvironmentId}`);
const interpreterIds = interpreterService.getInterpreters().map((i) => `\n- ${i.id}`);
throw new Error(
`Interpreter ${extraData.pythonEnvironmentId} (path: ${extraData.pythonPath}) not found in available Python interpreters: ${interpreterIds}`,
);
}
this.interpreter = interpreter;

Expand Down

0 comments on commit 7a118ad

Please sign in to comment.