Source code for mmlspark.io.http.HTTPTransformer

# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in project root for information.


import sys
if sys.version >= '3':
    basestring = str

from pyspark.ml.param.shared import *
from pyspark import keyword_only
from pyspark.ml.util import JavaMLReadable, JavaMLWritable
from mmlspark.core.serialize.java_params_patch import *
from pyspark.ml.wrapper import JavaTransformer, JavaEstimator, JavaModel
from pyspark.ml.common import inherit_doc
from mmlspark.core.schema.Utils import *
from mmlspark.core.schema.TypeConversionUtils import generateTypeConverter, complexTypeConverter

[docs]@inherit_doc class HTTPTransformer(ComplexParamsMixin, JavaMLReadable, JavaMLWritable, JavaTransformer): """ Args: concurrency (int): max number of concurrent calls (default: 1) concurrentTimeout (double): max number seconds to wait on futures if concurrency >= 1 (default: 100.0) handler (object): Which strategy to use when handling requests (default: UserDefinedFunction(<function2>,StringType,None)) inputCol (str): The name of the input column outputCol (str): The name of the output column timeout (double): number of seconds to wait before closing the connection (default: 60.0) """ @keyword_only def __init__(self, concurrency=1, concurrentTimeout=100.0, handler=None, inputCol=None, outputCol=None, timeout=60.0): super(HTTPTransformer, self).__init__() self._java_obj = self._new_java_obj("com.microsoft.ml.spark.io.http.HTTPTransformer") self._cache = {} self.concurrency = Param(self, "concurrency", "concurrency: max number of concurrent calls (default: 1)") self._setDefault(concurrency=1) self.concurrentTimeout = Param(self, "concurrentTimeout", "concurrentTimeout: max number seconds to wait on futures if concurrency >= 1 (default: 100.0)") self._setDefault(concurrentTimeout=100.0) self.handler = Param(self, "handler", "handler: Which strategy to use when handling requests (default: UserDefinedFunction(<function2>,StringType,None))", generateTypeConverter("handler", self._cache, complexTypeConverter)) self.inputCol = Param(self, "inputCol", "inputCol: The name of the input column") self.outputCol = Param(self, "outputCol", "outputCol: The name of the output column") self.timeout = Param(self, "timeout", "timeout: number of seconds to wait before closing the connection (default: 60.0)") self._setDefault(timeout=60.0) if hasattr(self, "_input_kwargs"): kwargs = self._input_kwargs else: kwargs = self.__init__._input_kwargs self.setParams(**kwargs)
[docs] @keyword_only def setParams(self, concurrency=1, concurrentTimeout=100.0, handler=None, inputCol=None, outputCol=None, timeout=60.0): """ Set the (keyword only) parameters Args: concurrency (int): max number of concurrent calls (default: 1) concurrentTimeout (double): max number seconds to wait on futures if concurrency >= 1 (default: 100.0) handler (object): Which strategy to use when handling requests (default: UserDefinedFunction(<function2>,StringType,None)) inputCol (str): The name of the input column outputCol (str): The name of the output column timeout (double): number of seconds to wait before closing the connection (default: 60.0) """ if hasattr(self, "_input_kwargs"): kwargs = self._input_kwargs else: kwargs = self.__init__._input_kwargs return self._set(**kwargs)
[docs] def setConcurrency(self, value): """ Args: concurrency (int): max number of concurrent calls (default: 1) """ self._set(concurrency=value) return self
[docs] def getConcurrency(self): """ Returns: int: max number of concurrent calls (default: 1) """ return self.getOrDefault(self.concurrency)
[docs] def setConcurrentTimeout(self, value): """ Args: concurrentTimeout (double): max number seconds to wait on futures if concurrency >= 1 (default: 100.0) """ self._set(concurrentTimeout=value) return self
[docs] def getConcurrentTimeout(self): """ Returns: double: max number seconds to wait on futures if concurrency >= 1 (default: 100.0) """ return self.getOrDefault(self.concurrentTimeout)
[docs] def setHandler(self, value): """ Args: handler (object): Which strategy to use when handling requests (default: UserDefinedFunction(<function2>,StringType,None)) """ self._set(handler=value) return self
[docs] def getHandler(self): """ Returns: object: Which strategy to use when handling requests (default: UserDefinedFunction(<function2>,StringType,None)) """ return self._cache.get("handler", None)
[docs] def setInputCol(self, value): """ Args: inputCol (str): The name of the input column """ self._set(inputCol=value) return self
[docs] def getInputCol(self): """ Returns: str: The name of the input column """ return self.getOrDefault(self.inputCol)
[docs] def setOutputCol(self, value): """ Args: outputCol (str): The name of the output column """ self._set(outputCol=value) return self
[docs] def getOutputCol(self): """ Returns: str: The name of the output column """ return self.getOrDefault(self.outputCol)
[docs] def setTimeout(self, value): """ Args: timeout (double): number of seconds to wait before closing the connection (default: 60.0) """ self._set(timeout=value) return self
[docs] def getTimeout(self): """ Returns: double: number of seconds to wait before closing the connection (default: 60.0) """ return self.getOrDefault(self.timeout)
[docs] @classmethod def read(cls): """ Returns an MLReader instance for this class. """ return JavaMMLReader(cls)
[docs] @staticmethod def getJavaPackage(): """ Returns package name String. """ return "com.microsoft.ml.spark.io.http.HTTPTransformer"
@staticmethod def _from_java(java_stage): module_name=HTTPTransformer.__module__ module_name=module_name.rsplit(".", 1)[0] + ".HTTPTransformer" return from_java(java_stage, module_name)