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

PK-929 Stub edge API #1

Merged
merged 19 commits into from
Dec 30, 2022
Merged

PK-929 Stub edge API #1

merged 19 commits into from
Dec 30, 2022

Conversation

michael-groundlight
Copy link
Contributor

This is a stub edge server (FastAPI + Docker + nginx). If a route is implemented in the edge server, then it tries to use the edge server. Otherwise, proxy the request to the real groundlight API endpoint.

Note: there is no application logic implemented (e.g. near-image deduplication on the edge) - it's just a stub.

# Build the image
$ docker build --target production-image --tag groundlight-edge .

# Run the server
$ docker run --rm -it -p 80:80 groundlight-edge

# Hit the edge API
$ curl -X POST "http://localhost/device-api/v1/image-queries" \
    --header "Content-Type: application/json" \
    --data '{"detector_id": "abc"}'

Comment on lines +9 to +22
# Goal: If the request path isn't found in the local edge server, fall back to the API server.
# TODO: This fallback almost works, but not quite. nginx seems to only do the fallback if
# the local server is down (502 status code); it doesn't seem to work with "regular" 404s at
# the application level. I'm not sure how to make it work ...
# https://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
location / {
proxy_pass http://localhost:8080;
error_page 404 = @fallback;
}

location @fallback {
# TODO: switch to prod
proxy_pass https://api.integ.groundlight.ai;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas on this bug, @robotrapta?

@michael-groundlight michael-groundlight changed the title Stub edge API PK-929 Stub edge API Dec 19, 2022
@@ -0,0 +1,97 @@
# Build args
ARG APP_PORT=8080
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in this case, 8080 is the port the customer would send queries too?

@@ -0,0 +1,97 @@
# Build args
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate all of the comments on this file. It seems in tune with making this open source.

@sunildkumar sunildkumar self-requested a review December 20, 2022 23:24
Copy link
Member

@sunildkumar sunildkumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looked at it offline w mike! super exciting!

I think the only thing we definitely should fix before merging is the nginx forwarding issue.

@michael-groundlight michael-groundlight merged commit 995cb8a into main Dec 30, 2022
@michael-groundlight michael-groundlight deleted the initial branch December 30, 2022 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants