Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project.model_dump() produces a big warning #90

Open
alexhroom opened this issue Nov 6, 2024 · 1 comment
Open

Project.model_dump() produces a big warning #90

alexhroom opened this issue Nov 6, 2024 · 1 comment

Comments

@alexhroom
Copy link
Collaborator

from RATapi import Project
p = Project()
p.model_dump()

produces the UserWarning

/home/rec93639/Code/RasCAL-2/.venv/lib/python3.12/site-packages/pydantic/main.py:390: UserWarning: Pydantic serializer warnings:
  Expected `list[definition-ref]` but got `ClassList` with value `[ProtectedParameter(name=...rm', mu=0.0, sigma=inf)]` - serialized value may not be as expected
  Expected `list[definition-ref]` but got `ClassList` with value `[Parameter(name='SLD Air'...rm', mu=0.0, sigma=inf)]` - serialized value may not be as expected
  Expected `list[definition-ref]` but got `ClassList` with value `[Parameter(name='SLD D2O'...rm', mu=0.0, sigma=inf)]` - serialized value may not be as expected
  Expected `list[definition-ref]` but got `ClassList` with value `[Parameter(name='Scalefac...rm', mu=0.0, sigma=inf)]` - serialized value may not be as expected
  Expected `list[definition-ref]` but got `ClassList` with value `[]` - serialized value may not be as expected
  Expected `list[definition-ref]` but got `ClassList` with value `[Parameter(name='Backgrou...rm', mu=0.0, sigma=inf)]` - serialized value may not be as expected
  Expected `list[Background]` but got `ClassList` with value `[Background(name='Backgro...value_4='', value_5='')]` - serialized value may not be as expected
  Expected `list[definition-ref]` but got `ClassList` with value `[Parameter(name='Resoluti...rm', mu=0.0, sigma=inf)]` - serialized value may not be as expected
  Expected `list[Resolution]` but got `ClassList` with value `[Resolution(name='Resolut...value_4='', value_5='')]` - serialized value may not be as expected
  Expected `list[CustomFile]` but got `ClassList` with value `[]` - serialized value may not be as expected
  Expected `list[Data]` but got `ClassList` with value `[Data(name='Simulation', ...ion_range=[0.005, 0.7])]` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `list[Layer]` but got `ClassList` with value `[]` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `list[AbsorptionLayer]` but got `ClassList` with value `[]` - serialized value may not be as expected
  Expected `list[DomainContrast]` but got `ClassList` with value `[]` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `list[Contrast]` but got `ClassList` with value `[]` - serialized value may not be as expected
  PydanticSerializationUnexpectedValue: Expected `list[ContrastWithRatio]` but got `ClassList` with value `[]` - serialized value may not be as expected
  return self.__pydantic_serializer__.to_python(

Investigate this and hopefully solve it.

@alexhroom alexhroom changed the title Project.model_dump() produces a big warning Project.model_dump() produces a big warning Nov 6, 2024
@alexhroom
Copy link
Collaborator Author

note: the warning isn't produced for RAT.Project().model_dump(serialize_as_any=True), and the serialised dict is exactly how we expect it to look!

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

No branches or pull requests

1 participant