Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
spark:using-python [2014/11/10 15:35] straka |
spark:using-python [2017/10/16 20:58] ufal [Using Python] |
||
---|---|---|---|
Line 9: | Line 9: | ||
Better interactive shell with code completion using '' | Better interactive shell with code completion using '' | ||
- | < | + | < |
As described in [[running-spark-on-single-machine-or-on-cluster|Running Spark on Single Machine or on Cluster]], environmental variable '' | As described in [[running-spark-on-single-machine-or-on-cluster|Running Spark on Single Machine or on Cluster]], environmental variable '' | ||
Line 16: | Line 16: | ||
Consider the following simple script computing 10 most frequent words of Czech Wikipedia: | Consider the following simple script computing 10 most frequent words of Czech Wikipedia: | ||
<file python> | <file python> | ||
- | (sc.textFile("/ | + | (sc.textFile("/ |
| | ||
| | ||
Line 24: | Line 24: | ||
</ | </ | ||
- | * run interactive shell inside '' | + | * run interactive shell using existing Spark cluster (i.e., |
- | < | + | < |
* run interactive shell with local Spark cluster using one thread: | * run interactive shell with local Spark cluster using one thread: | ||
- | < | + | < |
* start Spark cluster (10 machines, 1GB RAM each) on SGE and run interactive shell: | * start Spark cluster (10 machines, 1GB RAM each) on SGE and run interactive shell: | ||
- | < | + | < |
- | Note that '' | + | Note that '' |
===== Running Python Spark Scripts ===== | ===== Running Python Spark Scripts ===== | ||
- | Python Spark scripts can be started using '' | + | Python Spark scripts can be started using: |
+ | < | ||
As described in [[running-spark-on-single-machine-or-on-cluster|Running Spark on Single Machine or on Cluster]], environmental variable '' | As described in [[running-spark-on-single-machine-or-on-cluster|Running Spark on Single Machine or on Cluster]], environmental variable '' | ||
Line 55: | Line 56: | ||
sc = SparkContext() | sc = SparkContext() | ||
- | (sc.textFile(input) | + | (sc.textFile(input, 3*sc.defaultParallelism) |
| | ||
| | ||
Line 64: | Line 65: | ||
</ | </ | ||
- | * run '' | + | * run '' |
- | < | + | < |
* run '' | * run '' | ||
- | < | + | < |
* start Spark cluster (10 machines, 1GB RAM each) on SGE and run '' | * start Spark cluster (10 machines, 1GB RAM each) on SGE and run '' | ||
- | < | + | < |
+ | |||
+ | ===== Using Virtual Environments ===== | ||
+ | |||
+ | If you want to use specific virtual environment in your Spark job, use | ||
+ | < |