Skip to content

Replace deprecated schema() with model_json_schema() in mongo_dao.py #7

Description

@xyf5432

Summary

embedding_studio/data_access/mongo/mongo_dao.py:127 calls
self.model.schema() in get_model_property_names(). BaseModel.schema() has
been deprecated since pydantic 2.0.0 and emits a PydanticDeprecatedSince20
DeprecationWarning on every call (verified on pydantic 2.13.4).

The project pins pydantic = "2.5.2", so every call to this method emits the
warning.

Impact

  • A DeprecationWarning on every call to get_model_property_names(), which
    is invoked for each Mongo collection mapping.
  • These methods are scheduled for removal in a future pydantic major release
    (3.0); migrating now avoids a later break.

Suggested fix

Replace .schema() with .model_json_schema(), which returns the same JSON
schema and is available since pydantic 2.0.0:

# before
schema = self.model.schema()
return set(schema["properties"].keys())
# after
schema = self.model.model_json_schema()
return set(schema["properties"].keys())

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions