Duplicate index hashes for pydantic.main
are created when models are returned from FastAPI routes
#498
Labels
pydantic.main
are created when models are returned from FastAPI routes
#498
FastAPI creates duplicate models that are used as the returned model from a route. It uses the
create_model()
function frompydantic.main
to do that.When the duplicate models are being created, they are also queued for migrations in the Migrator class, which creates unnecessary keys in redis for the index hashes in the form of
{global_prefix}:pydantic.Main.{class_name}:index:hash
.There are a couple of possible workarounds:
Do not use redis-om-python models as return values from FastAPI routes
This option doesn't make a whole lot of sense and will create lots of duplicate code for extra models instead of reusing the redis-om models (as their pydantic base).
Do not use
Migrator().run()
Instead, use this piece of code to filter-out the pydantic hashes:
The text was updated successfully, but these errors were encountered: