Skip to content

Commit

Permalink
add more logs and upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
wb14123 committed Feb 21, 2023
1 parent 3c80d48 commit cd50ce0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile-cpu
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /usr/src/app

COPY requirements-cpu.txt ./

RUN pip install --no-cache-dir -r requirements-cpu.txt
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements-cpu.txt

COPY . .

Expand Down
8 changes: 4 additions & 4 deletions requirements-cpu.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Flask==1.0.2
Flask-Cors==3.0.9
gevent==1.2.2
greenlet==0.4.13
Flask==2.0.3
Flask-Cors==3.0.10
gevent==22.10.2
greenlet==2.0.2
numpy
tensorboard==1.15
tensorflow==1.15
15 changes: 13 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@

print("Program starting ...", flush=True)

import sys

from gevent import monkey

print("Patching monkey ...", flush=True)
monkey.patch_all()

print("Importing library ...", flush=True)
from flask import Flask, jsonify, request
from flask_cors import CORS, cross_origin
from model import Model
from gevent.wsgi import WSGIServer
from gevent.pywsgi import WSGIServer
from logging.handlers import RotatingFileHandler
import logging

print("Importing model ...", flush=True)
from model import Model


print("Creating Flask app ...", flush=True)
app = Flask(__name__)
CORS(app)

vocab_file = '/data/dl-data/couplet/vocabs'
model_dir = '/data/dl-data/models/tf-lib/output_couplet_prod'


print("Setting up logging ...", flush=True)

def log_setup():
log_handler = RotatingFileHandler(
"/logs/service.log",
Expand All @@ -39,6 +49,7 @@ def log_setup():
SPLIT_CHARS = [',', '、', ',', '.', '。', '!', '!', '?', '?', ' ']
CENSOR_WORDS_DICT = "/data/censor_words.txt"

logging.info("Loading censor words...")
with open(CENSOR_WORDS_DICT, encoding='utf-8') as censor_words_file:
censor_words = [word[:-1] for word in censor_words_file.readlines()]
logging.info("Loaded %s censor_words" % (len(censor_words)))
Expand Down

0 comments on commit cd50ce0

Please sign in to comment.