mirror of
https://github.com/qurator-spk/sbb_ner.git
synced 2025-06-07 19:35:14 +02:00
add logging
This commit is contained in:
parent
a29ea04603
commit
b2fdff0d9e
2 changed files with 15 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
from flask import Flask, send_from_directory, redirect, jsonify, request
|
from flask import Flask, send_from_directory, redirect, jsonify, request
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from sqlite3 import Error
|
from sqlite3 import Error
|
||||||
|
@ -19,6 +20,8 @@ app = Flask(__name__)
|
||||||
|
|
||||||
app.config.from_json('config.json')
|
app.config.from_json('config.json')
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Digisam:
|
class Digisam:
|
||||||
|
|
||||||
|
@ -31,13 +34,15 @@ class Digisam:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_connection(db_file):
|
def create_connection(db_file):
|
||||||
try:
|
try:
|
||||||
|
logger.debug('Connection to database: {}'.format(db_file))
|
||||||
|
|
||||||
conn = sqlite3.connect(db_file, check_same_thread=False)
|
conn = sqlite3.connect(db_file, check_same_thread=False)
|
||||||
|
|
||||||
conn.execute('pragma journal_mode=wal')
|
conn.execute('pragma journal_mode=wal')
|
||||||
|
|
||||||
return conn
|
return conn
|
||||||
except Error as e:
|
except Error as e:
|
||||||
print(e)
|
logger.error(e)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -292,7 +297,9 @@ def ner(model_id):
|
||||||
try:
|
try:
|
||||||
assert "".join([pred['word'] for pred in output_sentence]) == "".join(input_sentence).replace(" ", "")
|
assert "".join([pred['word'] for pred in output_sentence]) == "".join(input_sentence).replace(" ", "")
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
import ipdb;ipdb.set_trace()
|
logger.warning('Input and output different!!! \n\n\nInput: {}\n\nOutput: {}\n'.
|
||||||
|
format("".join(input_sentence).replace(" ", ""),
|
||||||
|
"".join([pred['word'] for pred in output_sentence])))
|
||||||
|
|
||||||
return jsonify(output)
|
return jsonify(output)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
from .app import app
|
from .app import app
|
||||||
|
import logging
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run()
|
app.run()
|
||||||
|
else:
|
||||||
|
gunicorn_logger = logging.getLogger('gunicorn.error')
|
||||||
|
app.logger.handlers = gunicorn_logger.handlers
|
||||||
|
app.logger.setLevel(gunicorn_logger.level)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue