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

model_rebuild calls for top level fragments #258

Closed
wants to merge 4 commits into from
Closed

Conversation

mat-sop
Copy link
Contributor

@mat-sop mat-sop commented Dec 22, 2023

This pr restores model_rebuild calls for top-level fragment models. When a fragment is parsed to many models only 1 (with the same name as the fragment) will get model_rebuild call.

Implementation is complete, but I'm marking this as a draft because I think it's a good opportunity to add a test that checks if generated models can be imported and used with .model_validate(...). Maybe as a part of generated_client or new test that imports models from expected_clients?

resolves #253

@mat-sop mat-sop marked this pull request as draft December 22, 2023 13:48
@bombsimon
Copy link
Contributor

Thanks for this fix! I updated to 0.11.0 today and hit this issue. Do you want any assistance with writing tests for this? I'm also curious if you have any suggested workaround for this until this is merged, should I just rebuild them manually?

@rafalp rafalp self-assigned this Jan 9, 2024
@rafalp
Copy link
Contributor

rafalp commented Jan 9, 2024

@bombsimon I'll be taking over this (and other) PRs from Matt who left the company. I'll need to catch up with the code and internals first, but this PR is a priority for me.

@bombsimon
Copy link
Contributor

@rafalp Oh, sad to hear you're losing a great colleague but congrats to Matt I hope! 🎈 And luckily for us using this the codebase is still in good hands with you!

Understandable that this will take some time, let me know if I can do anything to help with the process! And FYI I based my branch with issues on this branch and that works just fine so this solves the problem for me.

@rafalp
Copy link
Contributor

rafalp commented Jan 19, 2024

Hello @bombsimon. If you want to pick up this PR to add tests to it, please feel free to do so.

Apologies for taking this long to return to this.

@bombsimon
Copy link
Contributor

@rafalp I'll try to pick this up next week and I'll let you know if I won't make it so you're not waiting for me!

Don't mention it, all your effort is greatly apprecaited!

@bombsimon
Copy link
Contributor

I don't have access to push to this branch so I crated #267 and rebased on main.

I opted to import a model from expected_clients that would not have been fully built without calling model_rebuild() and I'm asserting both on the expected JSON schema and that we can validate all our types as expected. I added a somewhat unrelated but negative test to ensure we don't blindly validate invalid models. Maybe a bit out of scope since this should be tested in the Pydantic module but it might be helpful enough to show what we're trying to assert.

Since there's no way for me to turn of the calls to model_rebuild this test will solely serve as a check to not remove these by accident in the future. I think this one test case should be enough to confirm we generate an expected client.

@rafalp
Copy link
Contributor

rafalp commented Jan 23, 2024

Maybe a bit out of scope since this should be tested

Tests like this are useful, they codify assumptions/requirements on the dependency's behavior in tests suite.

@rafalp
Copy link
Contributor

rafalp commented Jan 25, 2024

Superseded by #267

@rafalp rafalp closed this Jan 25, 2024
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.

[bug] Pydantic model definition errors for fragments with nesting
3 participants