Skip to content
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

Fix: VM connector does not start when run locally #287

Merged
merged 2 commits into from
Apr 3, 2023

Conversation

odesenfans
Copy link
Collaborator

Problem: launching the VM connector with run_vm_connector.sh yields
an exception because of issues with the return types of the API
endpoints.

Solution: remove Response and StreamingResponse type hints from
return values as they are not Pydantic models.

Problem: the field does not appear in the VM connector API functions.
@odesenfans odesenfans requested a review from hoh March 31, 2023 15:32
@odesenfans odesenfans added the bug Something isn't working label Mar 31, 2023
@odesenfans
Copy link
Collaborator Author

Two commits, one fixes documentation issues and the other fixes the actual bug. The issue occurs when running bash docker/run_vm_connector.sh on main. I got the following exception:

Process SpawnProcess-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/local/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.9/site-packages/uvicorn/_subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 59, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 66, in serve
config.load()
File "/usr/local/lib/python3.9/site-packages/uvicorn/config.py", line 471, in load
self.loaded_app = import_from_string(self.app)
File "/usr/local/lib/python3.9/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/opt/vm_connector/main.py", line 67, in
async def download_message(ref: str) -> Union[Dict, Response]:
File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 661, in decorator
self.add_api_route(
File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 600, in add_api_route
route = route_class(
File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 405, in init
self.response_field = create_response_field(
File "/usr/local/lib/python3.9/site-packages/fastapi/utils.py", line 87, in create_response_field
raise fastapi.exceptions.FastAPIError(
fastapi.exceptions.FastAPIError: Invalid args for response field! Hint: check that typing.Union[typing.Dict, starlette.responses.Response] is a valid Pydantic field type. If you are using a return type annotation that is not a valid Pydantic field (e.g. Union[Response, dict, None]) you can disable generating the response model from the type annotation with the path operation decorator parameter response_model=None. Read more: https://fastapi.tiangolo.com/tutorial/response-model/

Problem: launching the VM connector with `run_vm_connector.sh` yields
an exception because of issues with the return types of the API
endpoints.

Solution: remove `Response` and `StreamingResponse` type hints from
return values as they are not Pydantic models.
@MHHukiewitz MHHukiewitz merged commit 3f9448c into main Apr 3, 2023
@MHHukiewitz MHHukiewitz deleted the od-fix-vm-connector-errors branch April 3, 2023 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants