77from aztk_cli import config , log , utils
88
99
10+ class AppendToDict (argparse .Action ):
11+ def __call__ (self , parser , namespace , values , option_string = None ):
12+ key_vals = getattr (namespace , self .dest ) or {}
13+ for key_val_str in values .replace (" " , "" ).split ("," ):
14+ key , val = key_val_str .split ("=" )
15+ key_vals [key ] = val
16+ setattr (namespace , self .dest , key_vals )
17+
18+
1019def setup_parser (parser : argparse .ArgumentParser ):
1120 parser .add_argument ("--id" , dest = "cluster_id" , required = True , help = "The unique id of your spark cluster" )
1221
@@ -25,6 +34,32 @@ def setup_parser(parser: argparse.ArgumentParser):
2534 absolute path to reference files." ,
2635 )
2736
37+ parser .add_argument (
38+ "--packages" ,
39+ help = "Comma-separated list of maven coordinates of \
40+ jars to include on the driver and executor \
41+ classpaths. Will search the local maven repo, \
42+ then maven central and any additional remote \
43+ repositories given by --repositories. The \
44+ format for the coordinates should be \
45+ groupId:artifactId:version." ,
46+ )
47+
48+ parser .add_argument (
49+ "--exclude-packages" ,
50+ help = "Comma-separated list of groupId:artifactId, to \
51+ exclude while resolving the dependencies \
52+ provided in --packages to avoid dependency \
53+ conflicts." ,
54+ )
55+
56+ parser .add_argument (
57+ "--repositories" ,
58+ help = "Comma-separated list of additional remote \
59+ repositories to search for the maven \
60+ coordinates given with --packages." ,
61+ )
62+
2863 parser .add_argument (
2964 "--py-files" ,
3065 help = "Comma-separated list of .zip, .egg, or .py files \
@@ -39,6 +74,24 @@ def setup_parser(parser: argparse.ArgumentParser):
3974 absolute path ot reference files." ,
4075 )
4176
77+ parser .add_argument (
78+ "--conf" ,
79+ action = AppendToDict ,
80+ metavar = '"PROP1=VAL1[,PROP2=VAL2...]"' ,
81+ help = 'Arbitrary Spark configuration property(/-ies). \
82+ Multiple --conf options can be added, either \
83+ by using multiple --conf flags or by supplying \
84+ a comma-separated list. All "PROP=VAL,..." \
85+ arguments should be wrapped in double quotes.' ,
86+ )
87+
88+ parser .add_argument (
89+ "--properties-file" ,
90+ help = "Path to a file from which to load extra \
91+ properties. If not specified, this will look \
92+ for conf/spark-defaults.conf." ,
93+ )
94+
4295 parser .add_argument ("--driver-java-options" , help = "Extra Java options to pass to the driver." )
4396
4497 parser .add_argument ("--driver-library-path" , help = "Extra library path entries to pass to the driver." )
@@ -105,6 +158,9 @@ def execute(args: typing.NamedTuple):
105158
106159 spark_client = aztk .spark .Client (config .load_aztk_secrets ())
107160 jars = []
161+ packages = []
162+ exclude_packages = []
163+ repositories = []
108164 py_files = []
109165 files = []
110166
@@ -117,6 +173,15 @@ def execute(args: typing.NamedTuple):
117173 if args .files is not None :
118174 files = args .files .replace (" " , "" ).split ("," )
119175
176+ if args .packages is not None :
177+ packages = args .packages .replace (" " , "" ).split ("," )
178+
179+ if args .exclude_packages is not None :
180+ exclude_packages = args .exclude_packages .replace (" " , "" ).split ("," )
181+
182+ if args .repositories is not None :
183+ repositories = args .repositories .replace (" " , "" ).split ("," )
184+
120185 log_application (args , jars , py_files , files )
121186
122187 spark_client .cluster .submit (
@@ -127,8 +192,13 @@ def execute(args: typing.NamedTuple):
127192 application_args = args .app_args ,
128193 main_class = args .main_class ,
129194 jars = jars ,
195+ packages = packages ,
196+ exclude_packages = exclude_packages ,
197+ repositories = repositories ,
130198 py_files = py_files ,
131199 files = files ,
200+ conf = args .conf ,
201+ properties_file = args .properties_file ,
132202 driver_java_options = args .driver_java_options ,
133203 driver_library_path = args .driver_library_path ,
134204 driver_class_path = args .driver_class_path ,
0 commit comments