Commit a0ac07e6 authored by Yoann HOUPERT's avatar Yoann HOUPERT

add identifiant worker

parent 0057c33d
......@@ -89,6 +89,12 @@ class DecodeRequestHandler(tornado.web.RequestHandler):
self.set_status(200, "Initial statut")
self.waitResponse = Condition()
self.waitWorker = Condition()
if not self.get_arguments('model'):
self.designation = 'uc1'
else:
self.designation = self.get_argument('model')
if self.request.method != 'POST' :
logging.debug("Received a non-POST request")
self.set_status(403, "Wrong request, server handles only POST requests")
......@@ -101,7 +107,7 @@ class DecodeRequestHandler(tornado.web.RequestHandler):
logging.debug("POST request from %s does not contain 'file_to_transcript' field.")
temp_file = self.request.files['wavFile'][0]['body']
self.temp_file = temp_file
#Writing file
try:
f = open(TEMP_FILE_PATH+self.uuid+'.wav', 'wb')
......@@ -117,6 +123,8 @@ class DecodeRequestHandler(tornado.web.RequestHandler):
@gen.coroutine
def post(self, *args, **kwargs):
logging.debug("Allocating Worker to %s" % self.uuid)
logging.info(self.designation)
yield self.allocate_worker()
self.worker.write_message(json.dumps({'uuid':self.uuid, 'file': self.temp_file.encode('base64')}))
yield self.waitResponse.wait()
......
......@@ -4,4 +4,10 @@ docker build -t linagora/stt-offline .
# Start
Path_model=$1
port=$2
docker run --rm -it -p $port:5000 -v $Path_model:/opt/models linagora/stt-offline
\ No newline at end of file
model_type=$3
if [ -z "${model_type}" ]; then
model_type="uc1"
fi
docker run --rm -it -p $port:5000 -v $Path_model:/opt/models -e MODEL_TYPE=$model_type linagora/stt-offline
\ No newline at end of file
......@@ -28,11 +28,14 @@ DECODER_COMMAND = worker_settings.get('worker_params', 'decoder_command')
TEMP_FILE_PATH = worker_settings.get('worker_params', 'temp_file_location')
PREPROCESSING = True if worker_settings.get('worker_params', 'preprocessing') == 'true' else False
INDICE_DATA = True if worker_settings.get('worker_params', 'indice_data') == 'true' else False
MODEL_TYPE = "UC1"
if "OFFLINE_PORT" in os.environ:
SERVER_PORT = os.environ['OFFLINE_PORT']
if "MODEL_TYPE" in os.environ:
MODEL_TYPE = os.environ['MODEL_TYPE']
class NoRouteException(Exception):
pass
class ConnexionRefusedException(Exception):
......@@ -134,12 +137,14 @@ def connect_to_server(ws):
def main():
parser = argparse.ArgumentParser(description='Worker for linstt-dispatch')
parser.add_argument('-u', '--uri', default="ws://"+SERVER_IP+":"+SERVER_PORT+SERVER_TARGET, dest="uri", help="Server<-->worker websocket URI")
parser.add_argument('-m', '--model', default=MODEL_TYPE, type=str ,help="Identifiant of the model")
args = parser.parse_args()
#thread.start_new_thread(loop.run, ())
if not os.path.isdir(TEMP_FILE_PATH):
os.mkdir(TEMP_FILE_PATH)
print('#'*50)
logging.basicConfig(level=logging.DEBUG, format="%(levelname)8s %(asctime)s %(message)s ")
logging.info('Starting up worker')
ws = WorkerWebSocket(args.uri)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment