Skip to content

Update pydantic to >=2.11 and fix issues introduced by pydantic behaviour change regarding type aliases #616

@ericblanc20

Description

@ericblanc20

Describe the bug
When pydantic version 2.11 is used, models with empty FilePath entries trigger a validation error when testing. This error doesn't occur with pydantic version 2.9 or 2.10

To Reproduce
Steps to reproduce the behavior:

  1. pytest -vv tests/snappy_pipeline/workflows/test_tumor_mutational_burden.py
  2. The 6 tests should pass
  3. Upgrade pydantic to 2.11
  4. Repeat pytest -vv tests/snappy_pipeline/workflows/test_tumor_mutational_burden.py
  5. There should be 9 errors PydanticSerializationUnexpectedValue(Expected <class 'pathlib.Path'> but got <class 'NoneType'> with value 'None' - serialized value may not be as expected.).

Expected behavior
The tests should all pass, because only the tumor mutational burden step should be assessed.
However, it makes sense that the tests fail, because the root cause is found in the logic of configuration validation.

Additional context
These errors are actually caused by failed validation of the WgsSvExportExternalConfigModel, WgsCnvExportExternalConfigModel & VariantExportExternalConfigModel.
Each of these 3 models have the configuration parameters path_refseq_ser, path_ensembl_ser & path_db as FilePath variables without default (as should be).
However, when any instance derived from BaseStep is initialised, the parent class initialization imports ConfigModel which (as I understand) populates all the steps with default values from their models.
Then, the validation fails, because although validation itself doesn't seem to be carried out, the serialisation of empty FilePath raise errors. Changing the type of offending parameters from FilePath to str avoids the error.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions