Get rid of the load_model utility function

This commit is contained in:
Marco Castelluccio 2020-11-19 23:40:59 +01:00
Родитель bfc1fa3a85
Коммит a1475fd7cd
3 изменённых файлов: 5 добавлений и 14 удалений

Просмотреть файл

@ -50,12 +50,3 @@ def get_model_class(model_name):
full_qualified_class_name = MODELS[model_name]
return load_model_class(full_qualified_class_name)
def load_model(model_name):
model_class = get_model_class(model_name)
model_file_path = f"{model_name}model"
LOGGER.debug(f"Lookup model in {model_file_path}")
return model_class.load(model_file_path)

Просмотреть файл

@ -17,7 +17,6 @@ from redis import Redis
from bugbug import bugzilla, repository
from bugbug.model import Model
from bugbug.models import load_model
from bugbug.utils import get_hgmo_stack
from bugbug_http.readthrough_cache import ReadthroughTTLCache
@ -38,7 +37,7 @@ DEFAULT_EXPIRATION_TTL = 7 * 24 * 3600 # A week
redis = Redis.from_url(os.environ.get("REDIS_URL", "redis://localhost/0"))
MODEL_CACHE: ReadthroughTTLCache[str, Model] = ReadthroughTTLCache(
timedelta(hours=1), load_model
timedelta(hours=1), lambda m: Model.load(f"{m}model")
)
MODEL_CACHE.start_ttl_thread()

Просмотреть файл

@ -9,7 +9,8 @@ import os
import random
from bugbug import bugzilla
from bugbug.models import load_model
from bugbug.models.bug import BugModel
from bugbug.models.regression import RegressionModel
parser = argparse.ArgumentParser()
parser.add_argument(
@ -21,9 +22,9 @@ parser.add_argument(
args = parser.parse_args()
if args.goal == "str":
model = load_model("bug")
model = BugModel.load("bugmodel")
elif args.goal == "regressionrange":
model = load_model("regression")
model = RegressionModel.load("regressionmodel")
file_path = os.path.join("bugbug", "labels", f"{args.goal}.csv")