Jinho Yoo Jinho Yoo - 1 year ago 180
Python Question

Can I add arguments to python code when I submit spark job?

I'm trying to use

to execute my python code in spark cluster.

Generally we run
with python code like below.

# Run a Python application on a cluster
./bin/spark-submit \
--master spark:// \
my_python_code.py \

But I wanna run
by passing several arguments Is there smart way to pass arguments?

Answer Source

Yes: Put this in a file called args.py

#import sys
print sys.argv

If you run

spark-submit args.py a b c d e 

You will see:

['/spark/args.py', 'a', 'b', 'c', 'd', 'e']
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download