3

I am trying to learn how to run a pyspark script using SPARK REST API.

I followed this link: http://arturmkrtchyan.com/apache-spark-hidden-rest-api and found this:

curl -X POST http://localhost:6066/v1/submissions/create --header "Content-Type:application/json;charset=UTF-8" --data '{
"action" : "CreateSubmissionRequest",
"appArgs" : [ "pi.py" ],
"appResource" : "file:learning/pi.py",
"clientSparkVersion" : "1.6.1",
"environmentVariables" : {
    "SPARK_ENV_LOADED" : "1"
},
"mainClass" : "org.apache.spark.deploy.SparkSubmit",
"sparkProperties" : {
"spark.driver.supervise" : "false",
"spark.app.name" : "Simple App",
"spark.eventLog.enabled": "true",
"spark.submit.deployMode" : "cluster",
"spark.master" : "spark://localhost:6066"
}
}'

Well it worked but I don't know what

"SPARK_ENV_LOADED" : "1"

means. Can someone explain please? it will help me proceed further.

Also, If someone knows a better way of doing the same please let me know. I am new at this.

Thanks

1 Answer 1

1

Check load-spark-env.sh.

This script loads spark-env.sh if it exists, and ensures it is only loaded once. spark-env.sh is loaded from SPARK_CONF_DIR if set, or within the current directory's conf/ subdirectory.

here if statement checks whether SPARK_ENV_LOADED was initialized (expression -z True if string is empty.):

if [ -z "$SPARK_ENV_LOADED" ]; then
  export SPARK_ENV_LOADED=1

  # Returns the parent of the directory this script lives in.
  parent_dir="${SPARK_HOME}"

  user_conf_dir="${SPARK_CONF_DIR:-"$parent_dir"/conf}"

  if [ -f "${user_conf_dir}/spark-env.sh" ]; then
    # Promote all variable declarations to environment (exported) variables
    set -a
    . "${user_conf_dir}/spark-env.sh"
    set +a
  fi
fi
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.