app_engine.py 1.7 KB
Newer Older
Z
Zhipeng Xie 已提交
1 2
#!/usr/bin/python3
# -*- coding: utf-8 -*-
W
willwolf 已提交
3
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
Z
Zhipeng Xie 已提交
4 5 6 7 8 9 10 11 12 13 14
# A-Tune is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Create: 2020-07-17

"""
W
willwolf 已提交
15
Engine application implementation.
Z
Zhipeng Xie 已提交
16 17 18 19
"""

import os
import sys
W
willwolf 已提交
20 21

from app import App
Z
Zhipeng Xie 已提交
22 23 24 25 26

sys.path.insert(0, os.path.dirname(__file__) + "/../")
from analysis.engine import optimizer, classification, train, transfer


W
willwolf 已提交
27 28
class AppEngine(App):
    """app engine"""
Z
Zhipeng Xie 已提交
29

W
willwolf 已提交
30 31 32 33 34 35 36 37
    def add_resource(self):
        """flask app add resource"""
        self.api.add_resource(optimizer.Optimizer, '/v1/optimizer',
                              '/v1/optimizer/<string:task_id>')
        self.api.add_resource(classification.Classification, '/v1/classification',
                              '/v1/classification')
        self.api.add_resource(train.Training, '/v1/training', '/v1/training')
        self.api.add_resource(transfer.Transfer, '/v1/transfer', '/transfer')
Z
Zhipeng Xie 已提交
38 39 40 41


def main(filename):
    """app main function"""
W
willwolf 已提交
42 43 44 45
    app_engine = AppEngine()
    app_engine.startup_app(filename, "engine_host", "engine_port", "engine_tls",
                           "tlsengineservercertfile", "tlsengineserverkeyfile",
                           "tlsenginecacertfile")
Z
Zhipeng Xie 已提交
46 47 48 49 50 51


if __name__ == '__main__':
    if len(sys.argv) != 2:
        sys.exit(-1)
    main(sys.argv[1])