-
Notifications
You must be signed in to change notification settings - Fork 377
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
[REFACTOR] argilla server
: using pydantic v2
#5666
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5666 +/- ##
===========================================
+ Coverage 91.10% 91.35% +0.24%
===========================================
Files 150 146 -4
Lines 6253 6292 +39
===========================================
+ Hits 5697 5748 +51
+ Misses 556 544 -12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
f14425f
to
ff30ee1
Compare
argilla server
: using pydantic v2argilla server
: using pydantic v2
# Description <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Closes #5633 **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> **Checklist** <!-- Please go over the list and make sure you've taken everything into account --> - I added relevant documentation - I followed the style guidelines of this project - I did a self-review of my code - I made corresponding changes to the documentation - I confirm My changes generate no new warnings - I have added tests that prove my fix is effective or that my feature works - I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/) --------- Co-authored-by: José Francisco Calvo <jose@argilla.io> Co-authored-by: José Francisco Calvo <josefranciscocalvo@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Masive effort! 💪
@@ -1,2 +1,2 @@ | |||
ALEMBIC_CONFIG=src/argilla_server/alembic.ini | |||
ARGILLA_DATABASE_URL=sqlite+aiosqlite:///${HOME}/.argilla/argilla.db?check_same_thread=False | |||
ARGILLA_DATABASE_URL=sqlite+aiosqlite:///${HOME}/.argilla/argilla.dev.db?check_same_thread=False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For .env.test
we have the following:
ARGILLA_DATABASE_URL=sqlite+aiosqlite:///${HOME}/.argilla/argilla-test.db?check_same_thread=False
So I guess we should do the same here:
ARGILLA_DATABASE_URL=sqlite+aiosqlite:///${HOME}/.argilla/argilla.dev.db?check_same_thread=False | |
ARGILLA_DATABASE_URL=sqlite+aiosqlite:///${HOME}/.argilla/argilla-dev.db?check_same_thread=False |
@@ -22,7 +22,8 @@ maintainers = [{ name = "argilla", email = "contact@argilla.io" }] | |||
dependencies = [ | |||
# Basic dependencies | |||
"fastapi ~= 0.115.0", | |||
"pydantic ~= 1.10.18", | |||
"pydantic ~= 2.9.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we upgrade to the latest version?
"pydantic ~= 2.9.0", | |
"pydantic ~= 2.9.2", |
Don't forget to do pdm install
after change this, so the lock file is updated.
@@ -22,7 +22,8 @@ maintainers = [{ name = "argilla", email = "contact@argilla.io" }] | |||
dependencies = [ | |||
# Basic dependencies | |||
"fastapi ~= 0.115.0", | |||
"pydantic ~= 1.10.18", | |||
"pydantic ~= 2.9.0", | |||
"pydantic-settings ~= 2.6.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something similar for pydantic-settings
:
"pydantic-settings ~= 2.6.0", | |
"pydantic-settings ~= 2.6.1", |
Don't forget to do pdm install
after change this, so the lock file is updated.
role: str = Field(..., min_role_length=MIN_ROLE_LENGTH, max_length=MAX_ROLE_LENGTH, regex=MAX_ROLE_REGEX) | ||
content: str = Field(..., min_message_length=MIN_MESSAGE_LENGTH, max_length=MAX_MESSAGE_LENGTH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means we didn't have a test checking this right (for empty strings)? Should we add one?
le=SCORE_LESS_THAN_OR_EQUAL, | ||
description="The score assigned to the suggestion", | ||
) | ||
score: Optional[Union[float, List[float]]] = Field(None, description="The score assigned to the suggestion") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding custom validations maybe we can define custom types like SuggestionScore
.
Take a look to what I did here: https://github.com/argilla-io/argilla/pull/5508/files#diff-a9277ada64762a8062c1e132567edba6ce2aec3e279d1ded0452b9557bfd6b26
password: str = Field(min_length=USER_PASSWORD_MIN_LENGTH, max_length=USER_PASSWORD_MAX_LENGTH) | ||
first_name: constr(min_length=1, strip_whitespace=True) | ||
last_name: Optional[constr(min_length=1, strip_whitespace=True)] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should start using annotated str
with StringConstraints
instead of using the old constr
.
This applies to all the constr
used in the PR.
So something like:
last_name: Optional[Annotated[str, StringConstraints(min_length=1, strip_whitespace=True)]] = None
You can take a look to https://github.com/argilla-io/argilla/pull/5508/files#diff-0e72eee9f8cea03b100e007fe81d5a97c5ebea93955187f083bb908a4cee2e29R48
@@ -16,7 +16,8 @@ | |||
from typing import List | |||
from uuid import UUID | |||
|
|||
from argilla_server.pydantic_v1 import BaseModel, Field | |||
from pydantic import BaseModel, Field, ConfigDict | |||
from starlette.config import Config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this import needed?
Description
An alternative work of pydantic v2 upgrade with the latest changes from develop.
The main problems I found:
Closes #4935
Refs #5508
Type of change
How Has This Been Tested
Checklist