in src/vw-serving/src/vw_serving/vw_model.py [0:0]
def __init__(self, model_path=None, cli_args="", test_only=True, quiet_mode=True):
"""
Args:
model_path (str): location of the model weights
cli_args (str): additional args to pass to VW
"""
self.logger = logging.getLogger("vw_model.VWModel")
self.logger.info("creating an instance of VWModel")
# if a model does not have a current proc it is
# uninitialized
self.closed = False
self.current_proc = None
self.test_mode = test_only
if len(cli_args) == 0:
raise VWError("No arguments specified to create/load a VW model.")
# command arguments for shell process
# we redirect the score to /dev/stdout to capture it
self.cmd = ["vw", *cli_args.split(), "-p", "/dev/stdout"]
if quiet_mode:
self.cmd.append("--quiet")
if self.test_mode:
self.cmd.extend(["--testonly"])
if model_path:
self.model_file = os.path.expanduser(os.path.expandvars(model_path))
self.cmd.extend(["-i", self.model_file])
self.logger.info("successfully created VWModel")
self.logger.info("command: %s", self.cmd)