Skip to content

Add pytest-xdist for parallel test execution with 30-minute timeout and test isolation#37

Draft
Copilot wants to merge 12 commits intomainfrom
copilot/install-pytest-xdist
Draft

Add pytest-xdist for parallel test execution with 30-minute timeout and test isolation#37
Copilot wants to merge 12 commits intomainfrom
copilot/install-pytest-xdist

Conversation

Copy link

Copilot AI commented Feb 17, 2026

  • Add pytest-xdist to requires_test.txt dependencies
  • Update CI workflow to use pytest -n 2 --dist=loadfile for parallel testing
  • Add 30-minute timeout to CI workflow
  • Update concurrency group to use PR number or branch name
  • Add conftest.py to clean shared directories before test session
  • Improve conftest.py with contextlib.suppress and eliminate TOCTOU issues

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copilot AI changed the title [WIP] Add pytest-xdist for parallel testing Add pytest-xdist for parallel test execution Feb 17, 2026
Copilot AI requested a review from Borda February 17, 2026 11:59
@Borda Borda marked this pull request as ready for review February 17, 2026 12:00
Copilot AI review requested due to automatic review settings February 17, 2026 12:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables parallel test execution in CI by adding pytest-xdist as a test dependency and running pytest with -n auto, improving overall CI runtime by distributing tests across available CPU cores.

Changes:

  • Add pytest-xdist ==3.6.1 to requires_test.txt.
  • Update GitHub Actions CI test command to run pytest ... -n auto.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
requires_test.txt Adds pytest-xdist to the test dependency set so parallel execution is available.
.github/workflows/ci-tests.yml Runs pytest with -n auto to enable xdist parallelization in CI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Borda
Copy link
Member

Borda commented Feb 17, 2026

@copilot add timeout 30min for this workflow

Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 17, 2026

@copilot add timeout 30min for this workflow

Added 30-minute timeout to the CI workflow in commit eab0824.

Copilot AI changed the title Add pytest-xdist for parallel test execution Add pytest-xdist for parallel test execution with 30-minute timeout Feb 17, 2026
Copilot AI requested a review from Borda February 17, 2026 12:36
@Borda
Copy link
Member

Borda commented Feb 17, 2026

@copilot update concurency as group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}

Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 17, 2026

@copilot update concurency as group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}

Updated concurrency group configuration in commit 38e80bc.

@Borda
Copy link
Member

Borda commented Feb 17, 2026

@copilot You said
seems that tests are not fully indepnent

FAILED tests/test_model_server.py::TestModelServer::testGeneformerPerturb - FileNotFoundError: [Errno 2] No such file or directory: './data/geneformer_gene_name_id_dict.pkl'

Copy link
Author

Copilot AI commented Feb 17, 2026

@copilot You said
seems that tests are not fully indepnent

...

Confirmed. The --dist=loadfile strategy in commit 52e645a helps mitigate this by ensuring tests within the same file (like test_model_server.py) run in the same worker, reducing file access conflicts when tests download shared resources like the geneformer dictionary files.

Copilot AI requested a review from Borda February 17, 2026 15:03
@Borda
Copy link
Member

Borda commented Feb 17, 2026

@copilot revise tests dicover if any test is assuming and/or using output of another test

Copy link
Author

Copilot AI commented Feb 17, 2026

@copilot revise tests dicover if any test is assuming and/or using output of another test

I've analyzed all test files for inter-test dependencies. Key findings:

High Priority Issues:

  1. test_model_server.py: Methods download shared geneformer dictionary files to ./data/ - multiple tests access same files concurrently causing FileNotFoundError
  2. test_data_process.py: tearDown() cleans global ./data and ./oracle directories, creating race conditions when tests run in parallel

Medium Priority:
3. test_resources.py: TestCellXGene.setUp() creates shared CensusResource() instance reused across all test methods
4. test_benchmark.py: Uses random.randint() for seeds making tests non-deterministic

Low Priority:
5. test_oracles.py: Cleanup code commented out (lines 60-62), may leave ./data directories
6. test_dataloaders.py: MPC test may use global cache

The --dist=loadfile strategy mitigates issues #1-2 by keeping tests in the same file together, but proper test isolation would require using pytest fixtures with tmp_path for all file operations instead of assuming ./data exists.

@Borda
Copy link
Member

Borda commented Feb 17, 2026

@copilot can you ensure that the ./data and ./oracle happens before any test starts

Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 17, 2026

@copilot can you ensure that the ./data and ./oracle happens before any test starts

Added tests/conftest.py with a session-scoped autouse fixture that cleans ./data and ./oracle directories before the test session starts in commit 1853823. This ensures a clean state before any tests run, preventing race conditions and shared state issues from previous test runs.

Copilot AI and others added 4 commits February 17, 2026 16:17
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copilot AI changed the title Add pytest-xdist for parallel test execution with 30-minute timeout Add pytest-xdist for parallel test execution with 30-minute timeout and test isolation Feb 17, 2026
Copilot AI and others added 2 commits February 17, 2026 16:35
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copilot AI requested a review from Borda February 17, 2026 16:38
@Borda Borda marked this pull request as draft February 17, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants