Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
2d98fff0
Commit
2d98fff0
authored
12 years ago
by
Josh Rosen
Browse files
Options
Downloads
Patches
Plain Diff
Add IPython support to pyspark-shell.
Suggested by / based on code from @MLnick
parent
1dca0c51
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyspark/README
+3
-0
3 additions, 0 deletions
pyspark/README
pyspark/pyspark/shell.py
+17
-8
17 additions, 8 deletions
pyspark/pyspark/shell.py
pyspark/requirements.txt
+1
-0
1 addition, 0 deletions
pyspark/requirements.txt
with
21 additions
and
8 deletions
pyspark/README
+
3
−
0
View file @
2d98fff0
...
@@ -38,6 +38,9 @@ interacting with Java processes. It can be installed from
...
@@ -38,6 +38,9 @@ interacting with Java processes. It can be installed from
https://github.com/bartdag/py4j; make sure to install a version that
https://github.com/bartdag/py4j; make sure to install a version that
contains at least the commits through b7924aabe9.
contains at least the commits through b7924aabe9.
PySpark requires the `argparse` module, which is included in Python 2.7
and is is available for Python 2.6 through `pip` or `easy_install`.
PySpark uses the `PYTHONPATH` environment variable to search for Python
PySpark uses the `PYTHONPATH` environment variable to search for Python
classes; Py4J should be on this path, along with any libraries used by
classes; Py4J should be on this path, along with any libraries used by
PySpark programs. `PYTHONPATH` will be automatically shipped to worker
PySpark programs. `PYTHONPATH` will be automatically shipped to worker
...
...
This diff is collapsed.
Click to expand it.
pyspark/pyspark/shell.py
+
17
−
8
View file @
2d98fff0
"""
"""
An interactive shell.
An interactive shell.
"""
"""
import
argparse
# argparse is avaiable for Python < 2.7 through easy_install.
import
code
import
code
import
sys
import
sys
from
pyspark.context
import
SparkContext
from
pyspark.context
import
SparkContext
def
main
(
master
=
'
local
'
):
def
main
(
master
=
'
local
'
,
ipython
=
False
):
sc
=
SparkContext
(
master
,
'
PySparkShell
'
)
sc
=
SparkContext
(
master
,
'
PySparkShell
'
)
print
"
Spark context available as sc.
"
user_ns
=
{
'
sc
'
:
sc
}
code
.
interact
(
local
=
{
'
sc
'
:
sc
})
banner
=
"
Spark context avaiable as sc.
"
if
ipython
:
import
IPython
IPython
.
embed
(
user_ns
=
user_ns
,
banner2
=
banner
)
else
:
print
banner
code
.
interact
(
local
=
user_ns
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
if
len
(
sys
.
argv
)
>
1
:
parser
=
argparse
.
ArgumentParser
()
master
=
sys
.
argv
[
1
]
parser
.
add_argument
(
"
master
"
,
help
=
"
Spark master host (default=
'
local
'
)
"
,
else
:
nargs
=
'
?
'
,
type
=
str
,
default
=
"
local
"
)
master
=
'
local
'
parser
.
add_argument
(
"
-i
"
,
"
--ipython
"
,
help
=
"
Run IPython shell
"
,
main
(
master
)
action
=
"
store_true
"
)
args
=
parser
.
parse_args
()
main
(
args
.
master
,
args
.
ipython
)
This diff is collapsed.
Click to expand it.
pyspark/requirements.txt
+
1
−
0
View file @
2d98fff0
...
@@ -4,3 +4,4 @@
...
@@ -4,3 +4,4 @@
# install Py4J from git once https://github.com/pypa/pip/pull/526 is merged.
# install Py4J from git once https://github.com/pypa/pip/pull/526 is merged.
# git+git://github.com/bartdag/py4j.git@b7924aabe9c5e63f0a4d8bbd17019534c7ec014e
# git+git://github.com/bartdag/py4j.git@b7924aabe9c5e63f0a4d8bbd17019534c7ec014e
argparse
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment