Skip to content

Commit f08a71f

Browse files
authored
Fix interpreter tests (#7410)
1 parent 2569945 commit f08a71f

21 files changed

+802
-445
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,6 @@ module.exports = {
723723
'src/client/datascience/jupyter/interpreter/jupyterInterpreterSelectionCommand.ts',
724724
'src/client/datascience/jupyter/interpreter/jupyterInterpreterOldCacheStateStore.ts',
725725
'src/client/datascience/jupyter/interpreter/jupyterInterpreterSelector.ts',
726-
'src/client/datascience/jupyter/interpreter/jupyterInterpreterService.ts',
727726
'src/client/datascience/jupyter/commandLineSelector.ts',
728727
'src/client/datascience/jupyter/jupyterConnection.ts',
729728
'src/client/datascience/jupyter/jupyterPasswordConnect.ts',

.github/actions/create-venv-for-tests/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ runs:
2121
2222
python -m venv .venvkernel
2323
source .venvkernel/bin/activate
24+
python --version
25+
python -c "import sys;print(sys.executable)"
2426
python -m pip install ipykernel
2527
python -m ipykernel install --user --name .venvkernel --display-name .venvkernel
2628
python -m pip uninstall jedi --yes
2729
python -m pip install jedi==0.17.2
2830
2931
python -m venv .venvnokernel
3032
source .venvnokernel/bin/activate
33+
python --version
34+
python -c "import sys;print(sys.executable)"
3135
python -m pip install ipykernel
3236
python -m ipykernel install --user --name .venvnokernel --display-name .venvnokernel
3337
python -m pip uninstall jedi --yes

.github/workflows/build-test.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ jobs:
468468
- name: Install Python Libs
469469
if: env.conda_python == ''
470470
run: |
471+
python --version
472+
python -c "import sys;print(sys.executable)"
471473
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r ./requirements.txt
472474
python -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt
473475
python ./pythonFiles/install_debugpy.py
@@ -556,22 +558,23 @@ jobs:
556558
check_name: Functional Test Report ${{matrix.os}}
557559
if: steps.test_functional_group.outcome == 'failure' && failure()
558560

559-
# Mosts tests are commented, hence nothing runs, thus no coverage (if not commented, CI falls over as this code expects coverage files)
560-
# Upload unit test coverage reports for later use in the "reports" job.
561-
- name: Upload unit test coverage reports
562-
uses: actions/upload-artifact@v2
563-
if: "(success() || failure()) && !contains(github.ref, 'refs/heads/release')"
564-
with:
565-
name: ${{runner.os}}-${{env.COVERAGE_REPORTS}}
566-
path: .nyc_output
567-
retention-days: 1
561+
# # Mosts tests are commented, hence nothing runs, thus no coverage (if not commented, CI falls over as this code expects coverage files)
562+
# # Upload unit test coverage reports for later use in the "reports" job.
563+
# - name: Upload unit test coverage reports
564+
# uses: actions/upload-artifact@v2
565+
# if: "(success() || failure()) && !contains(github.ref, 'refs/heads/release')"
566+
# with:
567+
# name: ${{runner.os}}-${{env.COVERAGE_REPORTS}}
568+
# path: .nyc_output
569+
# retention-days: 1
568570

569571
vscodeTests:
570572
name: VS Code Tests # These tests run with Python extension & real Jupyter
571573
runs-on: ${{ matrix.os }}
572574
if: github.repository == 'microsoft/vscode-jupyter'
573575
env:
574576
VSC_FORCE_REAL_JUPYTER: 1
577+
VSC_PYTHON_FORCE_LOGGING: 1
575578
VSC_JUPYTER_CI_RUN_NON_PYTHON_NB_TEST: 1
576579
strategy:
577580
fail-fast: false
@@ -734,6 +737,8 @@ jobs:
734737
- name: Install Python Libs
735738
if: matrix.python != 'conda' && matrix.python != 'noPython'
736739
run: |
740+
python --version
741+
python -c "import sys;print(sys.executable)"
737742
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r ./requirements.txt
738743
python -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt
739744
python ./pythonFiles/install_debugpy.py

src/client/api/pythonApi.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
import { inject, injectable, named } from 'inversify';
1515
import { CancellationToken, Disposable, Event, EventEmitter, Memento, Uri } from 'vscode';
1616
import { IApplicationShell, ICommandManager, IWorkspaceService } from '../common/application/types';
17+
import { isCI } from '../common/constants';
1718
import { trackPackageInstalledIntoInterpreter } from '../common/installer/productInstaller';
1819
import { ProductNames } from '../common/installer/productNames';
1920
import { InterpreterUri } from '../common/installer/types';
21+
import { traceInfo } from '../common/logger';
2022
import {
2123
GLOBAL_MEMENTO,
2224
IDisposableRegistry,
@@ -313,6 +315,8 @@ export class InterpreterSelector implements IInterpreterSelector {
313315
return this.apiProvider.getApi().then((api) => api.getSuggestions(resource));
314316
}
315317
}
318+
319+
const interpreterCacheForCI = new Map<string, PythonEnvironment[]>();
316320
// eslint-disable-next-line max-classes-per-file
317321
@injectable()
318322
export class InterpreterService implements IInterpreterService {
@@ -345,7 +349,24 @@ export class InterpreterService implements IInterpreterService {
345349
@captureTelemetry(Telemetry.InterpreterListingPerf)
346350
public getInterpreters(resource?: Uri): Promise<PythonEnvironment[]> {
347351
this.hookupOnDidChangeInterpreterEvent();
348-
return this.apiProvider.getApi().then((api) => api.getInterpreters(resource));
352+
const promise = this.apiProvider.getApi().then((api) => api.getInterpreters(resource));
353+
if (isCI) {
354+
promise
355+
.then((items) => {
356+
const current = interpreterCacheForCI.get(resource?.toString() || '');
357+
const itemToStore = items;
358+
if (
359+
current &&
360+
(itemToStore === current || JSON.stringify(itemToStore) === JSON.stringify(current))
361+
) {
362+
return;
363+
}
364+
interpreterCacheForCI.set(resource?.toString() || '', itemToStore);
365+
traceInfo(`Interpreter list for ${resource?.toString()} is ${JSON.stringify(items)}`);
366+
})
367+
.catch(noop);
368+
}
369+
return promise;
349370
}
350371
private workspaceCachedActiveInterpreter = new Map<string, Promise<PythonEnvironment | undefined>>();
351372
@captureTelemetry(Telemetry.ActiveInterpreterListingPerf)
@@ -364,6 +385,13 @@ export class InterpreterService implements IInterpreterService {
364385
this.workspaceCachedActiveInterpreter.delete(workspaceId);
365386
}
366387
});
388+
if (isCI) {
389+
promise
390+
.then((item) =>
391+
traceInfo(`Active Interpreter in Python API for ${resource?.toString()} is ${item?.path}`)
392+
)
393+
.catch(noop);
394+
}
367395
}
368396
}
369397
return promise;

src/client/datascience/export/exportInterpreterFinder.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export class ExportInterpreterFinder {
3333

3434
// If an interpreter was not passed in, work with the main jupyter interperter
3535
const selectedJupyterInterpreter = await this.jupyterInterpreterService.getSelectedInterpreter();
36-
3736
if (selectedJupyterInterpreter) {
3837
if (await this.checkNotebookInterpreter(selectedJupyterInterpreter)) {
3938
return selectedJupyterInterpreter;

src/client/datascience/jupyter/interpreter/jupyterInterpreterService.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ export class JupyterInterpreterService {
222222
// Nothing saved found, so check our current interpreter
223223
if (!interpreter) {
224224
const currentInterpreter = await this.interpreterService.getActiveInterpreter(undefined);
225-
226225
if (currentInterpreter) {
227226
// If the current active interpreter has everything installed already just use that
228227
if (await this.interpreterConfiguration.areDependenciesInstalled(currentInterpreter, token)) {

0 commit comments

Comments
 (0)