def load_model_from_url(url):
# TODO: move this into a class..
global scoring_model
url_opener = urllib.URLopener()
temp_model_path = get_temp_model_path()
url_opener.retrieve(url, temp_model_path)
# try to load the model:
try:
temp_model = ScoringModel.from_file(temp_model_path)
except Exception as e:
print "Failed to load donwloaded model: %s"%e
os.remove(temp_model_path)
raise RuntimeError("Failed to load donwloaded model! error: %s"%e)
# update model:
scoring_model = temp_model
# delete existing model
if (path.isfile(model_file_path)):
os.remove(model_file_path)
os.rename(temp_model_path, model_file_path)
# TODO: move this to an object with an init function...
评论列表
文章目录