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

Add hook to vscode_pytest to determine number xdist workers to use based on count of selected tests #23539

Merged
merged 9 commits into from
Jun 20, 2024

Conversation

DetachHead
Copy link

@karthiknadig
Copy link
Member

@DetachHead Thanks for the fix. It looks like this is causing test failures. Let me know if you are able to address these.

@DetachHead
Copy link
Author

@karthiknadig would you be able to point me to some documentation for how to set up this project for local development? i tried using the devcontainer but i can't get docker to work on my PC unfortunately, so i wasn't able to debug the tests

@eleanorjboyd
Copy link
Member

Hi @DetachHead, here are the steps to getting started, these are how I set up my dev environment so hopefully that will work for you too! To debug those tests you should be able to use the testing panel to run / debug the tests, let me know if it isn't working or is confusing and I can provide some extra direction. Thanks!!

@DetachHead DetachHead force-pushed the pytest-xdist-num-workers branch 2 times, most recently from 2f1a5a5 to 1f6fa68 Compare June 18, 2024 06:58
…ers to use based on how many tests are selected
@DetachHead
Copy link
Author

i got the tests passing, but i have no idea what's up with the formatter. i tried formatting it with ruff and it made a bunch of changes to code i didn't touch. (i also tried black because the wiki said so before i realized that the CI uses ruff, does that need to be updated to say ruff instead?)

ideally ruff should be a dev dependency of this project, and there would be committed vscode config to make it format on save to match what the CI would do.

@karthiknadig
Copy link
Member

@DetachHead sorry about that. i will fix the formatting. We have a debt item to update both linting and formatting to ruff with config added to repo. We are mid transition.

@DetachHead DetachHead force-pushed the pytest-xdist-num-workers branch 2 times, most recently from 50dd822 to f2648de Compare June 18, 2024 08:54
…to_num_workers` hook because the `pytest_configure` hook didn't work for some reason
@karthiknadig karthiknadig enabled auto-merge (squash) June 19, 2024 22:58
@karthiknadig karthiknadig changed the title add hook to the pytest vscode plugin to determine how many xdist workers to use based on how many tests are selected Add hook to vscode_pytest to determine number xdist workers to use based on count of selected tests Jun 19, 2024
@karthiknadig karthiknadig enabled auto-merge (squash) June 19, 2024 23:00
karthiknadig
karthiknadig previously approved these changes Jun 19, 2024
@DetachHead
Copy link
Author

DetachHead commented Jun 20, 2024

so i just realized that this will crash if the user runs pytest with -p no:xdist. as far as i know there doesn't seem to be a good way to conditionally define this hook. i raised an issue for it here: pytest-dev/pytest-xdist#1102

any ideas on how to work around this? if not, i'm happy to close this PR and try again once that issue is resolved.

auto-merge was automatically disabled June 20, 2024 01:30

Head branch was pushed to by a user without write access

@DetachHead
Copy link
Author

nvm, i got it working

anthonykim1
anthonykim1 previously approved these changes Jun 20, 2024
@karthiknadig karthiknadig merged commit d079322 into microsoft:main Jun 20, 2024
40 checks passed
DonJayamanne pushed a commit that referenced this pull request Jun 24, 2024
…e based on count of selected tests (#23539)

fixes microsoft/vscode-python-debugger#336

---------

Co-authored-by: detachhead <detachhead@users.noreply.github.com>
Co-authored-by: Karthik Nadig <kanadig@microsoft.com>
eleanorjboyd pushed a commit to eleanorjboyd/vscode-python that referenced this pull request Jun 28, 2024
…e based on count of selected tests (microsoft#23539)

fixes microsoft/vscode-python-debugger#336

---------

Co-authored-by: detachhead <detachhead@users.noreply.github.com>
Co-authored-by: Karthik Nadig <kanadig@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pytest xdist should run with -n0 in debug
4 participants