-
Notifications
You must be signed in to change notification settings - Fork 23
/
run_backend.py
68 lines (55 loc) · 2.11 KB
/
run_backend.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright 2022 Cisco Systems, Inc. and its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
import argparse
from multiprocessing import Process
import yaml
from tinydb import TinyDB, Query
from backend.server import create_app, run_app_server, create_server_config
from frontend.app import run_client
if __name__ == "__main__":
# es = Elasticsearch(['http://localhost:9200/'], verify_certs=True)
# if not es.ping():
# run_elastic_search_service = subprocess.Popen(
# ["./elasticsearch"], cwd="../elasticsearch/bin")
db = TinyDB('config.json')
db.drop_tables()
Config = Query()
parser = argparse.ArgumentParser()
parser.add_argument('yaml_file',
help='YAML file that describes the NLP pipeline',
)
parser.add_argument('-p', type=int, default=5001,
required=False, help="defines port ot be used")
args = parser.parse_args()
with open(args.yaml_file, mode="rt", encoding="utf-8") as file:
data = yaml.safe_load(file)
db.insert({
"type":"yaml_config",
"config":data
})
config = create_server_config(data)
app,sockio = create_app(data)
port = args.p
run_app_server(app,sockio,3000,'0.0.0.0')
# p_dash = Process(target=run_client, args=(data, port, '0.0.0.0'))
# p_serv = Process(target=run_app_server, args=(app,sockio, 3000, '0.0.0.0'))
# p_dash.start()
# try:
# p_serv.start()
# p_serv.join()
# except:
# print("Flask server may already be running!")
# p_dash.join()