From 536b53bdbebae0d22354a83370e625698bb44dcb Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 18 Jan 2022 21:17:18 +0530 Subject: [PATCH 1/8] Do not validate interpreters as part of discovery --- .../base/locators/composite/envsResolver.ts | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/client/pythonEnvironments/base/locators/composite/envsResolver.ts b/src/client/pythonEnvironments/base/locators/composite/envsResolver.ts index ef5b035541ea..e7c09c0aab91 100644 --- a/src/client/pythonEnvironments/base/locators/composite/envsResolver.ts +++ b/src/client/pythonEnvironments/base/locators/composite/envsResolver.ts @@ -52,6 +52,7 @@ export class PythonEnvsResolver implements IResolvingLocator { return iterator; } + // eslint-disable-next-line class-methods-use-this private async *iterEnvsIterator( iterator: IPythonEnvsIterator, didUpdate: EventEmitter, @@ -73,10 +74,9 @@ export class PythonEnvsResolver implements IResolvingLocator { 'Unsupported behavior: `undefined` environment updates are not supported from downstream locators in resolver', ); } else if (seen[event.index] !== undefined) { - const old = seen[event.index]; + // const old = seen[event.index]; seen[event.index] = await resolveBasicEnv(event.update); - didUpdate.fire({ old, index: event.index, update: seen[event.index] }); - this.resolveInBackground(event.index, state, didUpdate, seen).ignoreErrors(); + // this.resolveInBackground(event.index, state, didUpdate, seen).ignoreErrors(); } else { // This implies a problem in a downstream locator traceVerbose(`Expected already iterated env, got ${event.old} (#${event.index})`); @@ -91,7 +91,7 @@ export class PythonEnvsResolver implements IResolvingLocator { const currEnv = await resolveBasicEnv(result.value); seen.push(currEnv); yield currEnv; - this.resolveInBackground(seen.indexOf(currEnv), state, didUpdate, seen).ignoreErrors(); + // this.resolveInBackground(seen.indexOf(currEnv), state, didUpdate, seen).ignoreErrors(); result = await iterator.next(); } if (iterator.onUpdated === undefined) { @@ -100,28 +100,28 @@ export class PythonEnvsResolver implements IResolvingLocator { } } - private async resolveInBackground( - envIndex: number, - state: { done: boolean; pending: number }, - didUpdate: EventEmitter, - seen: PythonEnvInfo[], - ) { - state.pending += 1; - // It's essential we increment the pending call count before any asynchronus calls in this method. - // We want this to be run even when `resolveInBackground` is called in background. - const info = await this.environmentInfoService.getEnvironmentInfo(seen[envIndex]); - const old = seen[envIndex]; - if (info) { - const resolvedEnv = getResolvedEnv(info, seen[envIndex]); - seen[envIndex] = resolvedEnv; - didUpdate.fire({ old, index: envIndex, update: resolvedEnv }); - } else { - // Send update that the environment is not valid. - didUpdate.fire({ old, index: envIndex, update: undefined }); - } - state.pending -= 1; - checkIfFinishedAndNotify(state, didUpdate); - } + // private async resolveInBackground( + // envIndex: number, + // state: { done: boolean; pending: number }, + // didUpdate: EventEmitter, + // seen: PythonEnvInfo[], + // ) { + // state.pending += 1; + // // It's essential we increment the pending call count before any asynchronus calls in this method. + // // We want this to be run even when `resolveInBackground` is called in background. + // const info = await this.environmentInfoService.getEnvironmentInfo(seen[envIndex]); + // const old = seen[envIndex]; + // if (info) { + // const resolvedEnv = getResolvedEnv(info, seen[envIndex]); + // seen[envIndex] = resolvedEnv; + // didUpdate.fire({ old, index: envIndex, update: resolvedEnv }); + // } else { + // // Send update that the environment is not valid. + // didUpdate.fire({ old, index: envIndex, update: undefined }); + // } + // state.pending -= 1; + // checkIfFinishedAndNotify(state, didUpdate); + // } } /** From e12ffdd933994c032e960f5e3583223e11612b6b Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 18 Jan 2022 21:18:10 +0530 Subject: [PATCH 2/8] Only build VSIX --- .github/workflows/pr-check.yml | 986 +++++++++++++++++---------------- 1 file changed, 512 insertions(+), 474 deletions(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 7ec43a27b925..ebbe723be034 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -33,477 +33,515 @@ jobs: node_version: ${{ env.NODE_VERSION}} vsix_name: ${{ env.VSIX_NAME }} artifact_name: ${{ env.ARTIFACT_NAME_VSIX }} - - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2.3.4 - - - name: Lint - uses: ./.github/actions/lint - with: - node_version: ${{ env.NODE_VERSION }} - - check-types: - name: Check Python types - runs-on: ubuntu-latest - steps: - - name: Use Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v2 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Checkout - uses: actions/checkout@v2.3.4 - - - name: Install base Python requirements - uses: brettcannon/pip-secure-install@v1 - with: - options: '-t ./pythonFiles/lib/python --no-cache-dir --implementation py' - - - name: Install Jedi requirements - uses: brettcannon/pip-secure-install@v1 - with: - requirements-file: './pythonFiles/jedilsp_requirements/requirements.txt' - options: '-t ./pythonFiles/lib/jedilsp --no-cache-dir --implementation py' - - - name: Install other Python requirements - run: | - python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy - python -m pip install --upgrade -r build/test-requirements.txt - - - name: Run Pyright - uses: jakebailey/pyright-action@v1 - with: - working-directory: 'pythonFiles' - - ### Non-smoke tests - tests: - name: Tests - # The value of runs-on is the OS of the current job (specified in the strategy matrix below) instead of being hardcoded. - runs-on: ${{ matrix.os }} - defaults: - run: - working-directory: ${{ env.special-working-directory }} - strategy: - fail-fast: false - matrix: - # We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used, - # macOS runners are expensive, and we assume that Ubuntu is enough to cover the Unix case. - os: [ubuntu-latest, windows-latest] - # Run the tests on the oldest and most recent versions of Python. - python: ['2.7', '3.x'] - test-suite: [ts-unit, python-unit, venv, single-workspace, debugger, functional] - exclude: - # For fast PR turn-around, skip 2.7 under Windows. - - os: windows-latest - python: '2.7' - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - path: ${{ env.special-working-directory-relative }} - - - name: Install Node - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - cache-dependency-path: ${{ env.special-working-directory-relative }}/package-lock.json - - - name: Install dependencies (npm ci) - run: npm ci - - - name: Compile - run: npx gulp prePublishNonBundle - - - name: Use Python ${{ matrix.python }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - - name: Install debugpy - run: | - # We need to have debugpy so that tests relying on it keep passing, but we don't need install_debugpy's logic in the test phase. - python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy - - - name: Install base Python requirements - uses: brettcannon/pip-secure-install@v1 - with: - requirements-file: '"${{ env.special-working-directory-relative }}/requirements.txt"' - options: '-t "${{ env.special-working-directory-relative }}/pythonFiles/lib/python" --no-cache-dir --implementation py' - if: startsWith(matrix.python, 3.) - - - name: Install Jedi requirements - uses: brettcannon/pip-secure-install@v1 - with: - requirements-file: '"${{ env.special-working-directory-relative }}/pythonFiles/jedilsp_requirements/requirements.txt"' - options: '-t "${{ env.special-working-directory-relative }}/pythonFiles/lib/jedilsp" --no-cache-dir --implementation py' - if: startsWith(matrix.python, 3.) - - - name: Install test requirements - run: python -m pip install --upgrade -r build/test-requirements.txt - - - name: Install debugpy wheels (Python ${{ matrix.python }}) - run: | - python -m pip install wheel - python -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt - python ./pythonFiles/install_debugpy.py - shell: bash - if: matrix.test-suite == 'debugger' && matrix.python != 2.7 - - - name: Install debugpy wheel (Python 2.7) - run: | - python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy - shell: bash - if: matrix.test-suite == 'debugger' && matrix.python == 2.7 - - - name: Install functional test requirements - run: python -m pip install --upgrade -r ./build/functional-test-requirements.txt - if: matrix.test-suite == 'functional' - - - name: Prepare pipenv for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - if: matrix.test-suite == 'venv' && matrix.python != 2.7 - run: | - python -m pip install pipenv - python -m pipenv run python ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} pipenvPath - - - name: Prepare poetry for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - shell: pwsh - if: matrix.test-suite == 'venv' - run: | - python -m pip install poetry - Move-Item -Path ".\build\ci\pyproject.toml" -Destination . - poetry env use python - - - name: Prepare virtualenv for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - if: matrix.test-suite == 'venv' - run: | - python -m pip install virtualenv - python -m virtualenv .virtualenv/ - if ('${{ matrix.os }}' -match 'windows-latest') { - & ".virtualenv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} virtualEnvPath - } else { - & ".virtualenv/bin/python" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} virtualEnvPath - } - - - name: Prepare venv for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - if: matrix.test-suite == 'venv' && startsWith(matrix.python, 3.) - run: | - python -m venv .venv - if ('${{ matrix.os }}' -match 'windows-latest') { - & ".venv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} venvPath - } else { - & ".venv/bin/python" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} venvPath - } - - - name: Prepare conda for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - if: matrix.test-suite == 'venv' - run: | - # 1. For `terminalActivation.testvirtualenvs.test.ts` - if ('${{ matrix.os }}' -match 'windows-latest') { - $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python.exe - $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath Scripts | Join-Path -ChildPath conda - } else{ - $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath python - $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath conda - } - & $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaExecPath $condaExecPath - & $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath - & $condaExecPath init --all - - - name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION - run: | - echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV - echo "CI_DISABLE_AUTO_SELECTION=1" >> $GITHUB_ENV - shell: bash - if: matrix.test-suite != 'ts-unit' - - # Run TypeScript unit tests only for Python 3.X. - - name: Run TypeScript unit tests - run: npm run test:unittests - if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, 3.) - - # Run the Python tests in our codebase. - - name: Run Python unit tests - run: | - python pythonFiles/tests/run_all.py - if: matrix.test-suite == 'python-unit' - - # The virtual environment based tests use the `testSingleWorkspace` set of tests - # with the environment variable `TEST_FILES_SUFFIX` set to `testvirtualenvs`, - # which is set in the "Prepare environment for venv tests" step. - # We also use a third-party GitHub Action to install xvfb on Linux, - # run tests and then clean up the process once the tests ran. - # See https://github.com/GabrielBB/xvfb-action - - name: Run venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - CI_PYTHON_VERSION: ${{ matrix.python }} - uses: GabrielBB/xvfb-action@v1.6 - with: - run: npm run testSingleWorkspace - working-directory: ${{ env.special-working-directory }} - if: matrix.test-suite == 'venv' && matrix.os == 'ubuntu-latest' - - - name: Run single-workspace tests - env: - CI_PYTHON_VERSION: ${{ matrix.python }} - uses: GabrielBB/xvfb-action@v1.6 - with: - run: npm run testSingleWorkspace - working-directory: ${{ env.special-working-directory }} - if: matrix.test-suite == 'single-workspace' - - - name: Run multi-workspace tests - env: - CI_PYTHON_VERSION: ${{ matrix.python }} - uses: GabrielBB/xvfb-action@v1.6 - with: - run: npm run testMultiWorkspace - working-directory: ${{ env.special-working-directory }} - if: matrix.test-suite == 'multi-workspace' - - - name: Run debugger tests - env: - CI_PYTHON_VERSION: ${{ matrix.python }} - uses: GabrielBB/xvfb-action@v1.6 - with: - run: npm run testDebugger - working-directory: ${{ env.special-working-directory }} - if: matrix.test-suite == 'debugger' - - # Run TypeScript functional tests - - name: Run TypeScript functional tests - run: npm run test:functional - if: matrix.test-suite == 'functional' - - smoke-tests: - name: Smoke tests - # The value of runs-on is the OS of the current job (specified in the strategy matrix below) instead of being hardcoded. - runs-on: ${{ matrix.os }} - needs: [build-vsix] - strategy: - fail-fast: false - matrix: - # We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used, - # macOS runners are expensive, and we assume that Ubuntu is enough to cover the UNIX case. - os: [ubuntu-latest, windows-latest] - steps: - # Need the source to have the tests available. - - name: Checkout - uses: actions/checkout@v2 - - - name: Smoke tests - uses: ./.github/actions/smoke-tests - with: - node_version: ${{ env.NODE_VERSION }} - artifact_name: ${{ env.ARTIFACT_NAME_VSIX }} - - ### Coverage run - coverage: - name: Coverage - # The value of runs-on is the OS of the current job (specified in the strategy matrix below) instead of being hardcoded. - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - # Only run coverage on linux for PRs - os: [ubuntu-latest] - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Node - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - name: Install dependencies (npm ci) - run: npm ci - - - name: Compile - run: npx gulp prePublishNonBundle - - - name: Use Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v2 - with: - python-version: ${{ env.PYTHON_VERSION }} - cache: 'pip' - cache-dependency-path: | - requirements.txt - pythonFiles/jedilsp_requirements/requirements.txt - build/test-requirements.txt - build/functional-test-requirements.txt - - - name: Install base Python requirements - uses: brettcannon/pip-secure-install@v1 - with: - options: '-t ./pythonFiles/lib/python --implementation py' - - - name: Install Jedi requirements - uses: brettcannon/pip-secure-install@v1 - with: - requirements-file: './pythonFiles/jedilsp_requirements/requirements.txt' - options: '-t ./pythonFiles/lib/jedilsp --implementation py' - - - name: Install debugpy - run: | - # We need to have debugpy so that tests relying on it keep passing, but we don't need install_debugpy's logic in the test phase. - python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --implementation py --no-deps --upgrade --pre debugpy - - - name: Install test requirements - run: python -m pip install --upgrade -r build/test-requirements.txt - - - name: Install functional test requirements - run: python -m pip install --upgrade -r ./build/functional-test-requirements.txt - - - name: Prepare pipenv for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - run: | - python -m pip install pipenv - python -m pipenv run python ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} pipenvPath - - - name: Prepare poetry for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - shell: pwsh - run: | - python -m pip install poetry - Move-Item -Path ".\build\ci\pyproject.toml" -Destination . - poetry env use python - - - name: Prepare virtualenv for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - run: | - python -m pip install virtualenv - python -m virtualenv .virtualenv/ - if ('${{ matrix.os }}' -match 'windows-latest') { - & ".virtualenv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} virtualEnvPath - } else { - & ".virtualenv/bin/python" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} virtualEnvPath - } - - - name: Prepare venv for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - run: | - python -m venv .venv - if ('${{ matrix.os }}' -match 'windows-latest') { - & ".venv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} venvPath - } else { - & ".venv/bin/python" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} venvPath - } - - - name: Prepare conda for venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' - shell: pwsh - run: | - # 1. For `terminalActivation.testvirtualenvs.test.ts` - if ('${{ matrix.os }}' -match 'windows-latest') { - $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python.exe - $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath Scripts | Join-Path -ChildPath conda - } else{ - $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath python - $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath conda - } - & $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaExecPath $condaExecPath - & $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath - & $condaExecPath init --all - - - name: Run TypeScript unit tests - run: npm run test:unittests:cover - - - name: Run Python unit tests - run: | - python pythonFiles/tests/run_all.py - - # The virtual environment based tests use the `testSingleWorkspace` set of tests - # with the environment variable `TEST_FILES_SUFFIX` set to `testvirtualenvs`, - # which is set in the "Prepare environment for venv tests" step. - # We also use a third-party GitHub Action to install xvfb on Linux, - # run tests and then clean up the process once the tests ran. - # See https://github.com/GabrielBB/xvfb-action - - name: Run venv tests - env: - TEST_FILES_SUFFIX: testvirtualenvs - CI_PYTHON_VERSION: ${{ env.PYTHON_VERSION }} - CI_DISABLE_AUTO_SELECTION: 1 - uses: GabrielBB/xvfb-action@v1.6 - with: - run: npm run testSingleWorkspace:cover - - - name: Run single-workspace tests - env: - CI_PYTHON_VERSION: ${{ env.PYTHON_VERSION }} - CI_DISABLE_AUTO_SELECTION: 1 - uses: GabrielBB/xvfb-action@v1.6 - with: - run: npm run testSingleWorkspace:cover - - # Enable these tests when coverage is setup for multiroot workspace tests - # - name: Run multi-workspace tests - # env: - # CI_PYTHON_VERSION: ${{ env.PYTHON_VERSION }} - # CI_DISABLE_AUTO_SELECTION: 1 - # uses: GabrielBB/xvfb-action@v1.6 - # with: - # run: npm run testMultiWorkspace:cover - - # Enable these tests when coverage is setup for debugger tests - # - name: Run debugger tests - # env: - # CI_PYTHON_VERSION: ${{ env.PYTHON_VERSION }} - # CI_DISABLE_AUTO_SELECTION: 1 - # uses: GabrielBB/xvfb-action@v1.6 - # with: - # run: npm run testDebugger:cover - - # Run TypeScript functional tests - - name: Run TypeScript functional tests - env: - CI_PYTHON_VERSION: ${{ env.PYTHON_VERSION }} - CI_DISABLE_AUTO_SELECTION: 1 - run: npm run test:functional:cover - - - name: Generate coverage reports - run: npm run test:cover:report - - - name: Upload HTML report - uses: actions/upload-artifact@v2 - with: - name: ${{ runner.os }}-coverage-report-html - path: ./coverage - retention-days: 1 +# lint: +# name: Lint +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v2.3.4 + +# - name: Lint +# uses: ./.github/actions/lint +# with: +# node_version: ${{ env.NODE_VERSION }} + +# check-types: +# name: Check Python types +# runs-on: ubuntu-latest +# steps: +# - name: Use Python ${{ env.PYTHON_VERSION }} +# uses: actions/setup-python@v2 +# with: +# python-version: ${{ env.PYTHON_VERSION }} + +# - name: Checkout +# uses: actions/checkout@v2.3.4 + +# - name: Install Python requirements +# run: | +# python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy +# python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt --no-user +# python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/jedilsp --no-cache-dir --implementation py --no-deps --upgrade -r ./pythonFiles/jedilsp_requirements/requirements.txt +# python -m pip install --upgrade -r build/test-requirements.txt + +# - name: Run Pyright +# uses: jakebailey/pyright-action@v1 +# with: +# working-directory: 'pythonFiles' + +# ### Non-smoke tests +# tests: +# name: Tests +# # The value of runs-on is the OS of the current job (specified in the strategy matrix below) instead of being hardcoded. +# runs-on: ${{ matrix.os }} +# defaults: +# run: +# working-directory: ${{ env.special-working-directory }} +# strategy: +# fail-fast: false +# matrix: +# # We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used, +# # macOS runners are expensive, and we assume that Ubuntu is enough to cover the Unix case. +# os: [ubuntu-latest, windows-latest] +# # Run the tests on the oldest and most recent versions of Python. +# python: ['2.7', '3.x'] +# test-suite: [ts-unit, python-unit, venv, single-workspace, debugger, functional] +# exclude: +# # For fast PR turn-around, skip 2.7 under Windows. +# - os: windows-latest +# python: '2.7' +# steps: +# - name: Checkout +# uses: actions/checkout@v2 +# with: +# path: ${{ env.special-working-directory-relative }} + +# - name: Install Node +# uses: actions/setup-node@v2 +# with: +# node-version: ${{ env.NODE_VERSION }} +# cache: 'npm' +# cache-dependency-path: ${{ env.special-working-directory-relative }}/package-lock.json + +# - name: Install dependencies (npm ci) +# run: npm ci + +# - name: Compile +# run: npx gulp prePublishNonBundle + +# - name: Use Python ${{ matrix.python }} +# uses: actions/setup-python@v2 +# with: +# python-version: ${{ matrix.python }} + +# - name: Install Python requirements +# run: | +# # We need to have debugpy so that tests relying on it keep passing, but we don't need install_debugpy's logic in the test phase. +# python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy + +# - name: Install Python 3 requirements +# run: | +# python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt --no-user +# python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/jedilsp --no-cache-dir --implementation py --no-deps --upgrade -r ./pythonFiles/jedilsp_requirements/requirements.txt +# if: startsWith(matrix.python, 3.) + +# - name: Install test requirements +# run: python -m pip install --upgrade -r build/test-requirements.txt + +# - name: Install debugpy wheels (Python ${{ matrix.python }}) +# run: | +# python -m pip install wheel +# python -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt +# python ./pythonFiles/install_debugpy.py +# shell: bash +# if: matrix.test-suite == 'debugger' && matrix.python != 2.7 + +# - name: Install debugpy wheel (Python 2.7) +# run: | +# python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy +# shell: bash +# if: matrix.test-suite == 'debugger' && matrix.python == 2.7 + +# - name: Install functional test requirements +# run: python -m pip install --upgrade -r ./build/functional-test-requirements.txt +# if: matrix.test-suite == 'functional' + +# - name: Prepare pipenv for venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' +# shell: pwsh +# if: matrix.test-suite == 'venv' && matrix.python != 2.7 +# run: | +# python -m pip install pipenv +# python -m pipenv run python ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} pipenvPath + +# - name: Prepare poetry for venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# shell: pwsh +# if: matrix.test-suite == 'venv' +# run: | +# python -m pip install poetry +# Move-Item -Path ".\build\ci\pyproject.toml" -Destination . +# poetry env use python + +# - name: Prepare virtualenv for venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' +# shell: pwsh +# if: matrix.test-suite == 'venv' +# run: | +# python -m pip install virtualenv +# python -m virtualenv .virtualenv/ +# if ('${{ matrix.os }}' -match 'windows-latest') { +# & ".virtualenv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} virtualEnvPath +# } else { +# & ".virtualenv/bin/python" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} virtualEnvPath +# } + +# - name: Prepare venv for venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' +# shell: pwsh +# if: matrix.test-suite == 'venv' && startsWith(matrix.python, 3.) +# run: | +# python -m venv .venv +# if ('${{ matrix.os }}' -match 'windows-latest') { +# & ".venv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} venvPath +# } else { +# & ".venv/bin/python" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} venvPath +# } + +# - name: Prepare conda for venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' +# shell: pwsh +# if: matrix.test-suite == 'venv' +# run: | +# # 1. For `terminalActivation.testvirtualenvs.test.ts` +# if ('${{ matrix.os }}' -match 'windows-latest') { +# $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python.exe +# $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath Scripts | Join-Path -ChildPath conda +# } else{ +# $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath python +# $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath conda +# } +# & $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaExecPath $condaExecPath +# & $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath +# & $condaExecPath init --all + +# - name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION +# run: | +# echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV +# echo "CI_DISABLE_AUTO_SELECTION=1" >> $GITHUB_ENV +# shell: bash +# if: matrix.test-suite != 'ts-unit' + +# # Run TypeScript unit tests only for Python 3.X. +# - name: Run TypeScript unit tests +# run: npm run test:unittests +# if: matrix.test-suite == 'ts-unit' && startsWith(matrix.python, 3.) + +# # Run the Python tests in our codebase. +# - name: Run Python unit tests +# run: | +# python pythonFiles/tests/run_all.py +# if: matrix.test-suite == 'python-unit' + +# # The virtual environment based tests use the `testSingleWorkspace` set of tests +# # with the environment variable `TEST_FILES_SUFFIX` set to `testvirtualenvs`, +# # which is set in the "Prepare environment for venv tests" step. +# # We also use a third-party GitHub Action to install xvfb on Linux, +# # run tests and then clean up the process once the tests ran. +# # See https://github.com/GabrielBB/xvfb-action +# - name: Run venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# CI_PYTHON_VERSION: ${{ matrix.python }} +# uses: GabrielBB/xvfb-action@v1.6 +# with: +# run: npm run testSingleWorkspace +# working-directory: ${{ env.special-working-directory }} +# if: matrix.test-suite == 'venv' && matrix.os == 'ubuntu-latest' + +# - name: Run single-workspace tests +# env: +# CI_PYTHON_VERSION: ${{ matrix.python }} +# uses: GabrielBB/xvfb-action@v1.6 +# with: +# run: npm run testSingleWorkspace +# working-directory: ${{ env.special-working-directory }} +# if: matrix.test-suite == 'single-workspace' + +# - name: Run multi-workspace tests +# env: +# CI_PYTHON_VERSION: ${{ matrix.python }} +# uses: GabrielBB/xvfb-action@v1.6 +# with: +# run: npm run testMultiWorkspace +# working-directory: ${{ env.special-working-directory }} +# if: matrix.test-suite == 'multi-workspace' + +# - name: Run debugger tests +# env: +# CI_PYTHON_VERSION: ${{ matrix.python }} +# uses: GabrielBB/xvfb-action@v1.6 +# with: +# run: npm run testDebugger +# working-directory: ${{ env.special-working-directory }} +# if: matrix.test-suite == 'debugger' + +# # Run TypeScript functional tests +# - name: Run TypeScript functional tests +# run: npm run test:functional +# if: matrix.test-suite == 'functional' + +# smoke-tests: +# name: Smoke tests +# # The value of runs-on is the OS of the current job (specified in the strategy matrix below) instead of being hardcoded. +# runs-on: ${{ matrix.os }} +# needs: [build-vsix] +# strategy: +# fail-fast: false +# matrix: +# # We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used, +# # macOS runners are expensive, and we assume that Ubuntu is enough to cover the UNIX case. +# os: [ubuntu-latest, windows-latest] +# steps: +# # Need the source to have the tests available. +# - name: Checkout +# uses: actions/checkout@v2 + +# - name: Smoke tests +# uses: ./.github/actions/smoke-tests +# with: +# node_version: ${{ env.NODE_VERSION }} +# artifact_name: ${{ env.ARTIFACT_NAME_VSIX }} + +# insider-tests: +# name: Insider tests +# # The value of runs-on is the OS of the current job (specified in the strategy matrix below) instead of being hardcoded. +# runs-on: ${{ matrix.os }} +# strategy: +# fail-fast: false +# matrix: +# # We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used, +# # macOS runners are expensive, and we assume that Ubuntu is enough to cover the UNIX case. +# os: [ubuntu-latest] +# python: [3.8] +# steps: +# # Need the source to have the tests available. +# - name: Checkout +# uses: actions/checkout@v2 + +# - name: Install Node +# uses: actions/setup-node@v2 +# with: +# node-version: ${{ env.NODE_VERSION }} +# cache: 'npm' + +# - name: Use Python ${{ matrix.python }} +# uses: actions/setup-python@v2 +# with: +# python-version: ${{ matrix.python }} + +# - name: Install dependencies (npm ci) +# run: npm ci --prefer-offline + +# - name: pip install system test requirements +# run: | +# python -m pip install --upgrade -r build/test-requirements.txt +# 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 -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy +# shell: bash + +# - name: pip install smoke test requirements +# run: | +# python -m pip install --upgrade -r build/smoke-test-requirements.txt +# shell: bash + +# # Compile the test files. +# - name: Prepare for insiders tests +# run: npm run prePublish +# shell: bash + +# - name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION +# run: | +# echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV +# echo "CI_DISABLE_AUTO_SELECTION=1" >> $GITHUB_ENV +# shell: bash + +# - name: Run insider tests +# env: +# DISPLAY: 10 +# INSTALL_JUPYTER_EXTENSION: true +# INSTALL_PYLANCE_EXTENSION: true +# VSC_PYTHON_CI_TEST_VSC_CHANNEL: insiders +# TEST_FILES_SUFFIX: insiders.test +# CODE_TESTS_WORKSPACE: ./src/testMultiRootWkspc/smokeTests +# uses: GabrielBB/xvfb-action@v1.6 +# with: +# run: node --no-force-async-hooks-checks ./out/test/standardTest.js + +### Coverage run +# coverage: +# name: Coverage +# # The value of runs-on is the OS of the current job (specified in the strategy matrix below) instead of being hardcoded. +# runs-on: ${{ matrix.os }} +# strategy: +# fail-fast: false +# matrix: +# # Only run coverage on linux for PRs +# os: [ubuntu-latest] + +# steps: +# - name: Checkout +# uses: actions/checkout@v2 + +# - name: Install Node +# uses: actions/setup-node@v2 +# with: +# node-version: ${{ env.NODE_VERSION }} +# cache: 'npm' + +# - name: Install dependencies (npm ci) +# run: npm ci + +# - name: Compile +# run: npx gulp prePublishNonBundle + +# - name: Use Python ${{ env.PYTHON_VERSION }} +# uses: actions/setup-python@v2 +# with: +# python-version: ${{ env.PYTHON_VERSION }} +# cache: 'pip' +# cache-dependency-path: | +# requirements.txt +# pythonFiles/jedilsp_requirements/requirements.txt +# build/test-requirements.txt +# build/functional-test-requirements.txt + +# - name: Install Python requirements +# run: | +# python -m pip --disable-pip-version-check install --require-hashes -t ./pythonFiles/lib/python --implementation py --no-deps --upgrade -r requirements.txt --no-user +# # We need to have debugpy so that tests relying on it keep passing, but we don't need install_debugpy's logic in the test phase. +# python -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --implementation py --no-deps --upgrade --pre debugpy +# python -m pip --disable-pip-version-check install --require-hashes -t ./pythonFiles/lib/jedilsp --implementation py --no-deps --upgrade -r ./pythonFiles/jedilsp_requirements/requirements.txt + +# - name: Install test requirements +# run: python -m pip install --upgrade -r build/test-requirements.txt + +# - name: Install functional test requirements +# run: python -m pip install --upgrade -r ./build/functional-test-requirements.txt + +# - name: Prepare pipenv for venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' +# shell: pwsh +# run: | +# python -m pip install pipenv +# python -m pipenv run python ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} pipenvPath + +# - name: Prepare poetry for venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# shell: pwsh +# run: | +# python -m pip install poetry +# Move-Item -Path ".\build\ci\pyproject.toml" -Destination . +# poetry env use python + +# - name: Prepare virtualenv for venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' +# shell: pwsh +# run: | +# python -m pip install virtualenv +# python -m virtualenv .virtualenv/ +# if ('${{ matrix.os }}' -match 'windows-latest') { +# & ".virtualenv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} virtualEnvPath +# } else { +# & ".virtualenv/bin/python" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} virtualEnvPath +# } + +# - name: Prepare venv for venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' +# shell: pwsh +# run: | +# python -m venv .venv +# if ('${{ matrix.os }}' -match 'windows-latest') { +# & ".venv/Scripts/python.exe" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} venvPath +# } else { +# & ".venv/bin/python" ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} venvPath +# } + +# - name: Prepare conda for venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# PYTHON_VIRTUAL_ENVS_LOCATION: './src/tmp/envPaths.json' +# shell: pwsh +# run: | +# # 1. For `terminalActivation.testvirtualenvs.test.ts` +# if ('${{ matrix.os }}' -match 'windows-latest') { +# $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath python.exe +# $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath Scripts | Join-Path -ChildPath conda +# } else{ +# $condaPythonPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath python +# $condaExecPath = Join-Path -Path $Env:CONDA -ChildPath bin | Join-Path -ChildPath conda +# } +# & $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaExecPath $condaExecPath +# & $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath +# & $condaExecPath init --all + +# - name: Run TypeScript unit tests +# run: npm run test:unittests:cover + +# - name: Run Python unit tests +# run: | +# python pythonFiles/tests/run_all.py + +# # The virtual environment based tests use the `testSingleWorkspace` set of tests +# # with the environment variable `TEST_FILES_SUFFIX` set to `testvirtualenvs`, +# # which is set in the "Prepare environment for venv tests" step. +# # We also use a third-party GitHub Action to install xvfb on Linux, +# # run tests and then clean up the process once the tests ran. +# # See https://github.com/GabrielBB/xvfb-action +# - name: Run venv tests +# env: +# TEST_FILES_SUFFIX: testvirtualenvs +# CI_PYTHON_VERSION: ${{ env.PYTHON_VERSION }} +# CI_DISABLE_AUTO_SELECTION: 1 +# uses: GabrielBB/xvfb-action@v1.6 +# with: +# run: npm run testSingleWorkspace:cover + +# - name: Run single-workspace tests +# env: +# CI_PYTHON_VERSION: ${{ env.PYTHON_VERSION }} +# CI_DISABLE_AUTO_SELECTION: 1 +# uses: GabrielBB/xvfb-action@v1.6 +# with: +# run: npm run testSingleWorkspace:cover + +# # Enable these tests when coverage is setup for multiroot workspace tests +# # - name: Run multi-workspace tests +# # env: +# # CI_PYTHON_VERSION: ${{ env.PYTHON_VERSION }} +# # CI_DISABLE_AUTO_SELECTION: 1 +# # uses: GabrielBB/xvfb-action@v1.6 +# # with: +# # run: npm run testMultiWorkspace:cover + +# # Enable these tests when coverage is setup for debugger tests +# # - name: Run debugger tests +# # env: +# # CI_PYTHON_VERSION: ${{ env.PYTHON_VERSION }} +# # CI_DISABLE_AUTO_SELECTION: 1 +# # uses: GabrielBB/xvfb-action@v1.6 +# # with: +# # run: npm run testDebugger:cover + +# # Run TypeScript functional tests +# - name: Run TypeScript functional tests +# env: +# CI_PYTHON_VERSION: ${{ env.PYTHON_VERSION }} +# CI_DISABLE_AUTO_SELECTION: 1 +# run: npm run test:functional:cover + +# - name: Generate coverage reports +# run: npm run test:cover:report + +# - name: Upload HTML report +# uses: actions/upload-artifact@v2 +# with: +# name: ${{ runner.os }}-coverage-report-html +# path: ./coverage +# retention-days: 1 From afe70662fa322b9390f3c7bb6a02d6c3493f8148 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Sat, 29 Jan 2022 01:06:13 +0530 Subject: [PATCH 3/8] Log time taken --- .../pythonEnvironments/common/environmentManagers/conda.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/pythonEnvironments/common/environmentManagers/conda.ts b/src/client/pythonEnvironments/common/environmentManagers/conda.ts index c46246ef2017..89f0a9e89e53 100644 --- a/src/client/pythonEnvironments/common/environmentManagers/conda.ts +++ b/src/client/pythonEnvironments/common/environmentManagers/conda.ts @@ -13,6 +13,7 @@ import { cache } from '../../../common/utils/decorators'; import { isTestExecution } from '../../../common/constants'; import { traceError, traceVerbose } from '../../../logging'; import { OUTPUT_MARKER_SCRIPT } from '../../../common/process/internal/scripts'; +import { StopWatch } from '../../../common/utils/stopWatch'; export const AnacondaCompanyName = 'Anaconda, Inc.'; @@ -360,8 +361,9 @@ export class Conda { @cache(30_000, true, 10_000) // eslint-disable-next-line class-methods-use-this private async getInfoCached(command: string): Promise { + const stopWatch = new StopWatch(); const result = await exec(command, ['info', '--json'], { timeout: CONDA_GENERAL_TIMEOUT }); - traceVerbose(`conda info --json: ${result.stdout}`); + traceVerbose(`conda info --json: ${result.stdout}, time taken: ${stopWatch.elapsedTime}`); return JSON.parse(result.stdout); } From 84a0110dbca9d0e964a2462469fcd7baf93e2db0 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Sat, 29 Jan 2022 01:06:57 +0530 Subject: [PATCH 4/8] Do not trigger discovery as part of activation --- src/client/pythonEnvironments/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/pythonEnvironments/index.ts b/src/client/pythonEnvironments/index.ts index 4198075d4a71..7ca850addaa5 100644 --- a/src/client/pythonEnvironments/index.ts +++ b/src/client/pythonEnvironments/index.ts @@ -52,7 +52,7 @@ export async function initialize(ext: ExtensionState): Promise { /** * Make use of the component (e.g. register with VS Code). */ -export async function activate(api: IDiscoveryAPI, _ext: ExtensionState): Promise { +export async function activate(_api: IDiscoveryAPI, _ext: ExtensionState): Promise { /** * Force an initial background refresh of the environments. * @@ -65,7 +65,7 @@ export async function activate(api: IDiscoveryAPI, _ext: ExtensionState): Promis * Once `onInterpretersChanged` event is exposed via API, we can probably expect extensions to rely on that and * discovery can be triggered after activation, especially in the second case. */ - api.triggerRefresh().ignoreErrors(); + // api.triggerRefresh().ignoreErrors(); return { fullyReady: Promise.resolve(), From 067ad2f9f69908b87729d789245bf59efa31f081 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Sat, 29 Jan 2022 01:24:01 +0530 Subject: [PATCH 5/8] Revert "Do not trigger discovery as part of activation" This reverts commit 84a0110dbca9d0e964a2462469fcd7baf93e2db0. --- src/client/pythonEnvironments/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/pythonEnvironments/index.ts b/src/client/pythonEnvironments/index.ts index 7ca850addaa5..4198075d4a71 100644 --- a/src/client/pythonEnvironments/index.ts +++ b/src/client/pythonEnvironments/index.ts @@ -52,7 +52,7 @@ export async function initialize(ext: ExtensionState): Promise { /** * Make use of the component (e.g. register with VS Code). */ -export async function activate(_api: IDiscoveryAPI, _ext: ExtensionState): Promise { +export async function activate(api: IDiscoveryAPI, _ext: ExtensionState): Promise { /** * Force an initial background refresh of the environments. * @@ -65,7 +65,7 @@ export async function activate(_api: IDiscoveryAPI, _ext: ExtensionState): Promi * Once `onInterpretersChanged` event is exposed via API, we can probably expect extensions to rely on that and * discovery can be triggered after activation, especially in the second case. */ - // api.triggerRefresh().ignoreErrors(); + api.triggerRefresh().ignoreErrors(); return { fullyReady: Promise.resolve(), From 838815d53e41d446b57914e28dc931fe799bd622 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Wed, 23 Feb 2022 17:29:15 +0530 Subject: [PATCH 6/8] Cache output of `conda info --json` for session --- .../pythonEnvironments/common/environmentManagers/conda.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/pythonEnvironments/common/environmentManagers/conda.ts b/src/client/pythonEnvironments/common/environmentManagers/conda.ts index 89f0a9e89e53..75f9e6ce7997 100644 --- a/src/client/pythonEnvironments/common/environmentManagers/conda.ts +++ b/src/client/pythonEnvironments/common/environmentManagers/conda.ts @@ -358,7 +358,7 @@ export class Conda { /** * Cache result for this particular command. */ - @cache(30_000, true, 10_000) + @cache(-1, true) // eslint-disable-next-line class-methods-use-this private async getInfoCached(command: string): Promise { const stopWatch = new StopWatch(); From d6b888229ed087040e70c0bb2956cb92d5dbeeee Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 10 Mar 2022 19:27:33 +0530 Subject: [PATCH 7/8] Ensure we start discovery after language server is started --- src/client/activation/activationService.ts | 7 +++++-- src/client/pythonEnvironments/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/client/activation/activationService.ts b/src/client/activation/activationService.ts index 02ed57689cde..af86af37dde8 100644 --- a/src/client/activation/activationService.ts +++ b/src/client/activation/activationService.ts @@ -15,7 +15,7 @@ import { } from '../common/types'; import { swallowExceptions } from '../common/utils/decorators'; import { LanguageService } from '../common/utils/localize'; -import { IInterpreterService } from '../interpreter/contracts'; +import { IComponentAdapter, IInterpreterService } from '../interpreter/contracts'; import { IServiceContainer } from '../ioc/types'; import { PythonEnvironment } from '../pythonEnvironments/info'; import { sendTelemetryEvent } from '../telemetry'; @@ -29,7 +29,7 @@ import { LanguageServerType, } from './types'; import { StopWatch } from '../common/utils/stopWatch'; -import { traceError, traceLog } from '../logging'; +import { traceError, traceLog, traceVerbose } from '../logging'; const languageServerSetting: keyof IPythonSettings = 'languageServer'; const workspacePathNameForGlobalWorkspaces = ''; @@ -132,9 +132,12 @@ export class LanguageServerExtensionActivationService // Force this server to reconnect (if disconnected) as it should be the active // language server for all of VS code. this.activatedServer.server.activate(); + traceVerbose('Time taken to start language server', stopWatch.elapsedTime); sendTelemetryEvent(EventName.PYTHON_LANGUAGE_SERVER_STARTUP_DURATION, stopWatch.elapsedTime, { languageServerType: result.type, }); + const pyenvs = this.serviceContainer.get(IComponentAdapter); + pyenvs.triggerRefresh().ignoreErrors(); } public async get(resource: Resource, interpreter?: PythonEnvironment): Promise { diff --git a/src/client/pythonEnvironments/index.ts b/src/client/pythonEnvironments/index.ts index 4198075d4a71..e6f93bd6cbc9 100644 --- a/src/client/pythonEnvironments/index.ts +++ b/src/client/pythonEnvironments/index.ts @@ -52,7 +52,7 @@ export async function initialize(ext: ExtensionState): Promise { /** * Make use of the component (e.g. register with VS Code). */ -export async function activate(api: IDiscoveryAPI, _ext: ExtensionState): Promise { +export async function activate(_: IDiscoveryAPI, _ext: ExtensionState): Promise { /** * Force an initial background refresh of the environments. * @@ -65,7 +65,7 @@ export async function activate(api: IDiscoveryAPI, _ext: ExtensionState): Promis * Once `onInterpretersChanged` event is exposed via API, we can probably expect extensions to rely on that and * discovery can be triggered after activation, especially in the second case. */ - api.triggerRefresh().ignoreErrors(); + // api.triggerRefresh().ignoreErrors(); return { fullyReady: Promise.resolve(), From 2804feb857459b988e0f9c8049858a94d04198f3 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 10 Mar 2022 20:45:06 +0530 Subject: [PATCH 8/8] Add option to force using cache in conda.ts --- .../base/locators/composite/envsResolver.ts | 51 ++++++++++--------- .../common/environmentManagers/conda.ts | 12 +++-- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/client/pythonEnvironments/base/locators/composite/envsResolver.ts b/src/client/pythonEnvironments/base/locators/composite/envsResolver.ts index e7c09c0aab91..5dd1518a36f9 100644 --- a/src/client/pythonEnvironments/base/locators/composite/envsResolver.ts +++ b/src/client/pythonEnvironments/base/locators/composite/envsResolver.ts @@ -74,9 +74,10 @@ export class PythonEnvsResolver implements IResolvingLocator { 'Unsupported behavior: `undefined` environment updates are not supported from downstream locators in resolver', ); } else if (seen[event.index] !== undefined) { - // const old = seen[event.index]; + const old = seen[event.index]; seen[event.index] = await resolveBasicEnv(event.update); - // this.resolveInBackground(event.index, state, didUpdate, seen).ignoreErrors(); + didUpdate.fire({ old, index: event.index, update: seen[event.index] }); + this.resolveInBackground(event.index, state, didUpdate, seen).ignoreErrors(); } else { // This implies a problem in a downstream locator traceVerbose(`Expected already iterated env, got ${event.old} (#${event.index})`); @@ -91,7 +92,7 @@ export class PythonEnvsResolver implements IResolvingLocator { const currEnv = await resolveBasicEnv(result.value); seen.push(currEnv); yield currEnv; - // this.resolveInBackground(seen.indexOf(currEnv), state, didUpdate, seen).ignoreErrors(); + this.resolveInBackground(seen.indexOf(currEnv), state, didUpdate, seen).ignoreErrors(); result = await iterator.next(); } if (iterator.onUpdated === undefined) { @@ -100,28 +101,28 @@ export class PythonEnvsResolver implements IResolvingLocator { } } - // private async resolveInBackground( - // envIndex: number, - // state: { done: boolean; pending: number }, - // didUpdate: EventEmitter, - // seen: PythonEnvInfo[], - // ) { - // state.pending += 1; - // // It's essential we increment the pending call count before any asynchronus calls in this method. - // // We want this to be run even when `resolveInBackground` is called in background. - // const info = await this.environmentInfoService.getEnvironmentInfo(seen[envIndex]); - // const old = seen[envIndex]; - // if (info) { - // const resolvedEnv = getResolvedEnv(info, seen[envIndex]); - // seen[envIndex] = resolvedEnv; - // didUpdate.fire({ old, index: envIndex, update: resolvedEnv }); - // } else { - // // Send update that the environment is not valid. - // didUpdate.fire({ old, index: envIndex, update: undefined }); - // } - // state.pending -= 1; - // checkIfFinishedAndNotify(state, didUpdate); - // } + private async resolveInBackground( + envIndex: number, + state: { done: boolean; pending: number }, + didUpdate: EventEmitter, + seen: PythonEnvInfo[], + ) { + state.pending += 1; + // It's essential we increment the pending call count before any asynchronus calls in this method. + // We want this to be run even when `resolveInBackground` is called in background. + const info = await this.environmentInfoService.getEnvironmentInfo(seen[envIndex]); + const old = seen[envIndex]; + if (info) { + const resolvedEnv = getResolvedEnv(info, seen[envIndex]); + seen[envIndex] = resolvedEnv; + didUpdate.fire({ old, index: envIndex, update: resolvedEnv }); + } else { + // Send update that the environment is not valid. + didUpdate.fire({ old, index: envIndex, update: undefined }); + } + state.pending -= 1; + checkIfFinishedAndNotify(state, didUpdate); + } } /** diff --git a/src/client/pythonEnvironments/common/environmentManagers/conda.ts b/src/client/pythonEnvironments/common/environmentManagers/conda.ts index 0ecb0b83fca9..c401c90dd733 100644 --- a/src/client/pythonEnvironments/common/environmentManagers/conda.ts +++ b/src/client/pythonEnvironments/common/environmentManagers/conda.ts @@ -217,6 +217,8 @@ export class Conda { */ private static condaPromise: Promise | undefined; + private condaInfo: Promise | undefined; + /** * Creates a Conda service corresponding to the corresponding "conda" command. * @@ -351,8 +353,12 @@ export class Conda { * Retrieves global information about this conda. * Corresponds to "conda info --json". */ - public async getInfo(): Promise { - return this.getInfoCached(this.command); + public async getInfo(useCache?: boolean): Promise { + if (useCache && this.condaInfo) { + return this.condaInfo; + } + this.condaInfo = this.getInfoFromTemporaryCache(this.command); + return this.condaInfo; } /** @@ -360,7 +366,7 @@ export class Conda { */ @cache(-1, true) // eslint-disable-next-line class-methods-use-this - private async getInfoCached(command: string): Promise { + private async getInfoFromTemporaryCache(command: string): Promise { const stopWatch = new StopWatch(); const result = await exec(command, ['info', '--json'], { timeout: CONDA_GENERAL_TIMEOUT }); traceVerbose(`conda info --json: ${result.stdout}, time taken: ${stopWatch.elapsedTime}`);