You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by rgbkrk <gi...@git.apache.org> on 2017/04/17 21:10:51 UTC

[GitHub] spark pull request #17662: [SPARK-20360][PYTHON] Create _repr_html_ for Spar...

GitHub user rgbkrk opened a pull request:

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

    [SPARK-20360][PYTHON] Create _repr_html_ for SparkContext

    ## What changes were proposed in this pull request?
    
    Establishes a very minimal `_repr_html_` for PySpark's `SparkContext`.
    
    ## How was this patch tested?
    
    Jupyter:
    
    ![screen shot 2017-04-17 at 2 08 42 pm](https://cloud.githubusercontent.com/assets/836375/25104978/7e39abfa-2377-11e7-94e8-aa2f905847b9.png)
    
    Hydrogen:
    
    ![screen shot 2017-04-17 at 2 09 54 pm](https://cloud.githubusercontent.com/assets/836375/25104991/911af742-2377-11e7-8157-1afb65cb252e.png)
    
    nteract:
    
    ![screen shot 2017-04-17 at 2 10 38 pm](https://cloud.githubusercontent.com/assets/836375/25105004/a6f9fa54-2377-11e7-942b-5264c05ed38a.png)


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

    $ git pull https://github.com/rgbkrk/spark repr

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

    https://github.com/apache/spark/pull/17662.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 #17662
    
----
commit 65abd044f451649746fa39e27c6132dc754d23ef
Author: Kyle Kelley <rg...@gmail.com>
Date:   2017-04-17T20:06:31Z

    [SPARK-20360][PYTHON] Create _repr_html_ for SparkContext

----


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by holdenk <gi...@git.apache.org>.
Github user holdenk commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    Thanks for working on this @rgbkrk, having better IJupyter/nteract support seems useful.
    Jenkins, OK to test.


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by rgbkrk <gi...@git.apache.org>.
Github user rgbkrk commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    Nevermind what I just said, I was context switching between working on javascript and python -- I introduced the `$` in the format string. Silly me.


---
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 issue #17662: [SPARK-20360][PYTHON] reprs for interpreters

Posted by holdenk <gi...@git.apache.org>.
Github user holdenk commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    This looks good to me, since we've just cut the 2.2 branch but not yet built an RC & this PR is already outstanding, I'm going to merge this into master & 2.2 so we can have some faster feedback on this (and maybe pique some other peoples interest).


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by holdenk <gi...@git.apache.org>.
Github user holdenk commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    Thanks for working on this @rgbkrk , I have a few minor suggestions for the SparkSession representation to be a bit clearer but it looks useful already :)


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by holdenk <gi...@git.apache.org>.
Github user holdenk commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    I like it, I'm going to leave this a for a bit and see if anyone has any comments overnight :)


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    for starter, version and spark UI like this
    I'm sure we could add appname, session catalog current database, or conf like spark.sql.catalogImplementation
    
    ok, maybe not too many things :)



---
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 #17662: [SPARK-20360][PYTHON] reprs for interpreters

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

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


---
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 #17662: [SPARK-20360][PYTHON] Create _repr_html_ for Spar...

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

    https://github.com/apache/spark/pull/17662#discussion_r111847582
  
    --- Diff: python/pyspark/sql/session.py ---
    @@ -221,6 +221,9 @@ def __init__(self, sparkContext, jsparkSession=None):
                     or SparkSession._instantiatedSession._sc._jsc is None:
                 SparkSession._instantiatedSession = self
     
    +    def _repr_html_(self):
    +        return self.sparkContext._repr_html_()
    --- End diff --
    
    > It might also make sense to return a different URL link (e.g. to the SQL page rather than the default page which takes people to the Jobs section) but this is minor and likely less useful than the other things.
    
    I don't know enough internals here to tell what URL(s) you'd want here. What properties or calls should I make for the SQL page?


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by rgbkrk <gi...@git.apache.org>.
Github user rgbkrk commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    Should it just defer to the session's spark context?


---
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 #17662: [SPARK-20360][PYTHON] Create _repr_html_ for Spar...

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

    https://github.com/apache/spark/pull/17662#discussion_r111847456
  
    --- Diff: python/pyspark/sql/session.py ---
    @@ -221,6 +221,9 @@ def __init__(self, sparkContext, jsparkSession=None):
                     or SparkSession._instantiatedSession._sc._jsc is None:
                 SparkSession._instantiatedSession = self
     
    +    def _repr_html_(self):
    +        return self.sparkContext._repr_html_()
    --- End diff --
    
    Ok, I've set the `catalogImplementation` here now. This seems like something we could put in the SparkContext HTML repr as well.
    



---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    Can one of the admins verify 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 #17662: [SPARK-20360][PYTHON] Create _repr_html_ for Spar...

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

    https://github.com/apache/spark/pull/17662#discussion_r111833507
  
    --- Diff: python/pyspark/context.py ---
    @@ -240,6 +240,26 @@ def signal_handler(signal, frame):
             if isinstance(threading.current_thread(), threading._MainThread):
                 signal.signal(signal.SIGINT, signal_handler)
     
    +    def __repr__(self):
    +        return "<SparkContext master={master} appName={appName}>".format(
    +            master=self.master,
    +            appName=self.appName
    +        )
    +
    +    def _repr_html_(self):
    +        return """
    +        <div>
    +            <p><b>Spark Context</b></p>
    +            <ul>
    +                <li>Spark <code>v{spark_version}</code></li>
    +                <li><a href="{spark_ui_url}">Spark UI</a></li>
    +            </ul>
    +        </div>
    +        """.format(
    +            spark_version=self.version,
    +            spark_ui_url=self.uiWebUrl,
    --- End diff --
    
    Thanks for the explanation @rgbkrk. That make sense. The reason for asking is method _repr_ which you have added don't have the "," at the end. 


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    cool, should we add something similar to SparkSession?


---
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 #17662: [SPARK-20360][PYTHON] Create _repr_html_ for Spar...

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

    https://github.com/apache/spark/pull/17662#discussion_r111833037
  
    --- Diff: python/pyspark/context.py ---
    @@ -240,6 +240,26 @@ def signal_handler(signal, frame):
             if isinstance(threading.current_thread(), threading._MainThread):
                 signal.signal(signal.SIGINT, signal_handler)
     
    +    def __repr__(self):
    +        return "<SparkContext master={master} appName={appName}>".format(
    +            master=self.master,
    +            appName=self.appName
    +        )
    +
    +    def _repr_html_(self):
    +        return """
    +        <div>
    +            <p><b>Spark Context</b></p>
    +            <ul>
    +                <li>Spark <code>v{spark_version}</code></li>
    +                <li><a href="{spark_ui_url}">Spark UI</a></li>
    +            </ul>
    +        </div>
    +        """.format(
    +            spark_version=self.version,
    +            spark_ui_url=self.uiWebUrl,
    --- End diff --
    
    You're allowed to have trailing commas in Python. It's purely aesthetic -- the primary benefit is for the next coder. Every line has the same format and adding entries to the end is the same as adding them to the middle.


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by rgbkrk <gi...@git.apache.org>.
Github user rgbkrk commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    After this PR I'll be more than happy to do some representations for RDDs, Spark DataFrames, and the whole lot. Keep encouraging me and you'll have a happy contributor. \U0001f604 


---
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 #17662: [SPARK-20360][PYTHON] Create _repr_html_ for Spar...

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

    https://github.com/apache/spark/pull/17662#discussion_r111842520
  
    --- Diff: python/pyspark/sql/session.py ---
    @@ -221,6 +221,9 @@ def __init__(self, sparkContext, jsparkSession=None):
                     or SparkSession._instantiatedSession._sc._jsc is None:
                 SparkSession._instantiatedSession = self
     
    +    def _repr_html_(self):
    +        return self.sparkContext._repr_html_()
    --- End diff --
    
    As @felixcheung suggested I think it might make sense to include some extra Spark SQL specific things.
    
    I think the catalog implementation type here (can be very useful for understanding why hive UDFs are not working) (which you can get from the session config with the `spark.sql.catalogImplementation` key) and the current database (which you can get from the catalog object from the session). The catalog implementation is especially useful since we currently do a "fallback" from hive supported to non-hive supported and the user might not have noticed if they launched in Jupyter where the log messages are a bit more obscure -- something I've been meaning to work on in https://github.com/apache/spark/pull/17298 but I've gotten a bit distracted).
    
    It might also make sense to return a different URL link (e.g. to the SQL page rather than the default page which takes people to the Jobs section) but 


---
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 #17662: [SPARK-20360][PYTHON] Create _repr_html_ for Spar...

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

    https://github.com/apache/spark/pull/17662#discussion_r111996616
  
    --- Diff: python/pyspark/context.py ---
    @@ -240,6 +240,26 @@ def signal_handler(signal, frame):
             if isinstance(threading.current_thread(), threading._MainThread):
                 signal.signal(signal.SIGINT, signal_handler)
     
    +    def __repr__(self):
    +        return "<SparkContext master={master} appName={appName}>".format(
    +            master=self.master,
    +            appName=self.appName
    +        )
    +
    +    def _repr_html_(self):
    +        return """
    +        <div>
    +            <p><b>Spark Context</b></p>
    +            <ul>
    +                <li>Spark <code>v{spark_version}</code></li>
    +                <li><a href="{spark_ui_url}">Spark UI</a></li>
    +            </ul>
    +        </div>
    +        """.format(
    +            spark_version=self.version,
    +            spark_ui_url=self.uiWebUrl,
    --- End diff --
    
    Thanks, the `__repr__` declaration now has matching code style.


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by rgbkrk <gi...@git.apache.org>.
Github user rgbkrk commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    Happy to! What would you like to see?


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by rgbkrk <gi...@git.apache.org>.
Github user rgbkrk commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    I'm tempted to switch this to `<p>` tags for the header, based on how the hydrogen styling comes out by default. It then looks like this:
    
    ![screen shot 2017-04-17 at 2 26 51 pm](https://cloud.githubusercontent.com/assets/836375/25105553/efe726c2-2379-11e7-9151-1d70ebb45ee0.png)
    
    Should I be tearing the `$` off the front of the version string that's handed back? What's canonical, what's good for the user?


---
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 #17662: [SPARK-20360][PYTHON] Create _repr_html_ for Spar...

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

    https://github.com/apache/spark/pull/17662#discussion_r111832361
  
    --- Diff: python/pyspark/context.py ---
    @@ -240,6 +240,26 @@ def signal_handler(signal, frame):
             if isinstance(threading.current_thread(), threading._MainThread):
                 signal.signal(signal.SIGINT, signal_handler)
     
    +    def __repr__(self):
    +        return "<SparkContext master={master} appName={appName}>".format(
    +            master=self.master,
    +            appName=self.appName
    +        )
    +
    +    def _repr_html_(self):
    +        return """
    +        <div>
    +            <p><b>Spark Context</b></p>
    +            <ul>
    +                <li>Spark <code>v{spark_version}</code></li>
    +                <li><a href="{spark_ui_url}">Spark UI</a></li>
    +            </ul>
    +        </div>
    +        """.format(
    +            spark_version=self.version,
    +            spark_ui_url=self.uiWebUrl,
    --- End diff --
    
    Thanks for this change @rgbkrk. I am kind of newbee to python, would like to understand the significance of "," at the end. 


---
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 issue #17662: [SPARK-20360][PYTHON] Create _repr_html_ for SparkContex...

Posted by rgbkrk <gi...@git.apache.org>.
Github user rgbkrk commented on the issue:

    https://github.com/apache/spark/pull/17662
  
    Went ahead and put `master` and `appName`, since those seemed sensible for knowing if you were on yarn, `local[*]`, etc.
    
    ![screen shot 2017-04-17 at 3 41 29 pm](https://cloud.githubusercontent.com/assets/836375/25107475/76637f48-2384-11e7-8a45-dbcd50a0b129.png)



---
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