Skip to content

Dev.ej/address pytest warnings#781

Merged
joanise merged 9 commits intomainfrom
dev.ej/address-pytest-warnings
Mar 24, 2026
Merged

Dev.ej/address pytest warnings#781
joanise merged 9 commits intomainfrom
dev.ej/address-pytest-warnings

Conversation

@joanise
Copy link
Copy Markdown
Member

@joanise joanise commented Mar 19, 2026

PR Goal?

Make it friendly to use pytest as the driver for EveryVoice, by handling the warnings it outputs. They were pointing out real issues, afterall... :)

@marctessier, you're going to like this:

$ pytest
======================================== test session starts =========================================
platform linux -- Python 3.10.17, pytest-7.4.4, pluggy-1.6.0
rootdir: /gpfs/fs3c/nrc/ict/portage/u/joa125/EveryVoice/EveryVoice
configfile: pyproject.toml
testpaths: everyvoice/tests, everyvoice/model/feature_prediction/FastSpeech2_lightning/fs2/tests, everyvoice/model/aligner/wav2vec2aligner/aligner/tests
plugins: anyio-4.9.0
collected 289 items

everyvoice/tests/test_cli.py .......................                                           [  7%]
everyvoice/tests/test_configs.py .......................                                       [ 15%]
everyvoice/tests/test_custom_g2p.py ................                                           [ 21%]
everyvoice/tests/test_dataloader.py ........                                                   [ 24%]
everyvoice/tests/test_doctests.py .                                                            [ 24%]
everyvoice/tests/test_evaluation.py .                                                          [ 24%]
everyvoice/tests/test_model.py ...........                                                     [ 28%]
everyvoice/tests/test_preprocessing.py ...........................................             [ 43%]
everyvoice/tests/test_subsample.py .....                                                       [ 45%]
everyvoice/tests/test_text.py ..............................                                   [ 55%]
everyvoice/tests/test_utils.py .....................                                           [ 62%]
everyvoice/tests/test_wizard.py ...................................................            [ 80%]
everyvoice/tests/test_wizard_helpers.py ........                                               [ 83%]
everyvoice/model/feature_prediction/FastSpeech2_lightning/fs2/tests/test_chunking.py ......    [ 85%]
everyvoice/model/feature_prediction/FastSpeech2_lightning/fs2/tests/test_cli.py .............. [ 90%]
.....                                                                                          [ 92%]
everyvoice/model/feature_prediction/FastSpeech2_lightning/fs2/tests/test_loading.py ........   [ 94%]
everyvoice/model/feature_prediction/FastSpeech2_lightning/fs2/tests/test_writing_callbacks.py . [ 95%]
.........                                                                                      [ 98%]
everyvoice/model/aligner/wav2vec2aligner/aligner/tests/test_cli.py .s...                       [100%]

