コード例 #1
0
    async def get_application(self):
        deepaas.model.v1.register_models()

        app = web.Application(debug=True)
        v1app = v1.get_app()
        app.add_subapp("/v1", v1app)

        return app
コード例 #2
0
    async def get_application(self):
        app = web.Application(debug=True)
        app.add_routes(versions.routes)

        app.add_subapp("/v1", v1.get_app())
        app.add_subapp("/v2", v2.get_app())

        versions.Versions.versions = {}

        return app
コード例 #3
0
    async def get_application(self):
        app = web.Application(debug=True)
        app.add_routes(versions.routes)

        app.add_subapp("/v1", v1.get_app())
        app.add_subapp("/v2", v2.get_app())

        versions.Versions.versions = {}

        aiohttp_apispec.setup_aiohttp_apispec(app=app,
                                              url="/swagger.json",
                                              swagger_path="/ui")

        return app
コード例 #4
0
async def get_app(swagger=True,
                  doc="/ui",
                  prefix="",
                  enable_train=True,
                  enable_predict=True):
    """Get the main app."""
    global APP

    if APP:
        return APP

    APP = web.Application(debug=CONF.debug,
                          client_max_size=CONF.client_max_size)

    APP.middlewares.append(web.normalize_path_middleware())

    if CONF.enable_v1:
        LOG.warning("Using V1 version of the API is not anymore supported "
                    "and marked as deprecated, please switch to V2 as soon "
                    "as possible.")

        from deepaas.api import v1  # noqa

        model.register_v1_models()

        v1app = v1.get_app()
        APP.add_subapp("/v1", v1app)
        versions.register_version("deprecated", v1.get_version)

        LOG.info("Serving loaded V1 models: %s", list(model.V1_MODELS.keys()))

    model.register_v2_models(APP)

    v2app = v2.get_app(enable_train=enable_train,
                       enable_predict=enable_predict)
    APP.add_subapp("/v2", v2app)
    versions.register_version("stable", v2.get_version)

    APP.add_routes(versions.routes)

    LOG.info("Serving loaded V2 models: %s", list(model.V2_MODELS.keys()))

    if CONF.warm:
        for _, m in model.V2_MODELS.items():
            LOG.debug("Warming models...")
            await m.warm()

    if swagger:
        # init docs with all parameters, usual for ApiSpec
        aiohttp_apispec.setup_aiohttp_apispec(
            app=APP,
            title="DEEP as a Service API endpoint",
            info={
                "description": API_DESCRIPTION,
                "license": {
                    "name": "Apache 2.0",
                    "url": "http://www.apache.org/licenses/LICENSE-2.0.html",
                },
                "contact": {
                    "email": "*****@*****.**"
                },
            },
            externalDocs={
                "description": "API documentation",
                "url": "https://deepaas.readthedocs.org/",
            },
            version=deepaas.__version__,
            url="/swagger.json",
            swagger_path=doc if doc else None,
            prefix=prefix,
            in_place=True,
        )

    return APP