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

Fix deprecation warnings after updating django ninja #1215

Closed
BCerki opened this issue Mar 22, 2024 · 3 comments
Closed

Fix deprecation warnings after updating django ninja #1215

BCerki opened this issue Mar 22, 2024 · 3 comments
Assignees

Comments

@BCerki
Copy link
Contributor

BCerki commented Mar 22, 2024

Blocked by #1061. Will probably have merge conflicts with #825 , #826 , #827

###Description of the Tech Debt###

In #333 we updated to django-ninja 1, but we ran into some trouble because 1 doesn't support foreign keys the same way the old one (0) does. The 0 way is deprecated but not broken, and there's some discussion with the maintainer about how foreign keys would work (@Sepehr-Sobhani do you have the link?), so we decided to leave the deprecated code in for now.

Most of the warnings come up when running the tests and these seem to be the main ones:

../../.cache/pypoetry/virtualenvs/registration-Ja4MI3ZB-py3.9/lib/python3.9/site-packages/pydantic/_internal/_config.py:272: 31 warnings
/home/briannacerkiewicz/.cache/pypoetry/virtualenvs/registration-Ja4MI3ZB-py3.9/lib/python3.9/site-packages/pydantic/_internal/_config.py:272: PydanticDeprecatedSince20: Support for class-based config is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.6/migration/
warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

../../.cache/pypoetry/virtualenvs/registration-Ja4MI3ZB-py3.9/lib/python3.9/site-packages/ninja/orm/metaclass.py:90: 29 warnings
  /home/briannacerkiewicz/.cache/pypoetry/virtualenvs/registration-Ja4MI3ZB-py3.9/lib/python3.9/site-packages/ninja/orm/metaclass.py:90: DeprecationWarning: The use of `Config` class is deprecated for ModelSchema, use 'Meta' instead
    meta_conf = MetaConf.from_schema_class(name, namespace)

Django-ninja and pydantic docs on fixing this. Notes:

  • once we switch from Config to Meta, instead of "naics_code" in the schema it would have to change to "naics_code_id" (from "naics_code"), and this is going to affect both back and front ends
  • don't seem to be able to return more than one schema from a single endpoint. Eg, previously if an industry user was requesting operation data we'd give them some of it, and if it was a cas_user, they'd get all of it. We can't do this with schemas anymore so see resolve_operator validator

If there are other warnings, either address them as part of this card or make another if it looks like a big job.

###Tech Debt Triage#
The purpose of our technical debt triage process is to analyze technical debt to determine risk level of the technical debt and the value in tackling that technical debt.

Risk Value Scoring:

Level Value
High 3
Medium 2
Low 1
Technical Debt - Risk Types Level Value
Business Area Risk - Risk of business area visibility / damage to user experience
Developer Fault Risk - How likely will this tech debt cause a future error related to coding on top of it
System Fault Risk - Risk of system errors or application downtime
Time Scale Risk - Compound risk effect if left alone. How much more difficult to fix or dangerous will this become over time?
Time Sink Risk - How much will this tech debt slow the development process down
TOTAL SCORE:
@Sepehr-Sobhani
Copy link
Contributor

@BCerki based on this comment I think there is no fix for this for now: vitalik/django-ninja#1093 (comment)

@BCerki
Copy link
Contributor Author

BCerki commented Mar 26, 2024

@BCerki based on this comment I think there is no fix for this for now: vitalik/django-ninja#1093 (comment)

I had originally written this ticket because I wasn't planning to change from Config to model_config etc. in the open PR. Have you addressed all of that in your commits?

@Sepehr-Sobhani Sepehr-Sobhani self-assigned this Aug 31, 2024
@patriciarussellCAS
Copy link

@BCerki and @Sepehr-Sobhani - let me know if anything else is needed for this. If not I'll close this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants