diff options
author | Bryan Cutler <cutlerb@gmail.com> | 2016-03-08 17:34:25 -0800 |
---|---|---|
committer | Joseph K. Bradley <joseph@databricks.com> | 2016-03-08 17:34:25 -0800 |
commit | d8813fa043e8b8f7cbf6921d4c7ec889634f7abd (patch) | |
tree | e84f67640f0fdbc68fa2adb58e54c3c8985b0ebd /python/pyspark/ml/param | |
parent | 81f54acc9cc0fb9d4ee552f6f56a26c78654a33b (diff) | |
download | spark-d8813fa043e8b8f7cbf6921d4c7ec889634f7abd.tar.gz spark-d8813fa043e8b8f7cbf6921d4c7ec889634f7abd.tar.bz2 spark-d8813fa043e8b8f7cbf6921d4c7ec889634f7abd.zip |
[SPARK-13625][PYSPARK][ML] Added a check to see if an attribute is a property when getting param list
## What changes were proposed in this pull request?
Added a check in pyspark.ml.param.Param.params() to see if an attribute is a property (decorated with `property`) before checking if it is a `Param` instance. This prevents the property from being invoked to 'get' this attribute, which could possibly cause an error.
## How was this patch tested?
Added a test case with a class has a property that will raise an error when invoked and then call`Param.params` to verify that the property is not invoked, but still able to find another property in the class. Also ran pyspark-ml test before fix that will trigger an error, and again after the fix to verify that the error was resolved and the method was working properly.
Author: Bryan Cutler <cutlerb@gmail.com>
Closes #11476 from BryanCutler/pyspark-ml-property-attr-SPARK-13625.
Diffstat (limited to 'python/pyspark/ml/param')
-rw-r--r-- | python/pyspark/ml/param/__init__.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/python/pyspark/ml/param/__init__.py b/python/pyspark/ml/param/__init__.py index bbf83f0310..c0f0a71eb6 100644 --- a/python/pyspark/ml/param/__init__.py +++ b/python/pyspark/ml/param/__init__.py @@ -109,7 +109,8 @@ class Params(Identifiable): """ if self._params is None: self._params = list(filter(lambda attr: isinstance(attr, Param), - [getattr(self, x) for x in dir(self) if x != "params"])) + [getattr(self, x) for x in dir(self) if x != "params" and + not isinstance(getattr(type(self), x, None), property)])) return self._params @since("1.4.0") |