diff options
author | Joseph K. Bradley <joseph@databricks.com> | 2016-04-16 11:23:28 -0700 |
---|---|---|
committer | Joseph K. Bradley <joseph@databricks.com> | 2016-04-16 11:23:28 -0700 |
commit | 36da5e323487aa851a45475109185b9b0653db75 (patch) | |
tree | 3088ccde1eeefa430d8ca58dcdadc6e8caa64126 /python/pyspark/ml/util.py | |
parent | 9f678e97549b19d6d979b22fa4079094ce9fb2c0 (diff) | |
download | spark-36da5e323487aa851a45475109185b9b0653db75.tar.gz spark-36da5e323487aa851a45475109185b9b0653db75.tar.bz2 spark-36da5e323487aa851a45475109185b9b0653db75.zip |
[SPARK-14605][ML][PYTHON] Changed Python to use unicode UIDs for spark.ml Identifiable
## What changes were proposed in this pull request?
Python spark.ml Identifiable classes use UIDs of type str, but they should use unicode (in Python 2.x) to match Java. This could be a problem if someone created a class in Java with odd unicode characters, saved it, and loaded it in Python.
This PR: Use unicode everywhere in Python.
## How was this patch tested?
Updated persistence unit test to check uid type
Author: Joseph K. Bradley <joseph@databricks.com>
Closes #12368 from jkbradley/python-uid-unicode.
Diffstat (limited to 'python/pyspark/ml/util.py')
-rw-r--r-- | python/pyspark/ml/util.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/python/pyspark/ml/util.py b/python/pyspark/ml/util.py index 9dfcef0e40..841bfb47e1 100644 --- a/python/pyspark/ml/util.py +++ b/python/pyspark/ml/util.py @@ -21,6 +21,7 @@ from functools import wraps if sys.version > '3': basestring = str + unicode = str from pyspark import SparkContext, since from pyspark.mllib.common import inherit_doc @@ -67,10 +68,10 @@ class Identifiable(object): @classmethod def _randomUID(cls): """ - Generate a unique id for the object. The default implementation + Generate a unique unicode id for the object. The default implementation concatenates the class name, "_", and 12 random hex chars. """ - return cls.__name__ + "_" + uuid.uuid4().hex[12:] + return unicode(cls.__name__ + "_" + uuid.uuid4().hex[12:]) @inherit_doc |