Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/30#discussion_r10410987
  
    --- Diff: python/pyspark/java_gateway.py ---
    @@ -66,3 +71,30 @@ def run(self):
         java_import(gateway.jvm, "org.apache.spark.mllib.api.python.*")
         java_import(gateway.jvm, "scala.Tuple2")
         return gateway
    +
    +def set_env_vars_for_yarn(pyspark_zip):
    +    if "SPARK_YARN_DIST_FILES" in os.environ:
    +        os.environ["SPARK_YARN_DIST_FILES"] += ("," + pyspark_zip)
    +    else:
    +        os.environ["SPARK_YARN_DIST_FILES"] = pyspark_zip
    +    
    +    # Add the pyspark zip to the python path
    +    env_map = parse_env(os.environ.get("SPARK_YARN_USER_ENV", ""))
    +    if "PYTHONPATH" in env_map:
    +        env_map["PYTHONPATH"] += (":" + os.path.basename(pyspark_zip))
    +    else:
    +        env_map["PYTHONPATH"] = os.path.basename(pyspark_zip)
    +
    +    os.environ["SPARK_YARN_USER_ENV"] = ",".join(map(lambda v: v[0] + "=" 
+ v[1],
    --- End diff --
    
    I think you can write this a little more clearly as
    
    ```
     os.environ["SPARK_YARN_USER_ENV"] = ",".join(k + '=' + v for (k, v) in 
env_map.items())
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to