def configure(self, params):
        super(PredictionServer, self).configure(params)
        self._show_perf = self._params.get("show_perf")
        self._run_language = RunLanguage(params.get("run_language"))
        self._target_type = TargetType(params[TARGET_TYPE_ARG_KEYWORD])

        self._stats_collector = StatsCollector(
            disable_instance=not self._show_perf)

        self._stats_collector.register_report("run_predictor_total", "finish",
                                              StatsOperation.SUB, "start")
        self._memory_monitor = MemoryMonitor(monitor_current_process=True)

        if self._run_language == RunLanguage.PYTHON:
            from datarobot_drum.drum.language_predictors.python_predictor.python_predictor import (
                PythonPredictor, )

            self._predictor = PythonPredictor()
        elif self._run_language == RunLanguage.JAVA:
            from datarobot_drum.drum.language_predictors.java_predictor.java_predictor import (
                JavaPredictor, )

            self._predictor = JavaPredictor()
        elif self._run_language == RunLanguage.R:
            # this import is here, because RPredictor imports rpy library,
            # which is not installed for Java and Python cases.
            from datarobot_drum.drum.language_predictors.r_predictor.r_predictor import RPredictor

            self._predictor = RPredictor()
        else:
            raise DrumCommonException(
                "Prediction server doesn't support language: {} ".format(
                    self._run_language))

        self._predictor.configure(params)
    def configure(self, params):
        super(GenericPredictorComponent, self).configure(params)
        self._run_language = RunLanguage(params.get("run_language"))
        self._target_type = TargetType(params[TARGET_TYPE_ARG_KEYWORD])

        if self._run_language == RunLanguage.PYTHON:
            from datarobot_drum.drum.language_predictors.python_predictor.python_predictor import (
                PythonPredictor, )

            self._predictor = PythonPredictor()
        elif self._run_language == RunLanguage.JAVA:
            from datarobot_drum.drum.language_predictors.java_predictor.java_predictor import (
                JavaPredictor, )

            self._predictor = JavaPredictor()
        elif self._run_language == RunLanguage.R:
            # this import is here, because RPredictor imports rpy library,
            # which is not installed for Java and Python cases.
            from datarobot_drum.drum.language_predictors.r_predictor.r_predictor import RPredictor

            self._predictor = RPredictor()
        else:
            raise DrumCommonException(
                "Prediction server doesn't support language: {} ".format(
                    self._run_language))

        self._predictor.configure(params)
예제 #3
0
    def _resolve_target_type(self):
        if self.run_mode == RunMode.NEW:
            return

        target_type_options = getattr(self.options, "target_type", None)
        target_type_options = (None if target_type_options is None else
                               TargetType(target_type_options))
        target_type_model_config = None

        if self.options.model_config is not None:
            target_type_model_config = TargetType(
                self.options.model_config["targetType"])

        if target_type_options is None and target_type_model_config is None:
            raise DrumCommonException(
                "Target type is missing. It must be provided in --target-type argument, {} env var or model config file."
                .format(ArgumentOptionsEnvVars.TARGET_TYPE))
        elif (all([target_type_options, target_type_model_config])
              and target_type_options != target_type_model_config):
            raise DrumCommonException(
                "Target type provided in --target-type argument doesn't match target type from model config file. "
                "Use either one of them or make them match.")
        else:
            self.target_type = (target_type_options if target_type_options
                                is not None else target_type_model_config)

        if self.target_type != TargetType.UNSTRUCTURED:
            if getattr(self.options, "query", None):
                raise DrumCommonException(
                    "--query argument can be used only with --target-type unstructured"
                )
            if getattr(self.options, "content_type", None):
                raise DrumCommonException(
                    "--content-type argument can be used only with --target-type unstructured"
                )
        else:
            if self.options.content_type is None:
                self.options.content_type = "text/plain; charset=utf8"
예제 #4
0
    def _resolve_target_type(self):
        target_type_options = None
        target_type_model_config = None

        if hasattr(self.options,
                   "target_type") and self.options.target_type is not None:
            target_type_options = TargetType(self.options.target_type)

        if self.options.model_config is not None:
            target_type_model_config = TargetType(
                self.options.model_config["targetType"])

        if self.run_mode not in [RunMode.NEW]:
            if target_type_options is None and target_type_model_config is None:
                raise DrumCommonException(
                    "Target type is missing. It must be provided in either --target-type argument or model config file."
                )
            elif (all([target_type_options, target_type_model_config])
                  and target_type_options != target_type_model_config):
                raise DrumCommonException(
                    "Target type provided in --target-type argument doesn't match target type from model config file."
                    "Use either one of them or make them match.")
            else:
                self.target_type = (target_type_options if target_type_options
                                    is not None else target_type_model_config)

        if self.target_type != TargetType.UNSTRUCTURED:
            if getattr(self.options, "query", None):
                raise DrumCommonException(
                    "--query argument can be used only with --target-type unstructured"
                )
            if getattr(self.options, "content_type", None):
                raise DrumCommonException(
                    "--content-type argument can be used only with --target-type unstructured"
                )
        else:
            if self.options.content_type is None:
                self.options.content_type = "text/plain; charset=utf8"
예제 #5
0
    def configure(self, params):
        self._custom_model_path = params["__custom_model_path__"]
        self._positive_class_label = params.get("positiveClassLabel")
        self._negative_class_label = params.get("negativeClassLabel")
        self._target_type = TargetType(params.get("target_type"))
        self._params = params

        if self._params["monitor"] == "True":
            if not mlops_loaded:
                raise Exception("MLOps module was not imported: {}".format(
                    mlops_import_error))
            # TODO: if server use async, if batch, use sync etc.. some way of passing params
            self._mlops = (MLOps().set_model_id(
                self._params["model_id"]).set_deployment_id(
                    self._params["deployment_id"]).set_channel_config(
                        self._params["monitor_settings"]).init())
예제 #6
0
    def configure(self, params):
        """
        @brief      It is called in within the 'deputy' context
        """
        super(UwsgiServing, self).configure(params)
        self._show_perf = self._params.get("show_perf")
        self._run_language = RunLanguage(params.get("run_language"))
        self._target_type = TargetType(params[TARGET_TYPE_ARG_KEYWORD])

        self._stats_collector = StatsCollector(disable_instance=not self._show_perf)

        self._stats_collector.register_report(
            "run_predictor_total", "finish", StatsOperation.SUB, "start"
        )
        self._memory_monitor = MemoryMonitor()

        self._logger.info(
            "Configure component with input params, name: {}, params: {}".format(
                self.name(), params
            )
        )