SQLMIGRATION flask design thread date
This commit is contained in:
22
run.py
22
run.py
@@ -16,7 +16,6 @@ from storage import Mail, MailThread, db_session
|
||||
#import yaml
|
||||
#import email
|
||||
from classifier import get_training_threads, print_answers, in_training, store_training_data, get_pipe, test_pipe, train_single_thread # , pipe2, pipe2b
|
||||
from flaskapp import app
|
||||
|
||||
|
||||
def predict_thread(p,l,t):
|
||||
@@ -27,10 +26,31 @@ def predict_thread(p,l,t):
|
||||
|
||||
#print "arg1:"+sys.argv[1]
|
||||
if len(sys.argv)>1:
|
||||
|
||||
if sys.argv[1] == "fetch_threads":
|
||||
print flatten_threads(fetch_threads())
|
||||
|
||||
if sys.argv[1] == "predict_threads":
|
||||
pipe1,le=get_pipe("pipe1",b"answered")
|
||||
pipe2,le2=get_pipe("pipe2b", b"maintopic")
|
||||
pipe3,le3=get_pipe("pipe2b", b"lang")
|
||||
mail_threads=db_session.query(MailThread).all()
|
||||
|
||||
answered=le.inverse_transform(pipe1.predict(mail_threads))
|
||||
maintopic=le2.inverse_transform(pipe2.predict(mail_threads))
|
||||
lang=le3.inverse_transform(pipe3.predict(mail_threads))
|
||||
|
||||
for i, t in enumerate(mail_threads):
|
||||
t.answered=answered[i]
|
||||
t.opened=answered[i]
|
||||
|
||||
t.maintopic=maintopic[i]
|
||||
t.lang=lang[i]
|
||||
db_session.add(t)
|
||||
db_session.commit()
|
||||
|
||||
if sys.argv[1] == "run_server":
|
||||
from flaskapp import app
|
||||
app.run(port=3000,debug=True)
|
||||
|
||||
if sys.argv[1] == "print_threads":
|
||||
|
||||
Reference in New Issue
Block a user