[jira] [Commented] (SPARK-13691) Scala and Python generate inconsistent results
[ https://issues.apache.org/jira/browse/SPARK-13691?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15197775#comment-15197775 ] Bryan Cutler commented on SPARK-13691: -- Since the problem comes from the structure of the code in the driver, it's not just specific to local mode, I believe. For instance, with streaming kmeans, it can lead to an inconsistent model that is not updated as quickly as the Scala version would - which is what led to the flaky StreamingKMeans failures in SPARK-10086. Whether or not it really leads to a problem in practice, I'm not too sure. > Scala and Python generate inconsistent results > -- > > Key: SPARK-13691 > URL: https://issues.apache.org/jira/browse/SPARK-13691 > Project: Spark > Issue Type: Bug > Components: PySpark >Affects Versions: 1.4.1, 1.5.2, 1.6.0 >Reporter: Shixiong Zhu > > Here is an example that Scala and Python generate different results > {code} > Scala: > scala> var i = 0 > i: Int = 0 > scala> val rdd = sc.parallelize(1 to 10).map(_ + i) > scala> rdd.collect() > res0: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) > scala> i += 1 > scala> rdd.collect() > res2: Array[Int] = Array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) > Python: > >>> i = 0 > >>> rdd = sc.parallelize(range(1, 10)).map(lambda x: x + i) > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > >>> i += 1 > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > {code} > The difference is Scala will capture all variables' values when running a job > every time, but Python just captures variables' values once and always uses > them for all jobs. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-13691) Scala and Python generate inconsistent results
[ https://issues.apache.org/jira/browse/SPARK-13691?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15189084#comment-15189084 ] Sean Owen commented on SPARK-13691: --- Fair point ... but hm, I wonder if we can change the behavior significantly at this point? Is this specific to running in local mode BTW? > Scala and Python generate inconsistent results > -- > > Key: SPARK-13691 > URL: https://issues.apache.org/jira/browse/SPARK-13691 > Project: Spark > Issue Type: Bug > Components: PySpark >Affects Versions: 1.4.1, 1.5.2, 1.6.0 >Reporter: Shixiong Zhu > > Here is an example that Scala and Python generate different results > {code} > Scala: > scala> var i = 0 > i: Int = 0 > scala> val rdd = sc.parallelize(1 to 10).map(_ + i) > scala> rdd.collect() > res0: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) > scala> i += 1 > scala> rdd.collect() > res2: Array[Int] = Array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) > Python: > >>> i = 0 > >>> rdd = sc.parallelize(range(1, 10)).map(lambda x: x + i) > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > >>> i += 1 > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > {code} > The difference is Scala will capture all variables' values when running a job > every time, but Python just captures variables' values once and always uses > them for all jobs. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-13691) Scala and Python generate inconsistent results
[ https://issues.apache.org/jira/browse/SPARK-13691?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15183465#comment-15183465 ] Shixiong Zhu commented on SPARK-13691: -- I would like to say the Scala behavior is more like the Python collection's behavior. E.g., {code} >>> i = 0 >>> map(lambda x: x + i, range(1, 10)) [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> i += 1 >>> map(lambda x: x + i, range(1, 10)) [2, 3, 4, 5, 6, 7, 8, 9, 10] {code} > Scala and Python generate inconsistent results > -- > > Key: SPARK-13691 > URL: https://issues.apache.org/jira/browse/SPARK-13691 > Project: Spark > Issue Type: Bug > Components: PySpark >Affects Versions: 1.4.1, 1.5.2, 1.6.0 >Reporter: Shixiong Zhu > > Here is an example that Scala and Python generate different results > {code} > Scala: > scala> var i = 0 > i: Int = 0 > scala> val rdd = sc.parallelize(1 to 10).map(_ + i) > scala> rdd.collect() > res0: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) > scala> i += 1 > scala> rdd.collect() > res2: Array[Int] = Array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) > Python: > >>> i = 0 > >>> rdd = sc.parallelize(range(1, 10)).map(lambda x: x + i) > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > >>> i += 1 > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > {code} > The difference is Scala will capture all variables' values when running a job > every time, but Python just captures variables' values once and always uses > them for all jobs. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-13691) Scala and Python generate inconsistent results
[ https://issues.apache.org/jira/browse/SPARK-13691?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15183438#comment-15183438 ] Bryan Cutler commented on SPARK-13691: -- The reason for this is that Pyspark serializes the closure (including dependent variables) into a command and then uses that to construct a {{PythonRDD}} which sends the command to a Python worker on {{RDD.compute}}. > Scala and Python generate inconsistent results > -- > > Key: SPARK-13691 > URL: https://issues.apache.org/jira/browse/SPARK-13691 > Project: Spark > Issue Type: Bug > Components: PySpark >Affects Versions: 1.4.1, 1.5.2, 1.6.0 >Reporter: Shixiong Zhu > > Here is an example that Scala and Python generate different results > {code} > Scala: > scala> var i = 0 > i: Int = 0 > scala> val rdd = sc.parallelize(1 to 10).map(_ + i) > scala> rdd.collect() > res0: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) > scala> i += 1 > scala> rdd.collect() > res2: Array[Int] = Array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) > Python: > >>> i = 0 > >>> rdd = sc.parallelize(range(1, 10)).map(lambda x: x + i) > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > >>> i += 1 > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > {code} > The difference is Scala will capture all variables' values when running a job > every time, but Python just captures variables' values once and always uses > them for all jobs. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-13691) Scala and Python generate inconsistent results
[ https://issues.apache.org/jira/browse/SPARK-13691?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15181640#comment-15181640 ] Sean Owen commented on SPARK-13691: --- I think this is just a language difference? Although changing it might bring Pyspark closer to Scala Spark, would it just make it behave less like Python? > Scala and Python generate inconsistent results > -- > > Key: SPARK-13691 > URL: https://issues.apache.org/jira/browse/SPARK-13691 > Project: Spark > Issue Type: Bug > Components: PySpark >Affects Versions: 1.4.1, 1.5.2, 1.6.0 >Reporter: Shixiong Zhu > > Here is an example that Scala and Python generate different results > {code} > Scala: > scala> var i = 0 > i: Int = 0 > scala> val rdd = sc.parallelize(1 to 10).map(_ + i) > scala> rdd.collect() > res0: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) > scala> i += 1 > scala> rdd.collect() > res2: Array[Int] = Array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) > Python: > >>> i = 0 > >>> rdd = sc.parallelize(range(1, 10)).map(lambda x: x + i) > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > >>> i += 1 > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > {code} > The difference is Scala will capture all variables' values when running a job > every time, but Python just captures variables' values once and always uses > them for all jobs. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org
[jira] [Commented] (SPARK-13691) Scala and Python generate inconsistent results
[ https://issues.apache.org/jira/browse/SPARK-13691?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15180724#comment-15180724 ] Shixiong Zhu commented on SPARK-13691: -- Ideally, PySpark should always capture all values when running a job like Scala. > Scala and Python generate inconsistent results > -- > > Key: SPARK-13691 > URL: https://issues.apache.org/jira/browse/SPARK-13691 > Project: Spark > Issue Type: Bug > Components: PySpark >Reporter: Shixiong Zhu > > Here is an example that Scala and Python generate different results > {code} > Scala: > scala> var i = 0 > i: Int = 0 > scala> val rdd = sc.parallelize(1 to 10).map(_ + i) > scala> rdd.collect() > res0: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) > scala> i += 1 > scala> rdd.collect() > res2: Array[Int] = Array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11) > Python: > >>> i = 0 > >>> rdd = sc.parallelize(range(1, 10)).map(lambda x: x + i) > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > >>> i += 1 > >>> rdd.collect() > [1, 2, 3, 4, 5, 6, 7, 8, 9] > {code} > The difference is Scala will capture all variables' values when running a job > every time, but Python just captures variables' values once and always uses > them for all jobs. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org