-
Notifications
You must be signed in to change notification settings - Fork 80
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
Add REST API to ArduPilotManager #119
Add REST API to ArduPilotManager #119
Conversation
1846a28
to
7b7d805
Compare
7b7d805
to
1801744
Compare
1801744
to
f0f444e
Compare
028ae13
to
237ece0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small review, will do a deeper one tomorrow
237ece0
to
576720f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did run python setup.py install and getting:
./main.py
Traceback (most recent call last):
File "/home/patrick/git/blue/companion-docker/core/services/ardupilot_manager/./main.py", line 7, in <module>
from fastapi import Body, FastAPI
File "/home/patrick/.local/lib/python3.9/site-packages/fastapi-0.63.0-py3.9.egg/fastapi/__init__.py", line 7, in <module>
from .applications import FastAPI as FastAPI
File "/home/patrick/.local/lib/python3.9/site-packages/fastapi-0.63.0-py3.9.egg/fastapi/applications.py", line 18, in <module>
from fastapi.openapi.utils import get_openapi
File "/home/patrick/.local/lib/python3.9/site-packages/fastapi-0.63.0-py3.9.egg/fastapi/openapi/utils.py", line 17, in <module>
from fastapi.responses import Response
File "/home/patrick/.local/lib/python3.9/site-packages/fastapi-0.63.0-py3.9.egg/fastapi/responses.py", line 10, in <module>
from starlette.responses import UJSONResponse as UJSONResponse # noqa
ImportError: cannot import name 'UJSONResponse' from 'starlette.responses' (/home/patrick/.local/lib/python3.9/site-packages/starlette/responses.py)
Could you run Edit: there was a change in starlette and they removed UJSONResponse in the newest version, but this should not occur here, since FastAPI froze starlette's version on 0.13.6 for backwards compatibility. |
|
There's probably some other package in your environment taking starlette to an upper version. Best match: starlette 0.13.6
Processing starlette-0.13.6-py3-none-any.whl
Installing starlette-0.13.6-py3-none-any.whl to /home/runner/.local/lib/python3.7/site-packages
Adding starlette 0.13.6 to easy-install.pth file I suggest using a dedicated python virtual environment to isolate package's versions or downgrading your version of starlette to 0.13.6. |
Moved to a virtualenv solves the problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you post an endpoint that already exists, it returns false but with a number code of 200.
Is that the expected behaviour ? Should we return 200 or true/false at all ? Maybe 409 (Conflict) ?
576720f
to
1dfe415
Compare
This is exactly what IntEnum does, but for strings. In this way, json files and rest frameworks (like FastAPI) represent them as strings.
1dfe415
to
9869f75
Compare
9869f75
to
14d40b0
Compare
14d40b0
to
b229b41
Compare
if "/" in place: | ||
raise ValueError(f"Bad filename: {place}. Valid filenames do not contain '/' characters.") | ||
if argument is not None: | ||
raise ValueError(f"File endpoint has should have no argument. Received {argument}.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File endpoint has should have no argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved.
@@ -79,14 +79,11 @@ def start_navigator(self) -> None: | |||
# does not accept TCP master endpoints | |||
# self.start_mavlink_manager(Endpoint(local_endpoint)) | |||
|
|||
# Check if subprocess is running and wait until it finishes | |||
# Necessary since we don't have mavlink_manager running for navigator yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor detail, you don't need to fix it, but these comments should have come out in the previous commit :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Solved!
- Make it a pydantic dataclass, for REST API validation auto-parsing - Adds validation to all arguments - Add dependency for endpoint validation - Add mypy plugin through configuration file
Initial version contains routes for getting, adding and deleting mavlink endpoints.
b229b41
to
ddc9446
Compare
API is running as a uvicorn process, started with core.