Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Prevent initiating multiple Hive clients for ImageSchema.readImages
  • Loading branch information
HyukjinKwon committed Nov 29, 2017
commit c0c3c487474629df00ba50c5b6904552010f1aab
5 changes: 2 additions & 3 deletions python/pyspark/ml/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ def readImages(self, path, recursive=False, numPartitions=-1,
.. versionadded:: 2.3.0
"""

ctx = SparkContext._active_spark_context
spark = SparkSession(ctx)
image_schema = ctx._jvm.org.apache.spark.ml.image.ImageSchema
spark = SparkSession.builder.getOrCreate()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this should be best practice to initialize SparkSession.

image_schema = spark._jvm.org.apache.spark.ml.image.ImageSchema
jsession = spark._jsparkSession
jresult = image_schema.readImages(path, jsession, recursive, numPartitions,
dropImageFailures, float(sampleRatio), seed)
Expand Down