When I run a python application, and specify a remote path for the extra files to be included in the PYTHON_PATH using the '--py-files' or 'spark.submit.pyFiles' configuration option in YARN Cluster mode I get the following error:
Exception in thread "main" java.lang.IllegalArgumentException: Launching Python applications through spark-submit is currently only supported for local files: s3://xxxx/app.py
Here are sample commands which would throw this error in Spark 2.0 (sparkApp.py requires app.py):
spark-submit --deploy-mode cluster --py-files s3://xxxx/app.py s3://xxxx/sparkApp.py (works fine in 1.6)
spark-submit --deploy-mode cluster --conf spark.submit.pyFiles=s3://xxxx/app.py s3://xxxx/sparkApp1.py (not working in 1.6)
This would work fine if app.py is downloaded locally and specified.
This was working correctly using ‘—py-files’ option in earlier version of Spark, but not using the ‘spark.submit.pyFiles’ configuration option. But now, it does not work through either of the ways.
The following diff shows the comment which states that it should work with ‘non-local’ paths for the YARN cluster mode, and we are specifically doing separate validation to fail if YARN client mode is used with remote paths:
And then this code gets triggered at the end of each run, irrespective of whether we are using Client or Cluster mode, and internally validates that the paths should be non-local:
This above validation was not getting triggered in earlier version of Spark using ‘—py-files’ option because we were not storing the arguments passed to ‘—py-files’ in the ‘spark.submit.pyFiles’ configuration for YARN. However, the following code was newly added in 2.0 which now stores it and hence this validation gets triggered even if we specify files through ‘—py-files’ option:
Also, we changed the logic in YARN client, to read values directly from ‘spark.submit.pyFiles’ configuration instead of from ‘—py-files’ (earlier):
So now its broken whether we use ‘—py-files’ or ‘spark.submit.pyFiles’ as the validation gets triggered in both cases irrespective of whether we use Client or Cluster mode with YARN.