========================================== warnings summary ==========================================
../../../../../../../../../fs/hestia_Hnrc/ict/joa125/uvenvs/ev-py310/lib/python3.10/site-packages/websockets/legacy/__init__.py:6
  /fs/hestia_Hnrc/ict/joa125/uvenvs/ev-py310/lib/python3.10/site-packages/websockets/legacy/__init__.py:6: DeprecationWarning: websockets.legacy is deprecated; see https://websockets.readthedocs.io/en/stable/howto/upgrade.html for upgrade instructions
    warnings.warn(  # deprecated in 14.0 - 2024-11-09

everyvoice/tests/test_cli.py: 3 warnings
everyvoice/tests/test_model.py: 6 warnings
everyvoice/tests/test_utils.py: 1 warning
everyvoice/model/feature_prediction/FastSpeech2_lightning/fs2/tests/test_chunking.py: 6 warnings
everyvoice/model/feature_prediction/FastSpeech2_lightning/fs2/tests/test_cli.py: 1 warning
everyvoice/model/feature_prediction/FastSpeech2_lightning/fs2/tests/test_loading.py: 3 warnings
everyvoice/model/feature_prediction/FastSpeech2_lightning/fs2/tests/test_writing_callbacks.py: 2 warnings
  /fs/hestia_Hnrc/ict/joa125/uvenvs/ev-py310/lib/python3.10/site-packages/torch/cuda/__init__.py:789: UserWarning: Can't initialize NVML
    warnings.warn("Can't initialize NVML")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
====================== 288 passed, 1 skipped, 23 warnings in 252.67s (0:04:12) =======================

Note: it sits on collecting 0 items for a long time. That's normal: it's the time it takes to import all our torch and other expensive dependencies.

Fixes?

Some warnings pytest told me about, and errors that made pytest fail altogether.

Fixes #573

Feedback sought?

make sure it runs right for you too.

Note that most of the diff is for the schemas and the Pydantic fields with non-string defaults. That's because pytest complained about the way we had them before, and so that pushed me to fix them.

@SamuelLarkin Please have a look at the changes I made to Pydantic-validated directories. My original changes brought back the darn bug where running the tests creates logs_and_checkpoints and preprocessed in the directory where you run them. What I understand is that when Pydantic validates a PossiblyRelativePathMustExist, it creates the directory, so I deliberately set validate_default=False on this one. You had Path("dirname") as the default before, which did not require validation. I now have "dirname" instead, because Path() is not json-serializable on Windows. So I resorted to # type: ignore[assignment] to shut mypy up without creating the folders when we don't want them. This makes me wonder if we should not create those folders when we're about to write into them instead of during validation... In fact, this is also the cause behind #478 and #740, so we might want to make the change, sadly undoing the hard work you did to make it happen during validation.

Priority?

normal

How to test?

Redo pip install -e .[dev], or just do pip install pytest, then run:

pytest

To run a single test file:

pytest everyvoice/tests/test_cli.py

To run a single test class or case, add ::ClassName and maybe also ::test_function_name:

pytest everyvoice/tests/test_cli.py::CLITest::test_create_demo_app

When pytest issues a warning or an error message for a given test, it conveniently gives you this string in its output that you can cut and paste.

Confidence?

high

Related PRs?

EveryVoiceTTS/HiFiGAN_iSTFT_lightning#59

@joanise joanise requested a review from marctessier March 19, 2026 13:39
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com bot commented Mar 19, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  everyvoice/config/preprocessing_config.py  54% smaller
  everyvoice/config/text_config.py  43% smaller
  everyvoice/config/shared_types.py  34% smaller
  everyvoice/tests/stubs.py  1% smaller
  README.md Unsupported file format
  everyvoice/.schema/everyvoice-shared-data-0.4.json  0% smaller
  everyvoice/.schema/everyvoice-shared-text-0.4.json  0% smaller
  everyvoice/.schema/everyvoice-spec-to-wav-0.4.json  0% smaller
  everyvoice/.schema/everyvoice-text-to-spec-0.4.json  0% smaller
  everyvoice/.schema/everyvoice-text-to-wav-0.4.json  0% smaller
  everyvoice/model/vocoder/HiFiGAN_iSTFT_lightning  0% smaller
  everyvoice/tests/regression/prep-datasets.sh Unsupported file format
  everyvoice/tests/test_wizard.py  0% smaller
  make-everyvoice-env Unsupported file format
  pyproject.toml Unsupported file format

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

CLI load time: 0:00.25
Pull Request HEAD: faad89cc19c84cab5d3ddec416b9e339834a98c9
Imports that take more than 0.1 s:
import time: self [us] | cumulative | imported package
import time:      9976 |     141538 | everyvoice.cli

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.98%. Comparing base (60b1b21) to head (faad89c).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #781   +/-   ##
=======================================
  Coverage   82.97%   82.98%           
=======================================
  Files          47       47           
  Lines        4153     4154    +1     
  Branches      611      611           
=======================================
+ Hits         3446     3447    +1     
  Misses        575      575           
  Partials      132      132           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joanise joanise force-pushed the dev.ej/address-pytest-warnings branch from 055b08c to 3aa49e6 Compare March 19, 2026 20:34
Copy link
Copy Markdown
Collaborator

@marctessier marctessier left a comment

Choose a reason for hiding this comment

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

Awesome, looking forward for this to be the default.

Base automatically changed from dev.ej/windows-compat to main March 24, 2026 13:17
joanise and others added 9 commits March 24, 2026 09:34
When a pydantic field is a class, its default should still be a string
so it can be included in the schemas, but we should request it be
validated with `validate_default=True` so it gets converted correctly by
the before validator.
silence_c_stderr and silence_c_stdout are incompatible with pytest: pytest
already captures thoses streams, and if we try to do it, we just cause tests to
fail. But since pytest does this already, and more reliably, we no longer need
to do it!  Yay!!!
Squashing:
 - build(deps): upgrade matplotlib and remove restriction on numpy
 - build(deps): add pytest to test dependencies
 - fix(build): on Windows, we need questionary>=2
 - fix(build): lock chardet<6 to make requests happy (Fixes #782)
@joanise joanise force-pushed the dev.ej/address-pytest-warnings branch from a95db3a to faad89c Compare March 24, 2026 13:44
@joanise joanise merged commit 3456d53 into main Mar 24, 2026
13 checks passed
@joanise joanise deleted the dev.ej/address-pytest-warnings branch March 24, 2026 14:40
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.

Simplify the output of -->everyvoice/run_tests.py all

2 participants