-
Notifications
You must be signed in to change notification settings - Fork 797
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
bug: AttributeError
: close()
called on Service dependency in TestClient
#5082
Labels
bug
Something isn't working
Comments
yxtay
changed the title
bug: AttributeError:
bug: AttributeError: Nov 13, 2024
close()
called on Service dependencyclose()
called on Service dependency in TestClient
yxtay
changed the title
bug: AttributeError:
bug: Nov 13, 2024
close()
called on Service dependency in TestClient
AttributeError
: close()
called on Service dependency in TestClient
Should guard agains missing |
Will you be able to point me to the code where this should be done? |
Along at this very line:
Check the |
5 tasks
frostming
pushed a commit
that referenced
this issue
Nov 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Hi,
I am encountering
AttributeError
when usingTestClient
due toclose
being called on service dependencies. Below is the reproducible example.In the documentation, a simple service is demoed. But this doesn't work with model composition.
https://docs.bentoml.com/en/latest/guides/testing.html#http-behavior-tests
I believe this is linked to using
TestClient
as a context manager calls the lifespan handler.https://www.starlette.io/lifespan/#running-lifespan-in-tests
The service file
Using
TestClient
directly on theModel
is fine.But using
TestClient
onService
throwsAttributeError
. Stack trace is below.A possible workaround is to add an empty async
close
method to the dependent model as I added as a comment. I think this should be better handled in thebentoml.depends
decorator instead.To reproduce
Example as provided above.
Expected behavior
AttributeError
should not be thrown when usingTestClient
on service with model composition.Environment
bentoml==1.3.11
python==3.10.13
platform: ubuntu 22.04
The text was updated successfully, but these errors were encountered: