-
Notifications
You must be signed in to change notification settings - Fork 280
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
Rest API #3
Rest API #3
Conversation
* parse uid, input (vector<double>) and label from predict and update requests * attaches boost continuation onto future returned from call to qp.predict and qp.update, which then fulfills the http request * included server_http.hpp file directly TODO: put this in an interface library
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.
This looks good!
One key part of the REST API is the ability to configure new endpoints at runtime. For example, someone in devops should be able to deploy a Clipper cluster (potentially with no REST endpoints). A data scientist who wants to add a predictive recommendation application should then be able to add a new REST endpoint to the running Clipper instance without having to write any code or even restart the service.
That shouldn't all happen in this initial implementation, but let's make the implementation general enough to support this going forward. Here are the things that need to happen on a per-endpoint basis (ideally at runtime):
- Listen at endpoint (
http://clipper:1337/ads
,http://clipper:1337/recs
, etc). - Parse input
- Specify selection policy
- Generate query (get list of candidate models, set SLO.
TODO for this PR:
- Figure out how to support multiple named endpoints with the same request handler without explicitly hardcoding each endpoint.
- Create a generic
add_application()
function to create each endpoint that takes as arguments those 4 items above. For now this doesn't need to be called at runtime and can take lambdas or something to parse the input and specify the candidate models.
@@ -4,7 +4,7 @@ | |||
#include <utility> | |||
#include <vector> | |||
|
|||
#define BOOST_THREAD_VERSION 3 | |||
#define BOOST_THREAD_VERSION 4 |
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 wonder if there's a canonical place to define this once, so that we don't have to rely on developers setting this every time they include boost/thread.
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.
yes, when using Makefile projects I was just passing the -DBOOST_THREAD_VERSION=X preprocessing flag.
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.
something like this :
https://cmake.org/cmake/help/v3.2/command/add_definitions.html
add_definitions( -DBOOST_THREAD_VERSION=4)
@@ -4,7 +4,7 @@ | |||
#include <utility> | |||
#include <vector> | |||
|
|||
#define BOOST_THREAD_VERSION 3 | |||
#define BOOST_THREAD_VERSION 4 | |||
#include <boost/thread.hpp> | |||
#include <boost/thread/future.hpp> |
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 was reading about how to include boost thread this weekend, and it looks like we don't need both include lines. You can remove #include <boost/thread/future.hpp>
because boost/thread.hpp includes it.
See http://www.boost.org/doc/libs/1_62_0/doc/html/thread.html
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.
Yeah, turns out it's not necessary. Will remove on the next update to this PR.
@@ -0,0 +1,438 @@ | |||
#ifndef SERVER_HTTP_HPP |
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.
Is this file from Simple-Web-Server? We should attribute the source and include its license in a comment at the top of the file.
We should also add it to src/libs and expose it as an INTERFACE library in cmake using add_library()
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.
Yep, definitely. Will try to get that working on the next update.
#include "server_http.hpp" | ||
|
||
using namespace std; | ||
using namespace clipper; |
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.
Don't include all members of a namespace (see https://google.github.io/styleguide/cppguide.html#Namespaces). You can using ::clipper::QueryProcessor;
instead.
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.
In this case, I'd end up with each of these using
statements.
using clipper::DoubleVector;
using clipper::FeedbackAck;
using clipper::Input;
using clipper::Output;
using clipper::QueryProcessor;
using clipper::Response;
which seems a bit excessive. Any thoughts?
using namespace std; | ||
using namespace clipper; | ||
using namespace boost::property_tree; | ||
typedef SimpleWeb::Server<SimpleWeb::HTTP> HttpServer; |
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.
Use alias declarations not typedef. So this should be using HttpServer = SimpleWeb::Server<SimpleWeb::HTTP>;
See Item 9 in Effective Modern C++ for an explanation (I can send you a pdf of it).
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.
Will fix. Also, that would be useful. Thanks!
} | ||
|
||
class RequestHandler { | ||
HttpServer server; |
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.
Is this private? Let's have an explicit private section.
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.
Will do.
Updated the request handler with an add_endpoint function (currently defines the entire handling function). Later on, I'll break it up into the multiple functions corresponding to the steps you described. |
@giulio-zhou Is this ready for a final review? |
Not quite yet, but almost ready. Still need to add |
Cool. Let me know when it's ready. @Corey-Zumar and I spent some time figuring out how to add new third-party header-only libraries as interface libraries the other day. Check out the example for ZeroMQ to get started. |
Included |
LGTM. Can you add a short README.md in |
Just wanted to clarify something before proceeding. For the readme, are you thinking of, say, how to formulate a prediction query from a Python client? Or more like the steps I'd need to take to define a different endpoint? |
How to issue a query with curl. Say what the endpoint is ( |
Ok, sounds good. I'll do that later tonight. |
For some reason @atumanov's comments aren't making it into the thread. To echo them: |
Added README and fixed up boost thread version includes. |
Merged! |
# This is the 1st commit message: started work on spark container # This is the commit message #2: rearranged files in maven packages # This is the commit message #3: training example works # This is the commit message #4: Copies jar to known location # This is the commit message #5: loading container class from jar not working yet # This is the commit message #6: got jar loading working
# This is the 1st commit message: started work on spark container # This is the commit message #2: rearranged files in maven packages # This is the commit message #3: training example works # This is the commit message #4: Copies jar to known location # This is the commit message #5: loading container class from jar not working yet # This is the commit message #6: got jar loading working
# This is the 1st commit message: started work on spark container # This is the commit message #2: rearranged files in maven packages # This is the commit message #3: training example works # This is the commit message #4: Copies jar to known location # This is the commit message #5: loading container class from jar not working yet # This is the commit message #6: got jar loading working
…o repl support (#133) * # This is a combination of 6 commits. # This is the 1st commit message: started work on spark container # This is the commit message #2: rearranged files in maven packages # This is the commit message #3: training example works # This is the commit message #4: Copies jar to known location # This is the commit message #5: loading container class from jar not working yet # This is the commit message #6: got jar loading working * initial work on incorporating REPL classes. some cleanup and re-org. untested basic example working loading classes defined in REPL still doesn't work started java reorg Reorganized code. Everything compiles Finished implementation. Now need docker container and lots of debugging. start work on docker container fixed bug in docker file Fixed some bugs Clipper local deploy seems to be working Fixed some bugs Deploy is working but there's something wrong with the container Remote deploy is working! Spark scala deploy is working both locally and remotely Formatting started to add tests * mostly done with rebase * rebase complete with existing tests passing * Format code * Fix typo * added unit tests * addressed review comments * add some notes on how to run Spark example * fixed typo in comment
TODO: put this in an interface library