-
Notifications
You must be signed in to change notification settings - Fork 29k
SPARK-1565 (Addendum): Replace run-example with spark-submit.
#704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,21 +39,22 @@ And run the following command, which should also return 1000: | |
| ## Example Programs | ||
|
|
||
| Spark also comes with several sample programs in the `examples` directory. | ||
| To run one of them, use the `./bin/spark-submit` script. For example: | ||
| To run one of them, use `./bin/run-example <class> [<params>]`. For example: | ||
|
|
||
| ./bin/spark-submit \ | ||
| --class org.apache.spark.examples.SparkLR \ | ||
| --master local[2] \ | ||
| lib/spark-examples*.jar | ||
| ./bin/run-example org.apache.spark.examples.SparkLR | ||
|
|
||
| will run the Logistic Regression example locally on 2 CPUs. | ||
| will run the Logistic Regression example locally. | ||
|
|
||
| Many of the example programs print usage help if no params are given. | ||
| You can set the MASTER environment variable when running examples to submit | ||
| examples to a cluster. This can be a mesos:// or spark:// URL, | ||
| "yarn-cluster" or "yarn-client" to run on YARN, and "local" to run | ||
| locally with one thread, or "local[N]" to run locally with N thread. You | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. N threads |
||
| can also use an abbreviated class name if the class is in the `examples` | ||
| package. For instance: | ||
|
|
||
| MASTER=spark://host:7077 ./bin/run-example SparkPi | ||
|
|
||
| When running Spark examples you can pass `--master` parameter to the submission | ||
| script. This can be a mesos:// or spark:// URL, "yarn-cluster" or "yarn-client" | ||
| to run on YARN, and "local" to run locally with one thread, or "local[N]" to | ||
| run locally with N thread. | ||
| Many of the example programs print usage help if no params are given. | ||
|
|
||
| ## Running Tests | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,27 +35,25 @@ if [[ -z $SPARK_EXAMPLES_JAR ]]; then | |
| exit 1 | ||
| fi | ||
|
|
||
| SPARK_EXAMPLES_JAR_REL=${SPARK_EXAMPLES_JAR#$FWDIR/} | ||
|
|
||
| EXAMPLE_CLASS="<example-class>" | ||
| EXAMPLE_ARGS="[<example args>]" | ||
| EXAMPLE_MASTER=${MASTER:-"<master>"} | ||
| EXAMPLE_MASTER=${MASTER:-"local[2]"} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a consistent default. Should we use |
||
|
|
||
| if [ -n "$1" ]; then | ||
| EXAMPLE_CLASS="$1" | ||
| shift | ||
| else | ||
| echo "usage: ./bin/run-example <example-class> [<example-args>]" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops sorry there's another one |
||
| echo " - set MASTER=XX to use a specific master" | ||
| echo " - can use abbreviated example class name (e.g. SparkPi)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we should also add an example for say MLlib or Sql examples; people might try to run |
||
| echo | ||
| exit -1 | ||
| fi | ||
|
|
||
| if [ -n "$1" ]; then | ||
| EXAMPLE_ARGS="$@" | ||
| if [[ ! $EXAMPLE_CLASS == org.apache.spark.examples* ]]; then | ||
| EXAMPLE_CLASS="org.apache.spark.examples.$EXAMPLE_CLASS" | ||
| fi | ||
|
|
||
| echo "NOTE: This script has been replaced with ./bin/spark-submit. Please run:" >&2 | ||
| echo | ||
| echo "./bin/spark-submit \\" >&2 | ||
| echo " --master $EXAMPLE_MASTER \\" >&2 | ||
| echo " --class $EXAMPLE_CLASS \\" >&2 | ||
| echo " $SPARK_EXAMPLES_JAR_REL \\" >&2 | ||
| echo " $EXAMPLE_ARGS" >&2 | ||
| echo | ||
| exit 1 | ||
| ./bin/spark-submit \ | ||
| --master $EXAMPLE_MASTER \ | ||
| --class $EXAMPLE_CLASS \ | ||
| $SPARK_EXAMPLES_JAR \ | ||
| "$@" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: What does the notation
[< ... >]mean? I think it's clearer if it's just[params]