bug: pydantic/pathlib patching causes LookupError: <ContextVar name='request_directory' at 0x172a18860>
#4728
Labels
bug
Something isn't working
Describe the bug
We were seeing strange test failures with exceptions coming from bentoml code in tests unrelated to bentoml. It turns out that this was from the behaviour of
import bentoml
adding items topydantic._internal. _std_types_schema
which can cause unexpected validation issues. It seems that the pathlib validator tries to access arequest_directory
contextvar which doesn't exist.To reproduce
Expected behavior
I'm not sure what is happening with the contextvar issue, but I would expect that to not fail or give an informative error if there is something that should be done differently. It is quite surprising that bentoml affects unrelated code (especially in the case of testing where it creates non-determinism depending on test ordering and when bentoml was imported in other tests) so some documentation or a way to opt in to that (like the
patch_all()
pattern other libs like gevent use) could be good.Environment
Environment variable
System information
bentoml
: 1.2.15python
: 3.11.9platform
: macOS-13.6.6-x86_64-i386-64bituid_gid
: 501:20pip_packages
The text was updated successfully, but these errors were encountered: