(self, config_file)
Read the config file and pre-/load the models
Read the config file and pre-/load the models
Read the config file and pre - / load the models
def start(self, config_file):
        """Read the config file and pre-/load the models
        """
        self.config_file = config_file
        with open(self.config_file) as f:
            self.confs = json.load(f)

        self.models_root = self.confs.get('models_root', './available_models')
        for i, conf in enumerate(self.confs["models"]):
            if "models" not in conf:
                if "model" in conf:
                    # backwards compatibility for confs
                    conf["models"] = [conf["model"]]
                else:
                    raise ValueError("""Incorrect config file: missing 'models'
                                        parameter for model #%d""" % i)
            kwargs = {'timeout': conf.get('timeout', None),
                      'load': conf.get('load', None),
                      'tokenizer_opt': conf.get('tokenizer', None),
                      'on_timeout': conf.get('on_timeout', None),
                      'model_root': conf.get('model_root', self.models_root)
                      }
            kwargs = {k: v for (k, v) in kwargs.items() if v is not None}
            model_id = conf.get("id", None)
            opt = conf["opt"]
            opt["models"] = conf["models"]
            self.preload_model(opt, model_id=model_id, **kwargs)
def start ( self , config_file ) : self . config_file = config_file with open ( self . config_file ) as f : self . confs = json . load ( f ) self . models_root = self . confs . get ( 'models_root' , './available_models' ) for i , conf in enumerate ( self . confs [ "models" ] ) : if "models" not in conf : if "model" in conf : # backwards compatibility for confs conf [ "models" ] = [ conf [ "model" ] ] else : raise ValueError ( """Incorrect config file: missing 'models'
                                        parameter for model #%d""" % i ) kwargs = { 'timeout' : conf . get ( 'timeout' , None ) , 'load' : conf . get ( 'load' , None ) , 'tokenizer_opt' : conf . get ( 'tokenizer' , None ) , 'on_timeout' : conf . get ( 'on_timeout' , None ) , 'model_root' : conf . get ( 'model_root' , self . models_root ) } kwargs = { k : v for ( k , v ) in kwargs . items ( ) if v is not None } model_id = conf . get ( "id" , None ) opt = conf [ "opt" ] opt [ "models" ] = conf [ "models" ] self . preload_model ( opt , model_id = model_id , * * kwargs )