-
Notifications
You must be signed in to change notification settings - Fork 2
upgrade to pydantic 2.3 (FF-957) #24
Conversation
Paired with @sameerank and we worked through some test failures - remaining ones are in |
df689c9
to
bebce94
Compare
class AssignmentLogger(BaseModel): | ||
model_config = ConfigDict(arbitrary_types_allowed=True) |
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.
AssignmentLogger
does not inherit from SdkBaseModel
because it has unique serialization requirements from the json dto objects
|
||
|
||
def to_camel(s: str): | ||
words = s.split("_") | ||
if len(words) > 1: | ||
return words[0] + "".join([w.capitalize() for w in words[1:]]) | ||
return words[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.
glad they have an official version publish! our to_camel
had a bug in it preventing test cases from passing
class SdkBaseModel(BaseModel): | ||
class Config: | ||
alias_generator = to_camel | ||
allow_population_by_field_name = True | ||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True) |
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.
SdkBaseModel
is the parent class of all json dto classes
value=experiment_config.overrides[subject_hash], | ||
typedValue=experiment_config.typedOverrides[subject_hash], | ||
typed_value=experiment_config.typed_overrides[subject_hash], | ||
shard_range=ShardRange(start=0, end=10000), |
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.
python classes now have snake case, as they're supposed to
name: str | ||
value: str | ||
typedValue: Any | ||
typed_value: Any = 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.
pydantic required this
install_requires = | ||
pydantic<2 | ||
pydantic | ||
pydantic-settings |
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 there a setup.cfg
and requirements.txt
file?
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.
I can't know what the intention was here, but I believe the convention is about abstract vs concrete dependencies
https://martin-thoma.com/python-requirements/#abstract-dependencies
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.
Nice, but don't forget to bump the version in __init__.py
Fixes: #issue
Motivation and Context
Our customers are upgrading to pydantic 2; we need to in order to unblock them.
Following the migration guide (https://docs.pydantic.dev/2.0/migration/) and used the
bump-pydantic
tool to generate changes.Description
How has this been tested?
Unit tests initially failed; continued working on the PR until they were all ✅