Skip to content

Conversation

dulinriley
Copy link
Contributor

Summary:
The pytest-isolate package can support both pytest-timeout and pytest-forked,
to run each test in a separate process.
This should help prevent cross-contamination (one test affects a second test), as well
as preventing tests with fatal signals from taking down the whole test run.

Differential Revision: D84636534

Copy link

meta-codesync bot commented Oct 14, 2025

@dulinriley has exported this pull request. If you are a Meta employee, you can view the originating Diff in D84636534.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 14, 2025
@dulinriley dulinriley self-assigned this Oct 14, 2025
dulinriley added a commit to dulinriley/monarch that referenced this pull request Oct 14, 2025
Summary:

The pytest-isolate package can support both pytest-timeout and pytest-forked,
to run each test in a separate process.
This should help prevent cross-contamination (one test affects a second test), as well
as preventing tests with fatal signals from taking down the whole test run.
It requires pytest-timeout to *not* be installed, or else that will take precedence.

https://pypi.org/project/pytest-isolate/

Differential Revision: D84636534
@dulinriley dulinriley force-pushed the export-D84636534 branch 2 times, most recently from 6b254d1 to 24db257 Compare October 14, 2025 21:33
dulinriley added a commit to dulinriley/monarch that referenced this pull request Oct 14, 2025
Summary:

The pytest-isolate package can support both pytest-timeout and pytest-forked,
to run each test in a separate process.
This should help prevent cross-contamination (one test affects a second test), as well
as preventing tests with fatal signals from taking down the whole test run.
It requires pytest-timeout to *not* be installed, or else that will take precedence.

https://pypi.org/project/pytest-isolate/

Differential Revision: D84636534
Summary:

The pytest-isolate package can support both pytest-timeout and pytest-forked,
to run each test in a separate process.
This should help prevent cross-contamination (one test affects a second test), as well
as preventing tests with fatal signals from taking down the whole test run.
It requires pytest-timeout to *not* be installed, or else that will take precedence.

Since this slows down tests, but makes them easier to reproduce, we can turn on `-n auto`
to run them in parallel.

https://pypi.org/project/pytest-isolate/

Differential Revision: D84636534
@dulinriley
Copy link
Contributor Author

We won't be able to use this at the moment, or other plugins like pytest-forked, with GPU code:

RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method

We'll either need to change that plugin to use "spawn" instead of "fork", or make our own plugin.
So for now this will not be a good way to get to more reliable pytests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant