def __init__( self, labels, custom_model_dir, docker=None, with_error_server=False, show_stacktrace=True, nginx=False, ): port = CMRunnerUtils.find_free_port() server_address = "localhost:{}".format(port) url_host = os.environ.get("TEST_URL_HOST", "localhost") if docker: self.url_server_address = "http://{}:{}".format(url_host, port) else: self.url_server_address = "http://localhost:{}".format(port) cmd = "{} server --code-dir {} --address {}".format( ArgumentsOptions.MAIN_COMMAND, custom_model_dir, server_address ) if labels: cmd = _cmd_add_class_labels(cmd, labels) if docker: cmd += " --docker {}".format(docker) if with_error_server: cmd += " --with-error-server" if show_stacktrace: cmd += " --show-stacktrace" if nginx: cmd += " --production" self._cmd = cmd self._process_object_holder = DrumServerProcess() self._server_thread = None self._with_nginx = nginx
def __init__(self, options, run_mode, target_type=None): self.options = options self.target_type = target_type self._verbose = self.options.verbose self._input_csv = self.options.input self._input_df = pd.read_csv(self._input_csv) self._server_addr = "localhost" self._server_port = CMRunnerUtils.find_free_port() self._url_server_address = "http://{}:{}".format(self._server_addr, self._server_port) self._shutdown_endpoint = "/shutdown/" self._predict_endpoint = "/predict/" self._stats_endpoint = "/stats/" self._timeout = 20 self._server_process = None self._df_for_test = None self._test_cases_to_run = None
def __init__(self, options, run_mode): self.options = options self._input_csv = self.options.input self._server_addr = "localhost" self._server_port = CMRunnerUtils.find_free_port() self._url_server_address = "http://{}:{}".format( self._server_addr, self._server_port) self._shutdown_endpoint = "/shutdown/" self._predict_endpoint = "/predict/" self._stats_endpoint = "/stats/" self._timeout = 20 self._server_process = None self._df_for_test = None self._test_cases_to_run = None if run_mode == RunMode.PERF_TEST: self._prepare_test_cases()
def __init__( self, target_type, labels, custom_model_dir, docker=None, with_error_server=False, show_stacktrace=True, nginx=False, memory=None, fail_on_shutdown_error=True, pass_args_as_env_vars=False, verbose=True, append_cmd=None, ): port = CMRunnerUtils.find_free_port() self.server_address = "localhost:{}".format(port) url_host = os.environ.get("TEST_URL_HOST", "localhost") if docker: self.url_server_address = "http://{}:{}".format(url_host, port) else: self.url_server_address = "http://localhost:{}".format(port) cmd = "{} server".format(ArgumentsOptions.MAIN_COMMAND) if pass_args_as_env_vars: os.environ[ArgumentOptionsEnvVars.CODE_DIR] = str(custom_model_dir) os.environ[ArgumentOptionsEnvVars.TARGET_TYPE] = target_type os.environ[ArgumentOptionsEnvVars.ADDRESS] = self.server_address else: cmd += " --code-dir {} --target-type {} --address {}".format( custom_model_dir, target_type, self.server_address ) if labels: cmd = _cmd_add_class_labels( cmd, labels, target_type=target_type, pass_args_as_env_vars=pass_args_as_env_vars ) if docker: cmd += " --docker {}".format(docker) if memory: cmd += " --memory {}".format(memory) if with_error_server: if pass_args_as_env_vars: os.environ[ArgumentOptionsEnvVars.WITH_ERROR_SERVER] = "1" else: cmd += " --with-error-server" if show_stacktrace: if pass_args_as_env_vars: os.environ[ArgumentOptionsEnvVars.SHOW_STACKTRACE] = "1" else: cmd += " --show-stacktrace" if nginx: if pass_args_as_env_vars: os.environ[ArgumentOptionsEnvVars.PRODUCTION] = "1" else: cmd += " --production" if append_cmd is not None: cmd += " " + append_cmd self._cmd = cmd self._process_object_holder = DrumServerProcess() self._server_thread = None self._with_nginx = nginx self._fail_on_shutdown_error = fail_on_shutdown_error self._verbose = verbose