rasa/core/server.py
async def load_model(request: Request):
        """Loads a zipped model, replacing the existing one."""

        if 'model' not in request.files:
            # model file is missing
            raise ErrorResponse(400, "InvalidParameter",
                                "You did not supply a model as part of your "
                                "request.",
                                {"parameter": "model", "in": "body"})

        model_file = request.files['model']

        logger.info("Received new model through REST interface.")
        zipped_path = tempfile.NamedTemporaryFile(delete=False, suffix=".zip")
        zipped_path.close()
        model_directory = tempfile.mkdtemp()

        model_file.save(zipped_path.name)

        logger.debug("Downloaded model to {}".format(zipped_path.name))

        zip_ref = zipfile.ZipFile(zipped_path.name, 'r')
        zip_ref.extractall(model_directory)
        zip_ref.close()
        logger.debug("Unzipped model to {}".format(
            os.path.abspath(model_directory)))

        domain_path = os.path.join(os.path.abspath(model_directory),
                                   "domain.yml")
        domain = Domain.load(domain_path)
        ensemble = PolicyEnsemble.load(model_directory)
        app.agent.update_model(domain, ensemble, None)
        logger.debug("Finished loading new agent.")
        return response.text('', 204)
Loads a zipped model, replacing the existing one.
Loads a zipped model, replacing the existing one.
Loads a zipped model replacing the existing one .
async def load_model(request: Request):
        if 'model' not in request.files:
            raise ErrorResponse(400, "InvalidParameter",
                                "You did not supply a model as part of your "
                                "request.",
                                {"parameter": "model", "in": "body"})
        model_file = request.files['model']
        logger.info("Received new model through REST interface.")
        zipped_path = tempfile.NamedTemporaryFile(delete=False, suffix=".zip")
        zipped_path.close()
        model_directory = tempfile.mkdtemp()
        model_file.save(zipped_path.name)
        logger.debug("Downloaded model to {}".format(zipped_path.name))
        zip_ref = zipfile.ZipFile(zipped_path.name, 'r')
        zip_ref.extractall(model_directory)
        zip_ref.close()
        logger.debug("Unzipped model to {}".format(
            os.path.abspath(model_directory)))
        domain_path = os.path.join(os.path.abspath(model_directory),
                                   "domain.yml")
        domain = Domain.load(domain_path)
        ensemble = PolicyEnsemble.load(model_directory)
        app.agent.update_model(domain, ensemble, None)
        logger.debug("Finished loading new agent.")
        return response.text('', 204)
async def load_model ( request : Request ) : if 'model' not in request . files : raise ErrorResponse ( 400 , "InvalidParameter" , "You did not supply a model as part of your " "request." , { "parameter" : "model" , "in" : "body" } ) model_file = request . files [ 'model' ] logger . info ( "Received new model through REST interface." ) zipped_path = tempfile . NamedTemporaryFile ( delete = False , suffix = ".zip" ) zipped_path . close ( ) model_directory = tempfile . mkdtemp ( ) model_file . save ( zipped_path . name ) logger . debug ( "Downloaded model to {}" . format ( zipped_path . name ) ) zip_ref = zipfile . ZipFile ( zipped_path . name , 'r' ) zip_ref . extractall ( model_directory ) zip_ref . close ( ) logger . debug ( "Unzipped model to {}" . format ( os . path . abspath ( model_directory ) ) ) domain_path = os . path . join ( os . path . abspath ( model_directory ) , "domain.yml" ) domain = Domain . load ( domain_path ) ensemble = PolicyEnsemble . load ( model_directory ) app . agent . update_model ( domain , ensemble , None ) logger . debug ( "Finished loading new agent." ) return response . text ( '' , 204 )
Loads a zipped model, replacing the existing one.
Loads a zipped model replacing the existing one .
"""Loads a zipped model, replacing the existing one.""" # model file is missing
request
Request