Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document steps to debug tests with vscode #12459

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dholth
Copy link
Contributor

@dholth dholth commented Mar 7, 2023

Description

These are the steps I had to follow to debug with vscode.

Please try them out, and let me know what I've missed -- my system is already set up to do this, and there might be a few more hurdles to jump before vscode agrees to work.

Tests may be a lot easier to run than before, now that we have removed the "raises SystemExit for menuinst reasons, when tests are not run in a base environment" error.

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@dholth dholth requested a review from a team as a code owner March 7, 2023 18:20
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Mar 7, 2023
@travishathaway travishathaway added the source::anaconda created by members of Anaconda, Inc. label Mar 13, 2023
5. Conda's tests really want to run under the under-develoment version of conda,
and may refuse to run at all otherwise. Add or edit `"python.condaPath":
"(full path to conda in development environment)",`.
> On my system, this can be found with `conda info`: `base
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use "on my system" here? Are we mentioning somewhere in the docs who the author of this guide is?

Copy link
Contributor

@kathatherine kathatherine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments and edits from someone who's never done this before. Wasn't quite able to finish either, but I'll double check the last few instructions when my initial questions are answered.

1. In a conda checkout, run `. dev/start -p 3.10` to enter a Python 3.10 (or the
version you want to test) development environment.
2. Open VSCode from this terminal `code`.
> If `code` is not available, press `⌘-P`, `Shell` to find the `Install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it command + P? That opens a print dialog for me. I'm a bit stumped on these extra instructions, though I can open VSCode manually in order to continue looking at the rest of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to point to the menu item than the shortcut

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be more straightforward for newbies and anyone who knows how to open VSCode already via the CLI could do so if they wished.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me what works is shift + ⌘ + P (at which point I can type in shell command and that brings up Install 'code' command in PATH)

2. Open VSCode from this terminal `code`.
> If `code` is not available, press `⌘-P`, `Shell` to find the `Install
> 'code' command in PATH` action.
3. Ensure you have installed the `Python` extension.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe specify "in VSCode" at the end. Even though I'm in VSCode and following these instructions, my brain went blank for a second when I tried to figure out what "extension" meant in this context.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to even include a link to the Python extension being referred to. I'm assuming it's this one? https://marketplace.visualstudio.com/items?itemName=ms-python.python

(JSON)` (the paper icon with an arrow on it, above the settings editor).
5. Conda's tests really want to run under the under-develoment version of conda,
and may refuse to run at all otherwise. Add or edit `"python.condaPath":
"(full path to conda in development environment)",`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a placeholder standard for code snippets? In the Anaconda docs, we do <ALL-CAPS-PLACEHOLDER>, but that's pretty aggressive for a full sentence. Maybe:

"python.condaPath": "<full path to conda in your development environment>"

Copy link
Contributor

@kathatherine kathatherine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple more notes and suggestions from my testing of these instructions.

3. Ensure you have installed the `Python` extension.
4. Open settings (the gear icon in the lower left corner). Go to `Open Settings
(JSON)` (the paper icon with an arrow on it, above the settings editor).
5. Conda's tests really want to run under the under-develoment version of conda,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not positive about this, but I removed the python.condaPath from my settings.json, but made sure my python interpreter path was the dev environment bin and the tests worked fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great news, since having to change the global conda path is a nuisance.

Co-authored-by: Katherine Kinnaman <kkinnaman@anaconda.com>
> /Users/dholth/prog/conda/devenv/Darwin/arm64/envs/devenv-3.10-c`, plus
> `/bin/conda`, so the full setting is `"python.condaPath":
> "/Users/dholth/prog/conda/devenv/Darwin/arm64/envs/devenv-3.10-c/bin/conda",`
6. Press the Erlenmeyer flask 'Testing' icon in the VSCode toolbar. If necessary, click 'Configure Tests', then choose "pytest" as your framework and "Root directory" as your test directory.
Copy link
Contributor

@beeankha beeankha Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be helpful to include a link to the VSCode documentation for "Configure Tests"

Suggested change
6. Press the Erlenmeyer flask 'Testing' icon in the VSCode toolbar. If necessary, click 'Configure Tests', then choose "pytest" as your framework and "Root directory" as your test directory.
6. Press the Erlenmeyer flask 'Testing' icon in the VSCode toolbar. If necessary, click ['Configure Tests'](https://code.visualstudio.com/docs/python/testing#_configure-tests), then choose "pytest" as your framework and "Root directory" as your test directory.

> `/bin/conda`, so the full setting is `"python.condaPath":
> "/Users/dholth/prog/conda/devenv/Darwin/arm64/envs/devenv-3.10-c/bin/conda",`
6. Press the Erlenmeyer flask 'Testing' icon in the VSCode toolbar. If necessary, click 'Configure Tests', then choose "pytest" as your framework and "Root directory" as your test directory.
> To reconfigure your tests, use the Command Palette to search for "Python: Configure Tests".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> To reconfigure your tests, use the Command Palette to search for "Python: Configure Tests".
> To reconfigure your tests, use the Command Palette (`shift + ⌘ + P`) to search for "Python: Configure Tests".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA source::anaconda created by members of Anaconda, Inc.
Projects
Status: 🏗️ In Progress
Development

Successfully merging this pull request may close these issues.

None yet

6 participants