Skip to content

Conversation

darrylong
Copy link
Member

@darrylong darrylong commented Nov 22, 2023

Description

API serving is ported to run on Flask. Flask dependency is required to run this version of serving.

In this PR, API serving have been changed to the following form:
Flask --> Gunicorn (WSGI HTTP Server)

Changes

To run in development mode:
Run MODEL_DIR='saved_models/bpr' MODEL_CLASS='cornac.models.BPR' flask run where MODEL_DIR and MODEL_CLASS are saved model directory and the class of the models respectively.

Related Issues

Checklist:

  • I have added tests.
  • I have updated the documentation accordingly.
  • I have updated README.md (if you are adding a new model).
  • I have updated examples/README.md (if you are adding a new example).
  • I have updated datasets/README.md (if you are adding a new dataset).

@darrylong darrylong self-assigned this Nov 22, 2023
@qtuantruong
Copy link
Member

@darrylong are we planning to have a tutorial on best practices for using this API service?

@darrylong
Copy link
Member Author

darrylong commented Nov 23, 2023

@tqtg Yes we should! I'll include a readme in the directory, also with the developer documentation?

@qtuantruong
Copy link
Member

that would be great! Let me see how we can combine this with our current serving API. In the meantime, maybe you could help with a tutorial/guide on using this with wsgi server too.

@qtuantruong qtuantruong marked this pull request as ready for review November 25, 2023 20:05
@qtuantruong
Copy link
Member

@darrylong I've updated to use Flask app as the default way to serve model. I think it's better than maintaining different versions. Let me know if we're good with this approach, then we can develop user guide accordingly.

@darrylong
Copy link
Member Author

@darrylong I've updated to use Flask app as the default way to serve model. I think it's better than maintaining different versions. Let me know if we're good with this approach, then we can develop user guide accordingly.

@tqtg Hey thanks for the changes, they look great to me. I'm okay with Flask being used as the default way.

Only thing is that do we want all users to install Flask in order to use Cornac?

@qtuantruong
Copy link
Member

@darrylong that’s a good point. Maybe we don’t have to, and only need to tell users to install Flask as needed

@darrylong
Copy link
Member Author

@darrylong that’s a good point. Maybe we don’t have to, and only need to tell users to install Flask as needed

@tqtg alright! i was thinking maybe we can remove the dependency check from setup.py, and add a check in the serving portion instead. Will the be fine?

@qtuantruong
Copy link
Member

Yes. We can do that

@qtuantruong
Copy link
Member

LGTM

@darrylong
Copy link
Member Author

@tqtg Added the changes as discussed. Please have a look and feel free to edit or merge. Thanks!

@qtuantruong qtuantruong merged commit 3669929 into PreferredAI:master Nov 28, 2023
@darrylong darrylong deleted the production-serving branch November 29, 2023 03:23
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