You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by mattf <gi...@git.apache.org> on 2014/09/09 18:01:27 UTC

[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

GitHub user mattf opened a pull request:

    https://github.com/apache/spark/pull/2335

    [SPARK-3458] enable python "with" statements for SparkContext

    allow for best practice code,
    
    ```
    try:
      sc = SparkContext()
      app(sc)
    finally:
      sc.stop()
    ```
    
    to be written using a "with" statement,
    
    ```
    with SparkContext() as sc:
      app(sc)
    ```

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mattf/spark SPARK-3458

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/2335.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2335
    
----
commit 5b4e37cd8487f9a4c196bd7c85cef6b5def07b45
Author: Matthew Farrellee <ma...@redhat.com>
Date:   2014-09-09T15:58:26Z

    [SPARK-3458] enable python "with" statements for SparkContext
    
    allow for best practice code,
    
    try:
      sc = SparkContext()
      app(sc)
    finally:
      sc.stop()
    
    to be written using a "with" statement,
    
    with SparkContext() as sc:
      app(sc)

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55023418
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20048/consoleFull) for   PR 2335 at commit [`5b4e37c`](https://github.com/apache/spark/commit/5b4e37cd8487f9a4c196bd7c85cef6b5def07b45).
     * This patch **fails** unit tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55048880
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20052/consoleFull) for   PR 2335 at commit [`5b4e37c`](https://github.com/apache/spark/commit/5b4e37cd8487f9a4c196bd7c85cef6b5def07b45).
     * This patch **passes** unit tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55010011
  
    I'm OK to merge this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55001946
  
    @mattf It's cool to have this, just one minor comment about tests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55000341
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20045/consoleFull) for   PR 2335 at commit [`5b4e37c`](https://github.com/apache/spark/commit/5b4e37cd8487f9a4c196bd7c85cef6b5def07b45).
     * This patch merges cleanly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2335#discussion_r17314479
  
    --- Diff: python/pyspark/tests.py ---
    @@ -1254,6 +1254,35 @@ def test_single_script_on_cluster(self):
             self.assertIn("[2, 4, 6]", out)
     
     
    +class ContextStopTests(unittest.TestCase):
    +
    +    def test_stop(self):
    +        sc = SparkContext()
    +        self.assertNotEqual(SparkContext._active_spark_context, None)
    +        sc.stop()
    +        self.assertEqual(SparkContext._active_spark_context, None)
    --- End diff --
    
    Sorry, I missed that, we definitely need to target Python2.6.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by mattf <gi...@git.apache.org>.
Github user mattf commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55026585
  
    > This patch fails unit tests.
    
    still not this patch's fault


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55009950
  
    Jenkins, retest this please.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55037353
  
    Jenkins, retest this please.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55041591
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20052/consoleFull) for   PR 2335 at commit [`5b4e37c`](https://github.com/apache/spark/commit/5b4e37cd8487f9a4c196bd7c85cef6b5def07b45).
     * This patch merges cleanly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55015583
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20048/consoleFull) for   PR 2335 at commit [`5b4e37c`](https://github.com/apache/spark/commit/5b4e37cd8487f9a4c196bd7c85cef6b5def07b45).
     * This patch merges cleanly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by JoshRosen <gi...@git.apache.org>.
Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2335#discussion_r17314712
  
    --- Diff: python/pyspark/tests.py ---
    @@ -1254,6 +1254,35 @@ def test_single_script_on_cluster(self):
             self.assertIn("[2, 4, 6]", out)
     
     
    +class ContextStopTests(unittest.TestCase):
    +
    +    def test_stop(self):
    +        sc = SparkContext()
    +        self.assertNotEqual(SparkContext._active_spark_context, None)
    +        sc.stop()
    +        self.assertEqual(SparkContext._active_spark_context, None)
    --- End diff --
    
    Yeah, I know :( .  Unfortunately, Python 2.6 is still the default Python version on a lot of Linux distributions, so we've been trying to maintain backwards-compatibility in order to ensure a good out-of-the-box experience for those users.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/2335


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by mattf <gi...@git.apache.org>.
Github user mattf commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55008148
  
    > This patch fails unit tests.
    
    failures are unrelated to this patch


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55061687
  
    Merging in master. Thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2335#discussion_r17313570
  
    --- Diff: python/pyspark/tests.py ---
    @@ -1254,6 +1254,35 @@ def test_single_script_on_cluster(self):
             self.assertIn("[2, 4, 6]", out)
     
     
    +class ContextStopTests(unittest.TestCase):
    +
    +    def test_stop(self):
    +        sc = SparkContext()
    +        self.assertNotEqual(SparkContext._active_spark_context, None)
    +        sc.stop()
    +        self.assertEqual(SparkContext._active_spark_context, None)
    --- End diff --
    
    self.assertIsNone(xxx) is better than self.assertEqual(xxx, None)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by mattf <gi...@git.apache.org>.
Github user mattf commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-54995675
  
    @davies i'd appreciate your input on this


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by mattf <gi...@git.apache.org>.
Github user mattf commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2335#discussion_r17314305
  
    --- Diff: python/pyspark/tests.py ---
    @@ -1254,6 +1254,35 @@ def test_single_script_on_cluster(self):
             self.assertIn("[2, 4, 6]", out)
     
     
    +class ContextStopTests(unittest.TestCase):
    +
    +    def test_stop(self):
    +        sc = SparkContext()
    +        self.assertNotEqual(SparkContext._active_spark_context, None)
    +        sc.stop()
    +        self.assertEqual(SparkContext._active_spark_context, None)
    --- End diff --
    
    accordning to https://docs.python.org/2/library/unittest.html#assert-methods assertIsNone and assertIsNotNone are new to python 2.7 and my (potentially incorrect) understanding is we want to target 2.6.
    
    thoughts?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2335#issuecomment-55007790
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20045/consoleFull) for   PR 2335 at commit [`5b4e37c`](https://github.com/apache/spark/commit/5b4e37cd8487f9a4c196bd7c85cef6b5def07b45).
     * This patch **fails** unit tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3458] enable python "with" statements f...

Posted by mattf <gi...@git.apache.org>.
Github user mattf commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2335#discussion_r17314582
  
    --- Diff: python/pyspark/tests.py ---
    @@ -1254,6 +1254,35 @@ def test_single_script_on_cluster(self):
             self.assertIn("[2, 4, 6]", out)
     
     
    +class ContextStopTests(unittest.TestCase):
    +
    +    def test_stop(self):
    +        sc = SparkContext()
    +        self.assertNotEqual(SparkContext._active_spark_context, None)
    +        sc.stop()
    +        self.assertEqual(SparkContext._active_spark_context, None)
    --- End diff --
    
    side note: i can't even find a box w/ py2.6 (it's so old!)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org