2020-10-21 11:07:10 +00:00
|
|
|
# First things first: apply monkey patch, so that no code gets executed without
|
|
|
|
# patched libraries!
|
2019-08-26 12:21:06 +00:00
|
|
|
import eventlet
|
2020-10-21 11:07:10 +00:00
|
|
|
eventlet.monkey_patch()
|
|
|
|
|
2023-05-11 14:33:21 +00:00
|
|
|
from app import create_app, db, scheduler, socketio # noqa
|
2022-02-08 11:26:20 +00:00
|
|
|
from app.models import (
|
2022-12-05 08:40:02 +00:00
|
|
|
Avatar,
|
2022-02-08 11:26:20 +00:00
|
|
|
Corpus,
|
|
|
|
CorpusFile,
|
2023-01-23 10:50:12 +00:00
|
|
|
CorpusFollowerAssociation,
|
2023-02-23 12:05:04 +00:00
|
|
|
CorpusFollowerRole,
|
2022-02-08 11:26:20 +00:00
|
|
|
Job,
|
|
|
|
JobInput,
|
|
|
|
JobResult,
|
|
|
|
Role,
|
2022-10-12 08:23:05 +00:00
|
|
|
TesseractOCRPipelineModel,
|
2022-10-21 11:33:25 +00:00
|
|
|
SpaCyNLPPipelineModel,
|
2022-02-08 11:26:20 +00:00
|
|
|
User
|
|
|
|
) # noqa
|
2021-12-07 13:18:05 +00:00
|
|
|
from flask import Flask # noqa
|
|
|
|
from typing import Any, Dict # noqa
|
2020-10-21 11:07:10 +00:00
|
|
|
|
2019-07-03 08:31:23 +00:00
|
|
|
|
2021-12-07 13:18:05 +00:00
|
|
|
app: Flask = create_app()
|
2019-07-05 12:47:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.shell_context_processor
|
2021-12-07 13:18:05 +00:00
|
|
|
def make_shell_context() -> Dict[str, Any]:
|
|
|
|
''' Adds variables to the shell context. '''
|
|
|
|
return {
|
2023-02-23 12:05:04 +00:00
|
|
|
'db': db,
|
2022-12-05 08:40:02 +00:00
|
|
|
'Avatar': Avatar,
|
2021-12-07 13:18:05 +00:00
|
|
|
'Corpus': Corpus,
|
|
|
|
'CorpusFile': CorpusFile,
|
2023-01-23 10:50:12 +00:00
|
|
|
'CorpusFollowerAssociation': CorpusFollowerAssociation,
|
2023-02-23 12:05:04 +00:00
|
|
|
'CorpusFollowerRole': CorpusFollowerRole,
|
2021-12-07 13:18:05 +00:00
|
|
|
'Job': Job,
|
|
|
|
'JobInput': JobInput,
|
|
|
|
'JobResult': JobResult,
|
|
|
|
'Role': Role,
|
2022-10-12 08:23:05 +00:00
|
|
|
'TesseractOCRPipelineModel': TesseractOCRPipelineModel,
|
2022-10-21 11:33:25 +00:00
|
|
|
'SpaCyNLPPipelineModel': SpaCyNLPPipelineModel,
|
2021-12-07 13:18:05 +00:00
|
|
|
'User': User
|
|
|
|
}
|
2022-04-22 14:36:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2022-06-28 10:30:02 +00:00
|
|
|
with app.app_context():
|
|
|
|
if app.config['NOPAQUE_IS_PRIMARY_INSTANCE']:
|
|
|
|
for corpus in Corpus.query.filter(Corpus.num_analysis_sessions > 0).all():
|
|
|
|
corpus.num_analysis_sessions = 0
|
|
|
|
db.session.commit()
|
|
|
|
scheduler.start()
|
2022-04-22 14:36:12 +00:00
|
|
|
socketio.run(app, host='0.0.0.0')
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2022-06-28 10:30:02 +00:00
|
|
|
main()
|