Skip to content

Commit

Permalink
Fix interpreter tests (#7410)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Sep 7, 2021
1 parent 2569945 commit f08a71f
Show file tree
Hide file tree
Showing 21 changed files with 802 additions and 445 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,6 @@ module.exports = {
'src/client/datascience/jupyter/interpreter/jupyterInterpreterSelectionCommand.ts',
'src/client/datascience/jupyter/interpreter/jupyterInterpreterOldCacheStateStore.ts',
'src/client/datascience/jupyter/interpreter/jupyterInterpreterSelector.ts',
'src/client/datascience/jupyter/interpreter/jupyterInterpreterService.ts',
'src/client/datascience/jupyter/commandLineSelector.ts',
'src/client/datascience/jupyter/jupyterConnection.ts',
'src/client/datascience/jupyter/jupyterPasswordConnect.ts',
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/create-venv-for-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ runs:
python -m venv .venvkernel
source .venvkernel/bin/activate
python --version
python -c "import sys;print(sys.executable)"
python -m pip install ipykernel
python -m ipykernel install --user --name .venvkernel --display-name .venvkernel
python -m pip uninstall jedi --yes
python -m pip install jedi==0.17.2
python -m venv .venvnokernel
source .venvnokernel/bin/activate
python --version
python -c "import sys;print(sys.executable)"
python -m pip install ipykernel
python -m ipykernel install --user --name .venvnokernel --display-name .venvnokernel
python -m pip uninstall jedi --yes
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ jobs:
- name: Install Python Libs
if: env.conda_python == ''
run: |
python --version
python -c "import sys;print(sys.executable)"
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r ./requirements.txt
python -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt
python ./pythonFiles/install_debugpy.py
Expand Down Expand Up @@ -556,22 +558,23 @@ jobs:
check_name: Functional Test Report ${{matrix.os}}
if: steps.test_functional_group.outcome == 'failure' && failure()

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

vscodeTests:
name: VS Code Tests # These tests run with Python extension & real Jupyter
runs-on: ${{ matrix.os }}
if: github.repository == 'microsoft/vscode-jupyter'
env:
VSC_FORCE_REAL_JUPYTER: 1
VSC_PYTHON_FORCE_LOGGING: 1
VSC_JUPYTER_CI_RUN_NON_PYTHON_NB_TEST: 1
strategy:
fail-fast: false
Expand Down Expand Up @@ -734,6 +737,8 @@ jobs:
- name: Install Python Libs
if: matrix.python != 'conda' && matrix.python != 'noPython'
run: |
python --version
python -c "import sys;print(sys.executable)"
python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r ./requirements.txt
python -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt
python ./pythonFiles/install_debugpy.py
Expand Down
30 changes: 29 additions & 1 deletion src/client/api/pythonApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import { inject, injectable, named } from 'inversify';
import { CancellationToken, Disposable, Event, EventEmitter, Memento, Uri } from 'vscode';
import { IApplicationShell, ICommandManager, IWorkspaceService } from '../common/application/types';
import { isCI } from '../common/constants';
import { trackPackageInstalledIntoInterpreter } from '../common/installer/productInstaller';
import { ProductNames } from '../common/installer/productNames';
import { InterpreterUri } from '../common/installer/types';
import { traceInfo } from '../common/logger';
import {
GLOBAL_MEMENTO,
IDisposableRegistry,
Expand Down Expand Up @@ -313,6 +315,8 @@ export class InterpreterSelector implements IInterpreterSelector {
return this.apiProvider.getApi().then((api) => api.getSuggestions(resource));
}
}

const interpreterCacheForCI = new Map<string, PythonEnvironment[]>();
// eslint-disable-next-line max-classes-per-file
@injectable()
export class InterpreterService implements IInterpreterService {
Expand Down Expand Up @@ -345,7 +349,24 @@ export class InterpreterService implements IInterpreterService {
@captureTelemetry(Telemetry.InterpreterListingPerf)
public getInterpreters(resource?: Uri): Promise<PythonEnvironment[]> {
this.hookupOnDidChangeInterpreterEvent();
return this.apiProvider.getApi().then((api) => api.getInterpreters(resource));
const promise = this.apiProvider.getApi().then((api) => api.getInterpreters(resource));
if (isCI) {
promise
.then((items) => {
const current = interpreterCacheForCI.get(resource?.toString() || '');
const itemToStore = items;
if (
current &&
(itemToStore === current || JSON.stringify(itemToStore) === JSON.stringify(current))
) {
return;
}
interpreterCacheForCI.set(resource?.toString() || '', itemToStore);
traceInfo(`Interpreter list for ${resource?.toString()} is ${JSON.stringify(items)}`);
})
.catch(noop);
}
return promise;
}
private workspaceCachedActiveInterpreter = new Map<string, Promise<PythonEnvironment | undefined>>();
@captureTelemetry(Telemetry.ActiveInterpreterListingPerf)
Expand All @@ -364,6 +385,13 @@ export class InterpreterService implements IInterpreterService {
this.workspaceCachedActiveInterpreter.delete(workspaceId);
}
});
if (isCI) {
promise
.then((item) =>
traceInfo(`Active Interpreter in Python API for ${resource?.toString()} is ${item?.path}`)
)
.catch(noop);
}
}
}
return promise;
Expand Down
1 change: 0 additions & 1 deletion src/client/datascience/export/exportInterpreterFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class ExportInterpreterFinder {

// If an interpreter was not passed in, work with the main jupyter interperter
const selectedJupyterInterpreter = await this.jupyterInterpreterService.getSelectedInterpreter();

if (selectedJupyterInterpreter) {
if (await this.checkNotebookInterpreter(selectedJupyterInterpreter)) {
return selectedJupyterInterpreter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ export class JupyterInterpreterService {
// Nothing saved found, so check our current interpreter
if (!interpreter) {
const currentInterpreter = await this.interpreterService.getActiveInterpreter(undefined);

if (currentInterpreter) {
// If the current active interpreter has everything installed already just use that
if (await this.interpreterConfiguration.areDependenciesInstalled(currentInterpreter, token)) {
Expand Down
Loading

0 comments on commit f08a71f

Please sign in to comment.