Source code for SimpleHTTPTransformer

# 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 pyspark.ml.wrapper import JavaTransformer, JavaEstimator, JavaModel
from pyspark.ml.common import inherit_doc
from mmlspark.Utils import *
from mmlspark.TypeConversionUtils import generateTypeConverter, complexTypeConverter

[docs]@inherit_doc class SimpleHTTPTransformer(ComplexParamsMixin, JavaMLReadable, JavaMLWritable, JavaTransformer): """ Args: backoffTiming (object): times to use in backoffs (default: [I@22af2ee9) concurrency (int): max number of concurrent calls (default: 1) concurrentTimeout (double): max number seconds to wait on futures if concurrency >= 1 (default: 100.0) errorCol (str): column to hold http errors (default: [self.uid]_errors) flattenOutputBatches (bool): whether to flatten the output batches (default: false) handlingStrategy (str): Which strategy to use when handling requests (default: advanced) inputCol (str): The name of the input column inputParser (object): format to parse the column to (default: JSONInputParser_fb7a4fa14efe) miniBatcher (object): Minibatcher to use outputCol (str): The name of the output column outputParser (object): format to parse the column to """ @keyword_only def __init__(self, backoffTiming="[I@22af2ee9", concurrency=1, concurrentTimeout=100.0, errorCol=None, flattenOutputBatches=False, handlingStrategy="advanced", inputCol=None, inputParser=None, miniBatcher=None, outputCol=None, outputParser=None): super(SimpleHTTPTransformer, self).__init__() self._java_obj = self._new_java_obj("com.microsoft.ml.spark.SimpleHTTPTransformer") self._cache = {} self.backoffTiming = Param(self, "backoffTiming", "backoffTiming: times to use in backoffs (default: [I@22af2ee9)") self._setDefault(backoffTiming="[I@22af2ee9") 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.errorCol = Param(self, "errorCol", "errorCol: column to hold http errors (default: [self.uid]_errors)") self._setDefault(errorCol=self.uid + "_errors") self.flattenOutputBatches = Param(self, "flattenOutputBatches", "flattenOutputBatches: whether to flatten the output batches (default: false)") self._setDefault(flattenOutputBatches=False) self.handlingStrategy = Param(self, "handlingStrategy", "handlingStrategy: Which strategy to use when handling requests (default: advanced)") self._setDefault(handlingStrategy="advanced") self.inputCol = Param(self, "inputCol", "inputCol: The name of the input column") self.inputParser = Param(self, "inputParser", "inputParser: format to parse the column to (default: JSONInputParser_fb7a4fa14efe)", generateTypeConverter("inputParser", self._cache, complexTypeConverter)) self.miniBatcher = Param(self, "miniBatcher", "miniBatcher: Minibatcher to use", generateTypeConverter("miniBatcher", self._cache, complexTypeConverter)) self.outputCol = Param(self, "outputCol", "outputCol: The name of the output column") self.outputParser = Param(self, "outputParser", "outputParser: format to parse the column to", generateTypeConverter("outputParser", self._cache, complexTypeConverter)) if hasattr(self, "_input_kwargs"): kwargs = self._input_kwargs else: kwargs = self.__init__._input_kwargs self.setParams(**kwargs)
[docs] @keyword_only def setParams(self, backoffTiming="[I@22af2ee9", concurrency=1, concurrentTimeout=100.0, errorCol=None, flattenOutputBatches=False, handlingStrategy="advanced", inputCol=None, inputParser=None, miniBatcher=None, outputCol=None, outputParser=None): """ Set the (keyword only) parameters Args: backoffTiming (object): times to use in backoffs (default: [I@22af2ee9) concurrency (int): max number of concurrent calls (default: 1) concurrentTimeout (double): max number seconds to wait on futures if concurrency >= 1 (default: 100.0) errorCol (str): column to hold http errors (default: [self.uid]_errors) flattenOutputBatches (bool): whether to flatten the output batches (default: false) handlingStrategy (str): Which strategy to use when handling requests (default: advanced) inputCol (str): The name of the input column inputParser (object): format to parse the column to (default: JSONInputParser_fb7a4fa14efe) miniBatcher (object): Minibatcher to use outputCol (str): The name of the output column outputParser (object): format to parse the column to """ if hasattr(self, "_input_kwargs"): kwargs = self._input_kwargs else: kwargs = self.__init__._input_kwargs return self._set(**kwargs)
[docs] def setBackoffTiming(self, value): """ Args: backoffTiming (object): times to use in backoffs (default: [I@22af2ee9) """ self._set(backoffTiming=value) return self
[docs] def getBackoffTiming(self): """ Returns: object: times to use in backoffs (default: [I@22af2ee9) """ return self.getOrDefault(self.backoffTiming)
[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 setErrorCol(self, value): """ Args: errorCol (str): column to hold http errors (default: [self.uid]_errors) """ self._set(errorCol=value) return self
[docs] def getErrorCol(self): """ Returns: str: column to hold http errors (default: [self.uid]_errors) """ return self.getOrDefault(self.errorCol)
[docs] def setFlattenOutputBatches(self, value): """ Args: flattenOutputBatches (bool): whether to flatten the output batches (default: false) """ self._set(flattenOutputBatches=value) return self
[docs] def getFlattenOutputBatches(self): """ Returns: bool: whether to flatten the output batches (default: false) """ return self.getOrDefault(self.flattenOutputBatches)
[docs] def setHandlingStrategy(self, value): """ Args: handlingStrategy (str): Which strategy to use when handling requests (default: advanced) """ self._set(handlingStrategy=value) return self
[docs] def getHandlingStrategy(self): """ Returns: str: Which strategy to use when handling requests (default: advanced) """ return self.getOrDefault(self.handlingStrategy)
[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 setInputParser(self, value): """ Args: inputParser (object): format to parse the column to (default: JSONInputParser_fb7a4fa14efe) """ self._set(inputParser=value) return self
[docs] def getInputParser(self): """ Returns: object: format to parse the column to (default: JSONInputParser_fb7a4fa14efe) """ return self._cache.get("inputParser", None)
[docs] def setMiniBatcher(self, value): """ Args: miniBatcher (object): Minibatcher to use """ self._set(miniBatcher=value) return self
[docs] def getMiniBatcher(self): """ Returns: object: Minibatcher to use """ return self._cache.get("miniBatcher", None)
[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 setOutputParser(self, value): """ Args: outputParser (object): format to parse the column to """ self._set(outputParser=value) return self
[docs] def getOutputParser(self): """ Returns: object: format to parse the column to """ return self._cache.get("outputParser", None)
[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.SimpleHTTPTransformer"
@staticmethod def _from_java(java_stage): module_name=SimpleHTTPTransformer.__module__ module_name=module_name.rsplit(".", 1)[0] + ".SimpleHTTPTransformer" return from_java(java_stage, module_name)