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

Support pickle model import on API server #34

Merged
merged 11 commits into from
Aug 2, 2024

Conversation

santi1234567
Copy link
Contributor

Motivation

Using blockprint currently involves having the training data in a folder. Once the model is trained, it can be persisted, but imported back into the application.
This feature would allow anyone to use already trained models, as well as saving a lot of training time and disk space.

Description

It is needed to create a function that can import the model back, and call this from the main application.
Depending on whether the model was given or not, we shall import it.

TODOs:

  • Create function to import model
  • Create environment variable to allow user to input a model path
  • Depending on the environment variable, load the model at execution time

@santi1234567 santi1234567 changed the title Support model import on api server Support pickle model import on api server Jul 22, 2024
@santi1234567 santi1234567 changed the title Support pickle model import on api server Support pickle model import on API server Jul 22, 2024

else:
print("model path must end with .pkl")
exit(0)
Copy link
Member

Choose a reason for hiding this comment

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

We should use a non-zero exit code for errors

Suggested change
exit(0)
exit(1)

Comment on lines +226 to +228
if classifier is None:
print("The classifier was not loaded")
exit(0)
Copy link
Member

Choose a reason for hiding this comment

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

I'm going to delete this because it conflicts with the intention of DISABLE_CLASSIFIER. Sometimes it is useful to start the API server without a classifier, e.g. if you just want to serve info from the sqlite DB.

If we want to simplify this in future and always require a classifier, we should remove the DISABLE_CLASSIFIER option

Suggested change
if classifier is None:
print("The classifier was not loaded")
exit(0)

@michaelsproul
Copy link
Member

Merging as-is and will push my changes in a follow-up PR

@michaelsproul michaelsproul merged commit 1e57f01 into sigp:main Aug 2, 2024
1 check passed
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