-
Notifications
You must be signed in to change notification settings - Fork 591
/
options.py
1358 lines (1281 loc) · 46.2 KB
/
options.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
# Copyright 2009-2016 Yelp and Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Functions to populate py:class:`OptionParser` and :py:class:`OptionGroup`
objects with categorized command line parameters. This module should not be
made public until at least 0.4 if not later or never.
"""
import json
from optparse import OptionParser
from optparse import SUPPRESS_USAGE
from mrjob.conf import combine_cmds
from mrjob.conf import combine_dicts
from mrjob.conf import combine_envs
from mrjob.conf import combine_local_envs
from mrjob.conf import combine_lists
from mrjob.conf import combine_paths
from mrjob.conf import combine_path_lists
from mrjob.parse import _parse_port_range_list
from mrjob.py2 import string_types
#: cleanup options:
#:
#: * ``'ALL'``: delete logs and local and remote temp files; stop cluster
#: if on EMR and the job is not done when cleanup is run.
#: * ``'CLOUD_TMP'``: delete temp files on cloud storage (e.g. S3) only
#: * ``'CLUSTER'``: terminate the cluster if on EMR and the job is not done
#: on cleanup
#: * ``'HADOOP_TMP'``: delete temp files on HDFS only
#: * ``'JOB'``: stop job if on EMR and the job is not done when cleanup runs
#: * ``'LOCAL_TMP'``: delete local temp files only
#: * ``'LOGS'``: delete logs only
#: * ``'NONE'``: delete nothing
#: * ``'TMP'``: delete local, HDFS, and cloud storage temp files, but not logs
#:
#: .. versionchanged:: 0.5.0
#:
#: - ``LOCAL_TMP`` used to be ``LOCAL_SCRATCH``
#: - ``HADOOP_TMP`` is new (and used to be covered by ``LOCAL_SCRATCH``)
#: - ``CLOUD_TMP`` used to be ``REMOTE_SCRATCH``
#:
CLEANUP_CHOICES = [
'ALL',
'CLOUD_TMP',
'CLUSTER',
'HADOOP_TMP',
'JOB',
'LOCAL_TMP',
'LOGS',
'NONE',
'TMP',
]
_CLEANUP_DEPRECATED_ALIASES = {
'JOB_FLOW': 'CLUSTER',
'LOCAL_SCRATCH': 'LOCAL_TMP',
'REMOTE_SCRATCH': 'CLOUD_TMP',
'SCRATCH': 'TMP',
}
### custom callbacks ###
def _default_to(parser, dest, value):
"""Helper function; set the given optino dest to *value* if it's None.
This lets us create callbacks that don't require default to be set
to a container."""
if getattr(parser.values, dest) is None:
setattr(parser.values, dest, value)
def _append_to_conf_paths(option, opt_str, value, parser):
"""conf_paths is None by default, but --no-conf or --conf-path should make
it a list.
"""
# make a list to append to if conf_paths is None
_default_to(parser, 'conf_paths', [])
# this method is also called during generate_passthrough_arguments()
# the check below is to ensure that conf_paths are not duplicated
if value not in parser.values.conf_paths:
parser.values.conf_paths.append(value)
def _key_value_callback(option, opt_str, value, parser):
"""callback for KEY=VALUE pairs"""
# used for --cmdenv, --emr-api-param, and more
try:
k, v = value.split('=', 1)
except ValueError:
parser.error('%s argument %r is not of the form KEY=VALUE' % (
opt_str, value))
_default_to(parser, option.dest, {})
getattr(parser.values, option.dest)[k] = v
def _key_none_value_callback(option, opt_str, value, parser):
"""callback to set KEY to None"""
_default_to(parser, option.dest, {})
getattr(parser.values, option.dest)[value] = None
def _cleanup_callback(option, opt_str, value, parser):
"""callback to parse a comma-separated list of cleanup constants."""
result = []
for choice in value.split(','):
if choice in CLEANUP_CHOICES:
result.append(choice)
else:
option_parser.error(
'%s got %s, which is not one of: %s' %
opt_str, choice, ', '.join(CLEANUP_CHOICES))
if 'NONE' in result and len(set(result)) > 1:
option_parser.error(
'%s: Cannot clean up both nothing and something!' % (
opt_str))
setattr(parser.values, option.dest, result)
def _append_json_callback(option, opt_str, value, parser):
"""callback to parse JSON and append it to a list."""
_default_to(parser, option.dest, [])
try:
j = json.loads(value)
except ValueError as e:
option.parser.error('Malformed JSON passed to %s: %s' % (
opt_str, str(e)))
getattr(parser.values, option.dest).append(j)
def _port_range_callback(option, opt_str, value, parser):
"""callback to parse --ssh-bind-ports"""
try:
ports = parse_port_range_list(value)
except ValueError as e:
option_parser.error('%s: invalid port range list %r: \n%s' %
(opt_str, value, e.args[0]))
setattr(parser.values, option.dest, ports)
### runner opts ###
# map from runner option name to dict with the following keys (all optional):
# cloud_role:
# 'connect' if needed when interacting with cloud services at all
# 'launch' if needed when creating a new cluster
# (cloud runner options with no cloud role are only needed when running jobs)
# combiner: combiner func from mrjob.conf used to combine option values.
# (if left blank, we use combine_values())
# deprecated: if true, this option is deprecated and slated for removal
# deprecated_aliases: list of old names for this option slated for removal
# runner_combiners: map from runner alias to different combiner to use
# for that runner (we use this to get combine_local_envs() on sim runners)
# runners: list of aliases of runners that support this option (leave out
# for options common to all runners
# switches: list of switches to add to option parser for this option. Items
# have the format (['--switch-names', ...], dict(**kwargs)), where kwargs
# can be:
# action: action to pass to option parser (e.g. 'store_true')
# callback: option parser callback when action is 'callback'. implies
# action='callback'
# deprecated_aliases: list of old '--switch-names' slated for removal
# help: help string to pass to option parser
# nargs: number of args for callback to parse (defaults to 1 for callback)
# type: option type for option parser to enforce (e.g. 'float'). defaults
# to 'string' for callback
# You can't set the option parser's default; we use [] if *action* is
# 'append' and None otherwise.
_RUNNER_OPTS = dict(
additional_emr_info=dict(
cloud_role='launch',
runners=['emr'],
switches=[
(['--additional-emr-info'], dict(
help='A JSON string for selecting additional features on EMR',
)),
],
),
aws_access_key_id=dict(
cloud_role='connect',
runners=['emr'],
),
aws_secret_access_key=dict(
cloud_role='connect',
runners=['emr'],
),
aws_security_token=dict(
cloud_role='connect',
runners=['emr'],
),
bootstrap=dict(
cloud_role='launch',
combiner=combine_lists,
runners=['dataproc', 'emr'],
switches=[
(['--bootstrap'], dict(
action='append',
help=('A shell command to set up libraries etc. before any'
' steps (e.g. "sudo apt-get -qy install python3"). You'
' may interpolate files available via URL or locally'
' with Hadoop Distributed Cache syntax'
' ("sudo yum install -y foo.rpm#")'),
)),
],
),
bootstrap_actions=dict(
cloud_role='launch',
combiner=combine_lists,
runners=['emr'],
switches=[
(['--bootstrap-action'], dict(
action='append',
help=('Raw bootstrap action scripts to run before any of the'
' other bootstrap steps. You can use --bootstrap-action'
' more than once. Local scripts will be automatically'
' uploaded to S3. To add arguments, just use quotes:'
' "foo.sh arg1 arg2"'),
)),
],
),
bootstrap_cmds=dict(
cloud_role='launch',
combiner=combine_lists,
deprecated=True,
runners=['emr'],
switches=[
(['--bootstrap-cmd'], dict(
action='append',
help=('Commands to run on the master node to set up libraries,'
' etc. You can use --bootstrap-cmd more than once. Use'
' mrjob.conf to specify arguments as a list to be run'
' directly.'),
)),
],
),
bootstrap_files=dict(
cloud_role='launch',
combiner=combine_path_lists,
deprecated=True,
runners=['emr'],
switches=[
(['--bootstrap-file'], dict(
action='append',
help=('File to upload to the master node before running'
' bootstrap_cmds (for example, debian packages). You'
' can use --bootstrap-file more than once.'),
)),
],
),
bootstrap_mrjob=dict(
cloud_role='launch',
switches=[
(['--bootstrap-mrjob'], dict(
action='store_true',
help=("Automatically tar up the mrjob library and install it"
" when we run the mrjob. This is the default. Use"
" --no-bootstrap-mrjob if you've already installed"
" mrjob on your Hadoop cluster."),
)),
(['--no-bootstrap-mrjob'], dict(
action='store_false',
help=("Don't automatically tar up the mrjob library and"
" install it when we run this job. Use this if you've"
" already installed mrjob on your Hadoop cluster."),
)),
],
),
bootstrap_python=dict(
cloud_role='launch',
runners=['dataproc', 'emr'],
switches=[
(['--bootstrap-python'], dict(
action='store_true',
help=('Attempt to install a compatible version of Python'
' at bootstrap time. Currently this only does anything'
' for Python 3, for which it is enabled by default.'),
)),
(['--no-bootstrap-python'], dict(
action='store_false',
help=("Don't automatically try to install a compatible version"
" of Python at bootstrap time."),
)),
],
),
bootstrap_python_packages=dict(
cloud_role='launch',
combiner=combine_path_lists,
deprecated=True,
runners=['emr'],
switches=[
(['--bootstrap-python-package'], dict(
action='append',
help=('Path to a Python module to install on EMR. These should'
' be standard python module tarballs where you can cd'
' into a subdirectory and run ``sudo python setup.py'
' install``. You can use --bootstrap-python-package more'
' than once.'),
)),
],
),
bootstrap_scripts=dict(
cloud_role='launch',
combiner=combine_path_lists,
deprecated=True,
runners=['emr'],
switches=[
(['--bootstrap-script'], dict(
action='append',
help=('Script to upload and then run on the master node (a'
' combination of bootstrap_cmds and bootstrap_files).'
' These are run after the command from bootstrap_cmds.'
' You can use --bootstrap-script more than once.'),
)),
],
),
check_input_paths=dict(
switches=[
(['--check-input-paths'], dict(
action='store_true',
help='Check input paths exist before running (the default)',
)),
(['--no-check-input-paths'], dict(
action='store_false',
help='Skip the checks to ensure all input paths exist',
)),
],
),
check_cluster_every=dict(
deprecated_aliases=['check_emr_status_every'],
runners=['dataproc', 'emr'],
switches=[
(['--check-cluster-every'], dict(
deprecated_aliases=['--check-emr-status-every'],
help=('How often (in seconds) to check status of your'
' job/cluster'),
)),
],
),
cleanup=dict(
switches=[
(['--cleanup'], dict(
callback=_cleanup_callback,
help=('Comma-separated list of which directories to delete'
' when a job succeeds, e.g. TMP,LOGS. Choices:'
' %s (default: ALL)' % ', '.join(CLEANUP_CHOICES)),
)),
],
),
cleanup_on_failure=dict(
switches=[
(['--cleanup-on-failure'], dict(
callback=_cleanup_callback,
help=('Comma-separated list of which directories to delete'
' when a job fails, e.g. TMP,LOGS. Choices:'
' %s (default: NONE)' % ', '.join(CLEANUP_CHOICES)),
)),
],
),
cloud_fs_sync_secs=dict(
cloud_role='launch',
deprecated_aliases=['s3_sync_wait_time'],
runners=['dataproc', 'emr'],
switches=[
(['--cloud-fs-sync-secs'], dict(
deprecated_aliases=['--s3-sync-wait-time'],
help=('How long to wait for remote FS to reach eventual'
' consistency. This'
' is typically less than a second but the'
' default is 5.0 to be safe.'),
type='float',
)),
],
),
cloud_log_dir=dict(
cloud_role='launch',
combiner=combine_paths,
deprecated_aliases=['s3_log_uri'],
runners=['emr'],
switches=[
(['--cloud-log-dir'], dict(
deprecated_aliases=['--s3-log-uri'],
help='URI on remote FS to write logs into',
)),
],
),
cloud_tmp_dir=dict(
cloud_role='launch',
combiner=combine_paths,
deprecated_aliases=['s3_scratch_uri', 's3_tmp_dir'],
runners=['dataproc', 'emr'],
switches=[
(['--cloud-tmp-dir'], dict(
deprecated_aliases=['--s3-scratch-uri', '--s3-tmp-dir'],
help='URI on remote FS to use as our temp directory.',
)),
],
),
cloud_upload_part_size=dict(
cloud_role='launch',
deprecated_aliases=['s3_upload_part_size'],
runners=['emr'],
switches=[
(['--cloud-upload-part-size'], dict(
deprecated_aliases=['--s3-upload-part-size'],
help=('Upload files to S3 in parts no bigger than this many'
' megabytes. Default is 100 MiB. Set to 0 to disable'
' multipart uploading entirely.'),
type='float',
)),
],
),
cluster_id=dict(
deprecated_aliases=['emr_job_flow_id'],
runners=['dataproc', 'emr'],
switches=[
(['--cluster-id'], dict(
deprecated_aliases=['--emr-job-flow-id'],
help='ID of an existing cluster to run our job on',
)),
],
),
cmdenv=dict(
combiner=combine_envs,
runner_combiners=dict(
inline=combine_local_envs,
local=combine_local_envs,
),
switches=[
(['--cmdenv'], dict(
callback=_key_value_callback,
help=('Set an environment variable for your job inside Hadoop '
'streaming. Must take the form KEY=VALUE. You can use'
' --cmdenv multiple times.'),
)),
],
),
core_instance_bid_price=dict(
cloud_role='launch',
deprecated_aliases=['ec2_core_instance_bid_price'],
runners=['emr'],
switches=[
(['--core-instance-bid-price'], dict(
deprecated_aliases=['--ec2-core-instance-bid-price'],
help=('Bid price to specify for core nodes when'
' setting them up as EC2 spot instances (you probably'
' only want to do this for task instances).'),
)),
],
),
core_instance_type=dict(
cloud_role='launch',
deprecated_aliases=[
'ec2_core_instance_type', 'ec2_slave_instance_type'],
runners=['dataproc', 'emr'],
switches=[
(['--core-instance-type'], dict(
deprecated_aliases=[
'--ec2-core-instance-type', '--ec2-slave-instance-type'],
help='Type of GCE/EC2 core instance(s) to launch',
)),
],
),
ec2_key_pair=dict(
cloud_role='launch',
runners=['emr'],
switches=[
(['--ec2-key-pair'], dict(
help='Name of the SSH key pair you set up for EMR',
)),
],
),
ec2_key_pair_file=dict(
combiner=combine_paths,
runners=['emr'],
switches=[
(['--ec2-key-pair-file'], dict(
help='Path to file containing SSH key for EMR',
)),
],
),
emr_action_on_failure=dict(
runners=['emr'],
switches=[
(['--emr-action-on-failure'], dict(
help=('Action to take when a step fails'
' (e.g. TERMINATE_CLUSTER, CANCEL_AND_WAIT, CONTINUE)'),
)),
],
),
emr_api_params=dict(
cloud_role='launch',
combiner=combine_dicts,
runners=['emr'],
switches=[
(['--emr-api-param'], dict(
callback=_key_value_callback,
help=('Additional parameter to pass directly to the EMR'
' API when creating a cluster. Should take the form'
' KEY=VALUE. You can use --emr-api-param multiple'
' times'),
)),
(['--no-emr-api-param'], dict(
callback=_key_none_value_callback,
help=('Parameter to be unset when calling EMR API.'
' You can use --no-emr-api-param multiple times.'),
)),
],
),
emr_applications=dict(
cloud_role='launch',
combiner=combine_lists,
runners=['emr'],
switches=[
(['--emr-application'], dict(
action='append',
help=('Additional applications to run on 4.x AMIs (e.g.'
' Ganglia, Mahout, Spark)'),
)),
],
),
emr_configurations=dict(
cloud_role='launch',
combiner=combine_lists,
runners=['emr'],
switches=[
(['--emr-configuration'], dict(
callback=_append_json_callback,
help=('Configuration to use on 4.x AMIs as a JSON-encoded'
' dict; see'
' http://docs.aws.amazon.com/ElasticMapReduce/latest/'
'ReleaseGuide/emr-configure-apps.html for examples'),
)),
],
),
emr_endpoint=dict(
cloud_role='connect',
runners=['emr'],
switches=[
(['--emr-endpoint'], dict(
help=('Force mrjob to connect to EMR on this endpoint'
' (e.g. us-west-1.elasticmapreduce.amazonaws.com).'
' Default is to infer this from region.'),
)),
],
),
enable_emr_debugging=dict(
cloud_role='launch',
runners=['emr'],
switches=[
(['--enable-emr-debugging'], dict(
action='store_true',
help='Enable storage of Hadoop logs in SimpleDB',
)),
(['--disable-emr-debugging'], dict(
action='store_false',
help=('Disable storage of Hadoop logs in SimpleDB (the'
' default)'),
)),
],
),
gcp_project=dict(
runners=['dataproc'],
switches=[
(['--gcp-project'], dict(
help='Project to run Dataproc jobs in'
)),
],
),
hadoop_bin=dict(
combiner=combine_cmds,
runners=['hadoop'],
switches=[
(['--hadoop-bin'], dict(help='path to hadoop binary')),
],
),
hadoop_extra_args=dict(
combiner=combine_lists,
runners=['emr', 'hadoop'],
switches=[
(['--hadoop-arg'], dict(
action='append',
help=('Argument of any type to pass to hadoop '
'streaming. You can use --hadoop-arg multiple times.'),
)),
],
),
hadoop_home=dict(
combiner=combine_paths,
deprecated=True,
runners=['hadoop'],
switches=[
(['--hadoop-home'], dict(
help=('Deprecated hint about where to find hadoop binary and'
' streaming jar. In most cases mrjob will now find these'
' on its own. If not, use the --hadoop-bin and'
' --hadoop-streaming-jar switches.'),
)),
],
),
hadoop_log_dirs=dict(
combiner=combine_path_lists,
runners=['hadoop'],
switches=[
(['--hadoop-log-dirs'], dict(
action='append',
help=('Directory to search for hadoop logs in. You can use'
' --hadoop-log-dir multiple times.'),
)),
],
),
hadoop_streaming_jar=dict(
combiner=combine_paths,
runners=['emr', 'hadoop'],
switches=[
(['--hadoop-streaming-jar'], dict(
help=('Path of your hadoop streaming jar (locally, or on'
' S3/HDFS). In EMR, use a file:// URI to refer to a jar'
' on the master node of your cluster.'),
)),
],
),
hadoop_streaming_jar_on_emr=dict(
deprecated=True,
runners=['emr'],
switches=[
(['--hadoop-streaming-jar-on-emr'], dict(
help=("Deprecated: prepend 'file://' and pass that to"
" --hadoop-streaming-jar instead"),
)),
],
),
hadoop_tmp_dir=dict(
combiner=combine_paths,
deprecated_aliases=['hdfs_scratch_dir'],
runners=['hadoop'],
switches=[
(['--hadoop-tmp-dir'], dict(
deprecated_aliases=['--hdfs-scratch-dir'],
help='Temp space on HDFS (default is tmp/mrjob)',
)),
],
),
hadoop_version=dict(
runners=['inline', 'local'],
switches=[
(['--hadoop-version'], dict(
help='Specific version of Hadoop to simulate',
)),
],
),
iam_endpoint=dict(
cloud_role='launch', # not 'connect'; only used to create clusters
runners=['emr'],
switches=[
(['--iam-endpoint'], dict(
help=('Force mrjob to connect to IAM on this endpoint'
' (e.g. iam.us-gov.amazonaws.com)'),
)),
],
),
iam_instance_profile=dict(
cloud_role='launch',
runners=['emr'],
switches=[
(['--iam-instance-profile'], dict(
help=('EC2 instance profile to use for the EMR cluster -- see'
' "Configure IAM Roles for Amazon EMR" in AWS docs'),
)),
],
),
iam_service_role=dict(
cloud_role='launch',
runners=['emr'],
switches=[
(['--iam-service-role'], dict(
help=('IAM service role to use for the EMR cluster -- see'
' "Configure IAM Roles for Amazon EMR" in AWS docs')
)),
],
),
image_version=dict(
cloud_role='launch',
deprecated_aliases=['ami_version'],
runners=['dataproc', 'emr'],
switches=[
(['--image-version'], dict(
deprecated_aliases=['--ami-version'],
help='EMR/Dataproc machine image to launch clusters with',
)),
],
),
instance_type=dict(
cloud_role='launch',
deprecated_aliases=['ec2_instance_type'],
runners=['dataproc', 'emr'],
switches=[
(['--instance-type'], dict(
deprecated_aliases=['--ec2-instance-type'],
help=('Type of GCE/EC2 instance(s) to launch \n'
' GCE - e.g. n1-standard-1, n1-highcpu-4, n1-highmem-4'
' -- See'
' https://cloud.google.com/compute/docs/machine-types\n'
' EC2 - e.g. m1.medium, c3.xlarge, r3.xlarge '
' -- See http://aws.amazon.com/ec2/instance-types/'
),
)),
],
),
interpreter=dict(
combiner=combine_cmds,
switches=[
(['--interpreter'], dict(
help='Non-python command to run your script, e.g. "ruby".',
)),
],
),
jobconf=dict(
combiner=combine_dicts,
switches=[
(['--jobconf'], dict(
callback=_key_value_callback,
help=('-D arg to pass through to hadoop streaming; should'
' take the form KEY=VALUE. You can use --jobconf'
' multiple times.'),
)),
],
),
label=dict(
cloud_role='launch',
switches=[
(['--label'], dict(
help='Alternate label for the job, to help us identify it.',
)),
],
),
libjars=dict(
combiner=combine_path_lists,
switches=[
(['--libjar'], dict(
action='append',
help=('Path of a JAR to pass to Hadoop with -libjar. On EMR,'
' this can also be a URI; use file:/// to reference JARs'
' already on the EMR cluster'),
)),
],
),
local_tmp_dir=dict(
combiner=combine_paths,
deprecated_aliases=['base_tmp_dir'],
# no switches, use $TMPDIR etc.
),
master_instance_bid_price=dict(
cloud_role='launch',
deprecated_aliases=['ec2_master_instance_bid_price'],
runners=['emr'],
switches=[
(['--master-instance-bid-price'], dict(
deprecated_aliases=['--ec2-master-instance-bid-price'],
help=('Bid price to specify for the master node when'
' setting it up as an EC2 spot instance (you probably'
' only want to do this for task instances).'),
)),
],
),
master_instance_type=dict(
deprecated_aliases=['ec2_master_instance_type'],
cloud_role='launch',
runners=['dataproc', 'emr'],
switches=[
(['--master-instance-type'], dict(
deprecated_aliases=['--ec2-master-instance-type'],
help='Type of GCE/EC2 master instance to launch',
)),
],
),
max_hours_idle=dict(
cloud_role='launch',
runners=['dataproc', 'emr'],
switches=[
(['--max-hours-idle'], dict(
help=("If we create a cluster, have it automatically"
" terminate itself after it's been idle this many"
" hours"),
type='float',
)),
],
),
mins_to_end_of_hour=dict(
cloud_role='launch',
runners=['emr'],
switches=[
(['--mins-to-end-of-hour'], dict(
help=("If --max-hours-idle is set, control how close to the"
" end of an hour the cluster can automatically"
" terminate itself (default is 5 minutes)"),
type='float',
)),
],
),
num_core_instances=dict(
cloud_role='launch',
deprecated_aliases=['num_ec2_core_instances'],
runners=['dataproc', 'emr'],
switches=[
(['--num-core-instances'], dict(
deprecated_aliases=['--num-ec2-core-instances'],
help='Total number of core instances to launch',
type='int',
)),
],
),
num_ec2_instances=dict(
cloud_role='launch',
deprecated=True,
runners=['emr'],
switches=[
(['--num-ec2-instances'], dict(
help=('Deprecated: subtract one and pass that to '
'--num-core-instances instead'),
type='int',
)),
],
),
num_task_instances=dict(
cloud_role='launch',
deprecated_aliases=['num_ec2_task_instances'],
runners=['dataproc', 'emr'],
switches=[
(['--num-task-instances'], dict(
deprecated_aliases=['--num-ec2-task-instances'],
help='Total number of task instances to launch',
type='int',
)),
],
),
owner=dict(
cloud_role='launch',
switches=[
(['--owner'], dict(
help='User who ran the job (default is the current user)',
)),
],
),
pool_clusters=dict(
cloud_role='launch',
deprecated_aliases=['pool_emr_job_flows'],
runners=['emr'],
switches=[
(['--pool-clusters'], dict(
deprecated_aliases=['--pool-emr-job-flows'],
action='store_true',
help=('Add to an existing cluster or create a new one that'
' does not terminate when the job completes.\n'
'WARNING: do not run this without --max-hours-idle or '
' with mrjob terminate-idle-clusters in your crontab;'
' clusters left idle can quickly become expensive!'),
)),
(['--no-pool-clusters'], dict(
deprecated_aliases=['--no-pool-emr-job-flows'],
action='store_false',
help="Don't run job on a pooled cluster (the default)",
)),
],
),
pool_name=dict(
cloud_role='launch',
deprecated_aliases=['emr_job_flow_pool_name'],
runners=['emr'],
switches=[
(['--pool-name'], dict(
deprecated_aliases=['--emr-job-flow-pool-name'],
help='Specify a pool name to join. Default is "default"',
)),
],
),
pool_wait_minutes=dict(
runners=['emr'],
switches=[
(['--pool-wait-minutes'], dict(
help=('Wait for a number of minutes for a cluster to finish'
' if a job finishes, run job on its cluster. Otherwise'
" create a new one. (0, the default, means don't wait)"),
type='int',
)),
],
),
python_archives=dict(
combiner=combine_path_lists,
switches=[
(['--python-archive'], dict(
action='append',
help=('Archive to unpack and add to the PYTHONPATH of the'
' MRJob script when it runs. You can use'
' --python-archives multiple times.'),
)),
],
),
python_bin=dict(
combiner=combine_cmds,
switches=[
(['--python-bin'], dict(
help=('Alternate python command for Python mappers/reducers.'
' You can include arguments, e.g. --python-bin "python'
' -v"'),
)),
],
),
region=dict(
cloud_role='connect',
deprecated_aliases=['aws_region'],
runners=['dataproc', 'emr'],
switches=[
(['--region'], dict(
deprecated_aliases=['--aws-region'],
help='GCE/AWS region to run Dataproc/EMR jobs in.',
)),
],
),
release_label=dict(
cloud_role='launch',
runners=['emr'],
switches=[
(['--release-label'], dict(
help=('Release Label (e.g. "emr-4.0.0"). Overrides'
' --image-version'),
)),
],
),
s3_endpoint=dict(
cloud_role='connect',
runners=['emr'],
switches=[
(['--s3-endpoint'], dict(
help=("Force mrjob to connect to S3 on this endpoint (e.g."
" s3-us-west-1.amazonaws.com). You usually shouldn't"
" set this; by default mrjob will choose the correct"
" endpoint for each S3 bucket based on its location."),
)),
],
),
setup=dict(
combiner=combine_lists,
switches=[
(['--setup'], dict(
action='append',
help=('A command to run before each mapper/reducer step in the'
' shell ("touch foo"). You may interpolate files'
' available via URL or on your local filesystem using'
' Hadoop Distributed Cache syntax (". setup.sh#"). To'
' interpolate archives, use #/: "cd foo.tar.gz#/; make'),
)),
],
),
setup_cmds=dict(
combiner=combine_lists,
deprecated=True,
switches=[
(['--setup-cmd'], dict(
action='append',
help=('A command to run before each mapper/reducer step in the'
' shell (e.g. "cd my-src-tree; make") specified as a'
' string. You can use --setup-cmd more than once. Use'
' mrjob.conf to specify arguments as a list to be run'
' directly.'),
)),
],
),
setup_scripts=dict(
combiner=combine_path_lists,
deprecated=True,
switches=[
(['--setup-script'], dict(
action='append',
help=('Path to file to be copied into the local working'
' directory and then run. You can use --setup-script'
' more than once. These are run after setup_cmds.'),
)),
],
),
sh_bin=dict(
combiner=combine_cmds,
switches=[