spark git commit: [SPARK-20360][PYTHON] reprs for interpreters

2017-04-18 Thread holden
Repository: spark
Updated Branches:
  refs/heads/branch-2.2 ecf5605a1 -> 7dbc0a910


[SPARK-20360][PYTHON] reprs for interpreters

## What changes were proposed in this pull request?

Establishes a very minimal `_repr_html_` for PySpark's `SparkContext`.

## How was this patch tested?

nteract:

![screen shot 2017-04-17 at 3 41 29 
pm](https://cloud.githubusercontent.com/assets/836375/25107701/d57090ba-2385-11e7-8147-74bc2c50a41b.png)

Jupyter:

![screen shot 2017-04-17 at 3 53 19 
pm](https://cloud.githubusercontent.com/assets/836375/25107725/05bf1fe8-2386-11e7-93e1-07a20c917dde.png)

Hydrogen:

![screen shot 2017-04-17 at 3 49 55 
pm](https://cloud.githubusercontent.com/assets/836375/25107664/a75e1ddc-2385-11e7-8477-258661833007.png)

Author: Kyle Kelley 

Closes #17662 from rgbkrk/repr.

(cherry picked from commit f654b39a63d4f9b118733733c7ed2a1b58649e3d)
Signed-off-by: Holden Karau 


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/7dbc0a91
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/7dbc0a91
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/7dbc0a91

Branch: refs/heads/branch-2.2
Commit: 7dbc0a9101954f1d514b97143b24fbe1e439181b
Parents: ecf5605
Author: Kyle Kelley 
Authored: Tue Apr 18 12:35:27 2017 -0700
Committer: Holden Karau 
Committed: Tue Apr 18 12:35:39 2017 -0700

--
 python/pyspark/context.py | 26 ++
 python/pyspark/sql/session.py | 11 +++
 2 files changed, 37 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/spark/blob/7dbc0a91/python/pyspark/context.py
--
diff --git a/python/pyspark/context.py b/python/pyspark/context.py
index 2961cda..3be0732 100644
--- a/python/pyspark/context.py
+++ b/python/pyspark/context.py
@@ -240,6 +240,32 @@ class SparkContext(object):
 if isinstance(threading.current_thread(), threading._MainThread):
 signal.signal(signal.SIGINT, signal_handler)
 
+def __repr__(self):
+return "".format(
+master=self.master,
+appName=self.appName,
+)
+
+def _repr_html_(self):
+return """
+
+SparkContext
+
+Spark UI
+
+
+  Version
+v{sc.version}
+  Master
+{sc.master}
+  AppName
+{sc.appName}
+
+
+""".format(
+sc=self
+)
+
 def _initialize_context(self, jconf):
 """
 Initialize SparkContext in function to allow subclass specific 
initialization

http://git-wip-us.apache.org/repos/asf/spark/blob/7dbc0a91/python/pyspark/sql/session.py
--
diff --git a/python/pyspark/sql/session.py b/python/pyspark/sql/session.py
index 9f4772e..c1bf2bd 100644
--- a/python/pyspark/sql/session.py
+++ b/python/pyspark/sql/session.py
@@ -221,6 +221,17 @@ class SparkSession(object):
 or SparkSession._instantiatedSession._sc._jsc is None:
 SparkSession._instantiatedSession = self
 
+def _repr_html_(self):
+return """
+
+SparkSession - {catalogImplementation}
+{sc_HTML}
+
+""".format(
+
catalogImplementation=self.conf.get("spark.sql.catalogImplementation"),
+sc_HTML=self.sparkContext._repr_html_()
+)
+
 @since(2.0)
 def newSession(self):
 """


-
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org



spark git commit: [SPARK-20360][PYTHON] reprs for interpreters

2017-04-18 Thread holden
Repository: spark
Updated Branches:
  refs/heads/master 1f81dda37 -> f654b39a6


[SPARK-20360][PYTHON] reprs for interpreters

## What changes were proposed in this pull request?

Establishes a very minimal `_repr_html_` for PySpark's `SparkContext`.

## How was this patch tested?

nteract:

![screen shot 2017-04-17 at 3 41 29 
pm](https://cloud.githubusercontent.com/assets/836375/25107701/d57090ba-2385-11e7-8147-74bc2c50a41b.png)

Jupyter:

![screen shot 2017-04-17 at 3 53 19 
pm](https://cloud.githubusercontent.com/assets/836375/25107725/05bf1fe8-2386-11e7-93e1-07a20c917dde.png)

Hydrogen:

![screen shot 2017-04-17 at 3 49 55 
pm](https://cloud.githubusercontent.com/assets/836375/25107664/a75e1ddc-2385-11e7-8477-258661833007.png)

Author: Kyle Kelley 

Closes #17662 from rgbkrk/repr.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/f654b39a
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/f654b39a
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/f654b39a

Branch: refs/heads/master
Commit: f654b39a63d4f9b118733733c7ed2a1b58649e3d
Parents: 1f81dda
Author: Kyle Kelley 
Authored: Tue Apr 18 12:35:27 2017 -0700
Committer: Holden Karau 
Committed: Tue Apr 18 12:35:27 2017 -0700

--
 python/pyspark/context.py | 26 ++
 python/pyspark/sql/session.py | 11 +++
 2 files changed, 37 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/spark/blob/f654b39a/python/pyspark/context.py
--
diff --git a/python/pyspark/context.py b/python/pyspark/context.py
index 2961cda..3be0732 100644
--- a/python/pyspark/context.py
+++ b/python/pyspark/context.py
@@ -240,6 +240,32 @@ class SparkContext(object):
 if isinstance(threading.current_thread(), threading._MainThread):
 signal.signal(signal.SIGINT, signal_handler)
 
+def __repr__(self):
+return "".format(
+master=self.master,
+appName=self.appName,
+)
+
+def _repr_html_(self):
+return """
+
+SparkContext
+
+Spark UI
+
+
+  Version
+v{sc.version}
+  Master
+{sc.master}
+  AppName
+{sc.appName}
+
+
+""".format(
+sc=self
+)
+
 def _initialize_context(self, jconf):
 """
 Initialize SparkContext in function to allow subclass specific 
initialization

http://git-wip-us.apache.org/repos/asf/spark/blob/f654b39a/python/pyspark/sql/session.py
--
diff --git a/python/pyspark/sql/session.py b/python/pyspark/sql/session.py
index 9f4772e..c1bf2bd 100644
--- a/python/pyspark/sql/session.py
+++ b/python/pyspark/sql/session.py
@@ -221,6 +221,17 @@ class SparkSession(object):
 or SparkSession._instantiatedSession._sc._jsc is None:
 SparkSession._instantiatedSession = self
 
+def _repr_html_(self):
+return """
+
+SparkSession - {catalogImplementation}
+{sc_HTML}
+
+""".format(
+
catalogImplementation=self.conf.get("spark.sql.catalogImplementation"),
+sc_HTML=self.sparkContext._repr_html_()
+)
+
 @since(2.0)
 def newSession(self):
 """


-
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org