def base_client_product_view(request):

    try:
        from dbhelper.main.dbhelper import HelperRuntime
        import numpy as np
        import json

        inputs = request.json['inputs']

        helper = HelperRuntime()

        model_retrieved = ModelRetriever.get_model(
            app=request.matchdict.get("app"),
            model_name=request.matchdict.get("model_name"),
            version=request.matchdict.get("version"),
            client=request.matchdict.get("client"),
            product=request.matchdict.get("product"))

        model = model_retrieved.model
        io_template = model_retrieved.io_template

        template_inputs = eval(io_template["input"])

        outputs = model.predict(template_inputs)

        template_outputs = eval(io_template["output"])

        return {"output": template_outputs}

    except:
        response = generate_bad_request()
        return response
def deploy_model_view(request):

    try:
        instance_info = request.matchdict

        ModelRetriever.search_model(app=instance_info['app'], model_name=instance_info['model_name'],
                                    version=instance_info['version'])

        return {"model": instance_info['model_name'],
                "version": instance_info['version'],
                "app": instance_info['app'],
                "status": "Ready"}

    except:
        response = generate_bad_request()
        return response
def data_template_view(request):

    try:
        from dbhelper.main.dbhelper import HelperRuntime

        helper = HelperRuntime()

        model_retrieved = ModelRetriever.get_model(
            app=request.matchdict.get("app"),
            model_name=request.matchdict.get("model_name"),
            version=request.matchdict.get("version"))

        return model_retrieved.io_template

    except:
        response = generate_bad_request()
        return response