Update python environment and dependencies - #1065
Open
natbutter wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Update Python Environment, Dependencies, and Migrate to Pydantic v2
Description
This pull request modernizes the codebase by upgrading the minimum Python version requirement, bumping major library dependencies, upgrading FastAPI and Uvicorn, and migrating the web app validation layer from Pydantic v1 to Pydantic v2. It also fixes a minor filename casing mismatch in the test assertions to ensure the test suite runs and passes successfully.
Motivation & Context
>=3.8,<3.12. By bumping the minimum requirement to>=3.10, we can take advantage of modern Python features (e.g., union type hints|instead ofUnion, improved performance, and cleaner syntax) and support newer versions of key scientific libraries.numpy,scipy,matplotlib,Pillow, etc.) to their latest compatible versions to address potential security vulnerabilities, gain performance improvements, and ensure compatibility with newer Python runtimes.~=0.88.0to~=0.138.1and Uvicorn from~=0.20.0to~=0.49.0. This necessitated a migration ofwebapp/main.pyvalidation models from Pydantic v1 to Pydantic v2. Pydantic v2 offers massive speedups in validation serialization and cleaner APIs, but comes with breaking changes in validator decorators and field configuration.FixedBandEq.txtandParametricEq.txtwhile the batch processing code actually generatesFixedBandEQ.txtandParametricEQ.txt.Detailed Changes
1. Python Environment & Library Upgrades
In
pyproject.toml:Requires-Python = ">=3.8,<3.12"toRequires-Python = ">=3.10".Pillow:~=10.0.1→~=12.2.0matplotlib:~=3.7.3→~=3.11.0scipy:~=1.10.1→~=1.18.0numpy:~=1.24.4→~=2.5.0tabulate:~=0.9.0→~=0.10.0soundfile:~=0.12.1→~=0.14.0pyyaml:~=6.0→~=6.0.3tqdm:~=4.66.1→~=4.68.3In
webapp/requirements.txt:fastapito~=0.138.1anduvicorn[standard]to~=0.49.0.2. Pydantic v2 Migration in Web App
In
webapp/main.py:validator,root_validator,confloat,conlist) with Pydantic v2 equivalents (Field,field_validator,model_validator).confloat(ge=0.0, le=0.5)) to v2Fieldlimits (e.g.float = Field(default=None, ge=0.0, le=0.5)).@root_validatorwith@model_validator(mode='before')and@validator(...)with@field_validator(...).Optional[type] = None) to satisfy Pydantic v2 strictness.3. Test Suite Alignment
In
tests/test_autoeq.py:FixedBandEQ.txtandParametricEQ.txt(capitalizedEQ), aligning the test suite with the actual file naming convention implemented inautoeq/batch_processing.py.