mortar 0.15.36 → 0.15.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8038226d4444ee657c0f34ef9af8ed05deec35b5
4
- data.tar.gz: 05086ca35f9a1ce136d0f679fe6d3ea000ee9aca
3
+ metadata.gz: 15cff7085bdc1d7475ce5de63a224f1e5f9af981
4
+ data.tar.gz: e273bd6668c0752d89cef8546c1c43cdc69f1d92
5
5
  SHA512:
6
- metadata.gz: 4e6dcc9dee6926957ddce2e1b6f804d46dffd1be318659ff3c65e9cdb17695c986e6aaea3f037979fce108293afd3a75adab9addc5f6cf87648669565fd43797
7
- data.tar.gz: 32dc2c1c42b58400465496b8169c21689cbac62873c8c16474027edb523a602178fab6633065beee99152ad3e70fa3467cfbe0fae8b1f6f22c3bdff62992df02
6
+ metadata.gz: 3c52e4a5fb9d3921626417c54aa3622d8494b81bb481155862918c05a9d1a69c3f1ceab0ac4485409533f383d2c1d1043b9c7d89293c35c27f12ade5e2d49ae7
7
+ data.tar.gz: c31c3f2135b0e592630cbf622d9815d7ccb28eb741826e203df3b11be0d427b5c936ec67e23543a5494ff1444ec1bee0eb91c990234ffe9a8d9c32d49845be84
@@ -296,7 +296,7 @@ protected
296
296
 
297
297
  def self.replace_templates(help)
298
298
  help.each do |line|
299
- line.gsub!("<PIG_VERSION_OPTIONS>", "0.9 (default) and 0.12")
299
+ line.gsub!("<PIG_VERSION_OPTIONS>", "0.12 and 0.12-Hadoop-2")
300
300
  end
301
301
  end
302
302
 
@@ -608,7 +608,7 @@ protected
608
608
  end
609
609
 
610
610
  def pig_version
611
- pig_version_str = options[:pigversion] || '0.9'
611
+ pig_version_str = options[:pigversion] || '0.12'
612
612
  pig_version = Mortar::PigVersion.from_string(pig_version_str)
613
613
  end
614
614
 
@@ -27,21 +27,27 @@ class Mortar::Command::Config < Mortar::Command::Base
27
27
  #
28
28
  # Display the config vars for a project.
29
29
  #
30
- # -s, --shell # output config vars in shell format
30
+ # -s, --shell # output config vars in shell format.
31
31
  #
32
32
  #
33
33
  # $ mortar config
34
34
  # A: one
35
+ # B: three
36
+ #
37
+ # == Project config settings overriden by user config
35
38
  # B: two
36
39
  #
40
+ #
37
41
  # $ mortar config --shell
38
42
  # A=one
39
- # B=two
43
+ # B=three
40
44
  #
41
45
  def index
42
46
  validate_arguments!
43
47
  project_name = options[:project] || project.name
44
- vars = api.get_config_vars(project_name).body['config']
48
+ config_body = api.get_config_vars(project_name).body
49
+ vars = config_body['config']
50
+ shadow_vars = config_body['shadow_config'] || {}
45
51
  if vars.empty?
46
52
  display("#{project_name} has no config vars.")
47
53
  else
@@ -53,6 +59,12 @@ class Mortar::Command::Config < Mortar::Command::Base
53
59
  else
54
60
  styled_header("#{project_name} Config Vars")
55
61
  styled_hash(vars)
62
+ unless shadow_vars.empty?
63
+ shadow_vars.each {|key, value| shadow_vars[key] = value.to_s}
64
+ display("\n")
65
+ styled_header("Project config settings overriden by user config")
66
+ styled_hash(shadow_vars)
67
+ end
56
68
  end
57
69
  end
58
70
  end
@@ -86,6 +98,10 @@ class Mortar::Command::Config < Mortar::Command::Base
86
98
  #
87
99
  # Set one or more config vars
88
100
  #
101
+ # -u, --user # Set the config value for your user. Only visible to your user
102
+ # # and will apply to all projects. Will overwrite a project config
103
+ # # variable with the same key.
104
+ #
89
105
  #Example:
90
106
  #
91
107
  # $ mortar config:set A=one
@@ -97,6 +113,11 @@ class Mortar::Command::Config < Mortar::Command::Base
97
113
  # A: one
98
114
  # B: two
99
115
  #
116
+ # $ mortar config:set B=three -u
117
+ # Setting config vars... done.
118
+ # A: one
119
+ # B: three
120
+ #
100
121
  def set
101
122
  unless args.size > 0 and args.all? { |a| a.include?('=') }
102
123
  error("Usage: mortar config:set KEY1=VALUE1 [KEY2=VALUE2 ...]\nMust specify KEY and VALUE to set.")
@@ -108,10 +129,15 @@ class Mortar::Command::Config < Mortar::Command::Base
108
129
  vars
109
130
  end
110
131
 
111
- project_name = options[:project] || project.name
112
-
113
- action("Setting config vars for project #{project_name}") do
114
- api.put_config_vars(project_name, vars)
132
+ if options[:user]
133
+ action("Setting config vars for your user") do
134
+ api.put_user_config_vars(vars)
135
+ end
136
+ else
137
+ project_name = options[:project] || project.name
138
+ action("Setting config vars for project #{project_name}") do
139
+ api.put_config_vars(project_name, vars)
140
+ end
115
141
  end
116
142
 
117
143
  vars.each {|key, value| vars[key] = value.to_s}
@@ -125,6 +151,9 @@ class Mortar::Command::Config < Mortar::Command::Base
125
151
  #
126
152
  # unset one or more config vars
127
153
  #
154
+ # -u, --user # Unset the config value for your user. Only affecsts your user
155
+ # # and will apply to all projects.
156
+ #
128
157
  # $ mortar config:unset A
129
158
  # Unsetting A... done
130
159
  #
@@ -132,14 +161,26 @@ class Mortar::Command::Config < Mortar::Command::Base
132
161
  # Unsetting A... done
133
162
  # Unsetting B... done
134
163
  #
164
+ # $ mortar config:unset A B -u
165
+ # Unsetting A... done
166
+ # Unsetting B... done
167
+ #
135
168
  def unset
136
169
  if args.empty?
137
170
  error("Usage: mortar config:unset KEY1 [KEY2 ...]\nMust specify KEY to unset.")
138
171
  end
139
- project_name = options[:project] || project.name
140
- args.each do |key|
141
- action("Unsetting #{key} for project #{project_name}") do
142
- api.delete_config_var(project_name, key)
172
+ if options[:user]
173
+ args.each do |key|
174
+ action("Unsetting #{key} for your user") do
175
+ api.delete_user_config_var(key)
176
+ end
177
+ end
178
+ else
179
+ project_name = options[:project] || project.name
180
+ args.each do |key|
181
+ action("Unsetting #{key} for project #{project_name}") do
182
+ api.delete_config_var(project_name, key)
183
+ end
143
184
  end
144
185
  end
145
186
  end
@@ -114,7 +114,7 @@ class Mortar::Command::Jobs < Mortar::Command::Base
114
114
  end
115
115
 
116
116
  unless options[:clusterid] || options[:clustersize]
117
- clusters = api.get_clusters(Mortar::API::Jobs::CLUSTER_BACKEND__EMR_HADOOP_1).body['clusters']
117
+ clusters = api.get_clusters(pig_version.cluster_backend).body['clusters']
118
118
 
119
119
  largest_free_cluster = clusters.select{ |c| \
120
120
  c['running_jobs'].length == 0 && c['status_code'] == Mortar::API::Clusters::STATUS_RUNNING }.
@@ -41,7 +41,7 @@ class Mortar::Command::Local < Mortar::Command::Base
41
41
  Dir.chdir(project_root)
42
42
 
43
43
  ctrl = Mortar::Local::Controller.new
44
- ctrl.install_and_configure(pig_version, nil, true)
44
+ ctrl.install_and_configure(pig_version, nil)
45
45
  end
46
46
 
47
47
  # local:run SCRIPT
@@ -277,139 +277,4 @@ class Mortar::Command::Local < Mortar::Command::Base
277
277
  ctrl.run_luigi(pig_version, script, cli_parameters, project_config_params)
278
278
  end
279
279
 
280
- # local:sqoop_table dbtype database-name table s3-destination
281
- #
282
- # Export data from an RDBMS table to S3.
283
- #
284
- # -h, --host HOSTNAME # Database host, localhost assumed if not specified
285
- # -u, --username USERNAME # User to log into the database with
286
- # -p, --password PASSWORD # Password to log into the database
287
- # -j, --jdbcdriver COM.DRIVER.BAR # Name of the JDBC driver class
288
- # -d, --direct # Use a direct import path
289
- # -r, --driverjar JARFILE # Path to the jar containing the jdbc driver
290
- # -c, --jdbcconnectionstring CONNECTION_STRING # The JDBC connection string override
291
- #
292
- #Examples:
293
- #
294
- # Export from a postgres database
295
- # $ mortar local:sqoop_table postgres mydb mytable s3://com.dbhost01/archive -u steve -p stevespassword
296
- def sqoop_table
297
- dbtype = shift_argument
298
- unless dbtype
299
- error("Usage: mortar local:sqoop_table dbtype database-name table s3-destination\nMust specify database type.")
300
- end
301
- physdb = shift_argument
302
- unless physdb
303
- error("Usage: mortar local:sqoop_table dbtype database-name table s3-destination\nMust specify database name.")
304
- end
305
- dbtable = shift_argument
306
- unless dbtable
307
- error("Usage: mortar local:sqoop_table dbtype database-name table s3-destination\nMust specify database table.")
308
- end
309
- s3dest = shift_argument
310
- unless s3dest
311
- error("Usage: mortar local:sqoop_table dbtype database-name table s3-destination\nMust specify s3 destination.")
312
- end
313
- validate_arguments!
314
-
315
- dbhost = options[:host] || "localhost"
316
- connstr = Shellwords.escape(options[:jdbcconnectionstring] || jdbc_conn(dbtype, dbhost, physdb))
317
-
318
- ctrl = Mortar::Local::Controller.new
319
- ctrl.sqoop_export_table(pig_version, connstr, dbtable, s3dest, options)
320
- end
321
-
322
- # local:sqoop_query dbtype database-name query s3-destination
323
- #
324
- # Export the result of an SQL query to S3.
325
- #
326
- # -h, --host HOSTNAME # Database host, localhost assumed if not specified
327
- # -u, --username USERNAME # User to log into the database with
328
- # -p, --password PASSWORD # Password to log into the database
329
- # -j, --jdbcdriver COM.DRIVER.BAR # Name of the JDBC driver class
330
- # -d, --direct # Use a direct import path
331
- # -r, --driverjar JARFILE # Path to the jar containing the jdbc driver
332
- # -c, --jdbcconnectionstring CONNECTION_STRING # The JDBC connection string override
333
- #
334
- #Examples:
335
- #
336
- # Export from a postgres database
337
- # $ mortar local:sqoop_query postgres mydb "select user_name, id from users" s3://com.dbhost01/archive
338
- def sqoop_query
339
- dbtype = shift_argument
340
- unless dbtype
341
- error("Usage: mortar local:sqoop_query dbtype database-name query s3-destination\nMust specify database type.")
342
- end
343
- physdb = shift_argument
344
- unless physdb
345
- error("Usage: mortar local:sqoop_query dbtype database-name query s3-destination\nMust specify database name.")
346
- end
347
- query = shift_argument
348
- unless query
349
- error("Usage: mortar local:sqoop_query dbtype database-name query s3-destination\nMust specify sql query.")
350
- end
351
- s3dest = shift_argument
352
- unless s3dest
353
- error("Usage: mortar local:sqoop_query dbtype database-name query s3-destination\nMust specify s3 destination.")
354
- end
355
- validate_arguments!
356
-
357
- dbhost = options[:host] || "localhost"
358
- connstr = Shellwords.escape(options[:jdbcconnectionstring] || jdbc_conn(dbtype, dbhost, physdb))
359
-
360
- ctrl = Mortar::Local::Controller.new
361
- ctrl.sqoop_export_query(pig_version, connstr, query, s3dest, options)
362
- end
363
-
364
- # local:sqoop_incremental dbtype database-name table column value s3-destination
365
- #
366
- # Export all records where column is > value
367
- #
368
- # -h, --host HOSTNAME # Database host, localhost assumed if not specified
369
- # -u, --username USERNAME # User to log into the database with
370
- # -p, --password PASSWORD # Password to log into the database
371
- # -j, --jdbcdriver COM.DRIVER.BAR # Name of the JDBC driver class
372
- # -d, --direct # Use a direct import path
373
- # -r, --driverjar JARFILE # Path to the jar containing the jdbc driver
374
- # -c, --jdbcconnectionstring CONNECTION_STRING # The JDBC connection string override
375
- #
376
- #Examples:
377
- #
378
- # Export from the newest users
379
- # $ mortar local:sqoop_incremental postgres mydb users user_id 12345 s3://com.dbhost01/archive
380
- def sqoop_incremental
381
- dbtype = shift_argument
382
- unless dbtype
383
- error("Usage: mortar local:sqoop_incremental dbtype database-name table column value s3-destination\nMust specify database type.")
384
- end
385
- physdb = shift_argument
386
- unless physdb
387
- error("Usage: mortar local:sqoop_incremental dbtype database-name table column value s3-destination\nMust specify database name.")
388
- end
389
- table = shift_argument
390
- unless table
391
- error("Usage: mortar local:sqoop_incremental dbtype database-name table column value s3-destination\nMust specify database table.")
392
- end
393
- column = shift_argument
394
- unless column
395
- error("Usage: mortar local:sqoop_incremental dbtype database-name table column value s3-destination\nMust specify column.")
396
- end
397
- max_value = shift_argument
398
- unless max_value
399
- error("Usage: mortar local:sqoop_incremental dbtype database-name table column value s3-destination\nMust specify value.")
400
- end
401
- s3dest = shift_argument
402
- unless s3dest
403
- error("Usage: mortar local:sqoop_incremental dbtype database-name table column value s3-destination\nMust specify s3 destination.")
404
- end
405
- validate_arguments!
406
-
407
- dbhost = options[:host] || "localhost"
408
- connstr = Shellwords.escape(options[:jdbcconnectionstring] || jdbc_conn(dbtype, dbhost, physdb))
409
-
410
- ctrl = Mortar::Local::Controller.new
411
- ctrl.sqoop_export_incremental(pig_version, connstr, table, column, max_value, s3dest, options)
412
- end
413
-
414
-
415
280
  end
@@ -17,56 +17,44 @@
17
17
  require "mortar/command/base"
18
18
  require "time"
19
19
 
20
- # run spark jobs
20
+ # run spark jobs using Spark Job Server
21
21
  #
22
22
  class Mortar::Command::Spark < Mortar::Command::Base
23
23
 
24
24
  include Mortar::Git
25
25
 
26
- # spark SCRIPT
26
+ # spark CLASS_NAME
27
27
  #
28
- # Run a spark job.
28
+ # Run a spark job on a spark jobserver.
29
29
  #
30
- # -c, --clusterid CLUSTERID # Run job on an existing cluster with ID of CLUSTERID (optional)
31
- # -s, --clustersize NUMNODES # Run job on a new cluster, with NUMNODES nodes (optional; must be >= 2 if provided)
32
- # -1, --singlejobcluster # Stop the cluster after job completes. (Default: false--cluster can be used for other jobs, and will shut down after 1 hour of inactivity)
33
- # -2, --permanentcluster # Don't automatically stop the cluster after it has been idle for an hour (Default: false--cluster will be shut down after 1 hour of inactivity)
34
- # -3, --spot # Use spot instances for this cluster (Default: false, only applicable to new clusters)
30
+ # -c, --clusterid CLUSTERID # Run job on an existing cluster with ID of CLUSTERID (Default: runs on an existing available cluster)
31
+ # -s, --clustersize NUMNODES # Run job with NUMNODES nodes (optional; must be >= 2 if provided)
32
+ # -3, --spot # Use spot instances for this cluster (Default: true)
35
33
  # -P, --project PROJECTNAME # Use a project that is not checked out in the current directory. Runs code from project's master branch in GitHub rather than snapshotting local code.
36
34
  # -B, --branch BRANCHNAME # Used with --project to specify a non-master branch
37
35
  #
38
36
  # Examples:
39
37
  #
40
- # Run the classify_text sparkscript:
41
- # $ mortar spark sparkscripts/classify_text.py
38
+ # Run a spark job:
39
+ # $ mortar spark com.datadog.some.Job
42
40
  #
43
- # Run the classify_text sparkscript with 3 script arguments (input location, output location, tuning parameter):
44
- # $ mortar spark sparkscripts/classify_text.py s3://your-bucket/input s3://your-bucket/output 100
41
+ # Run a spark job with some arguments:
42
+ # $ mortar spark com.datadog.some.Job --env prod s3://your-bucket/input s3://your-bucket/output 100
45
43
  #
46
44
  def index
47
- script_name = shift_argument
48
- unless script_name
49
- error("Usage: mortar spark SCRIPT\nMust specify SCRIPT.")
45
+ class_name = shift_argument
46
+ unless class_name
47
+ error("Usage: mortar spark CLASS_NAME\nMust specify CLASS_NAME.")
50
48
  end
51
-
49
+
52
50
  if options[:project]
53
51
  project_name = options[:project]
54
52
  else
55
53
  project_name = project.name
56
- script = validate_sparkscript!(script_name)
57
- script_name = script.name
58
54
  end
59
55
 
60
56
  script_arguments = spark_script_arguments()
61
57
 
62
- if options[:clusterid]
63
- [:clustersize, :singlejobcluster, :permanentcluster].each do |opt|
64
- unless options[opt].nil?
65
- error("Option #{opt.to_s} cannot be set when running a job on an existing cluster (with --clusterid option)")
66
- end
67
- end
68
- end
69
-
70
58
  if options[:project]
71
59
  if options[:branch]
72
60
  git_ref = options[:branch]
@@ -78,46 +66,27 @@ class Mortar::Command::Spark < Mortar::Command::Base
78
66
  end
79
67
 
80
68
  unless options[:clusterid] || options[:clustersize]
81
- clusters = api.get_clusters(Mortar::API::Jobs::CLUSTER_BACKEND__EMR_HADOOP_2).body['clusters']
69
+ clusters = api.get_clusters(Mortar::API::Jobs::CLUSTER_BACKEND__EMR_SPARK_JOBSERVER).body['clusters']
82
70
 
83
71
  largest_free_cluster = clusters.select{ |c| \
84
72
  c['running_jobs'].length == 0 && c['status_code'] == Mortar::API::Clusters::STATUS_RUNNING }.
85
73
  max_by{|c| c['size']}
86
-
74
+
87
75
  if largest_free_cluster.nil?
88
- options[:clustersize] = 2
89
- display("Defaulting to running job on new cluster of size 2")
90
- else
91
- options[:clusterid] = largest_free_cluster['cluster_id']
92
- display("Defaulting to running job on largest existing free cluster, id = " +
93
- largest_free_cluster['cluster_id'] + ", size = " + largest_free_cluster['size'].to_s)
76
+ error('No running clusters with Spark Job Server detected, please, launch a SparkJobServer cluster first')
94
77
  end
78
+
79
+ options[:clusterid] = largest_free_cluster['cluster_id']
80
+ display("Defaulting to running job on largest existing free cluster, id = " +
81
+ largest_free_cluster['cluster_id'] + ", size = " + largest_free_cluster['size'].to_s)
95
82
  end
96
83
 
97
84
  response = action("Requesting job execution") do
98
- if options[:clustersize]
99
- if options[:singlejobcluster] && options[:permanentcluster]
100
- error("Cannot declare cluster as both --singlejobcluster and --permanentcluster")
101
- end
102
- cluster_size = options[:clustersize].to_i
103
- cluster_type = Mortar::API::Jobs::CLUSTER_TYPE__PERSISTENT
104
- if options[:singlejobcluster]
105
- cluster_type = Mortar::API::Jobs::CLUSTER_TYPE__SINGLE_JOB
106
- elsif options[:permanentcluster]
107
- cluster_type = Mortar::API::Jobs::CLUSTER_TYPE__PERMANENT
108
- end
109
- use_spot_instances = options[:spot] || false
110
- api.post_spark_job_new_cluster(project_name, script_name, git_ref, cluster_size,
111
- :project_script_path => script.rel_path,
112
- :script_arguments => script_arguments,
113
- :cluster_type => cluster_type,
114
- :use_spot_instances => use_spot_instances).body
115
- else
116
- cluster_id = options[:clusterid]
117
- api.post_spark_job_existing_cluster(project_name, script_name, git_ref, cluster_id,
118
- :project_script_path => script.rel_path,
119
- :script_arguments => script_arguments).body
120
- end
85
+ cluster_id = options[:clusterid]
86
+ api.post_spark_job_on_jobserver(project_name, class_name, git_ref, cluster_id,
87
+ :script_arguments => script_arguments,
88
+ :clustersize => options[:clustersize]
89
+ ).body
121
90
  end
122
91
 
123
92
  display("job_id: #{response['job_id']}")
@@ -19,7 +19,6 @@ require "mortar/local/pig"
19
19
  require "mortar/local/java"
20
20
  require "mortar/local/python"
21
21
  require "mortar/local/jython"
22
- require "mortar/local/sqoop"
23
22
 
24
23
 
25
24
  class Mortar::Local::Controller
@@ -118,14 +117,14 @@ EOF
118
117
  end
119
118
  # Main entry point to perform installation and configuration necessary
120
119
  # to run pig on the users local machine
121
- def install_and_configure(pig_version=nil, command=nil, install_sqoop=false)
120
+ def install_and_configure(pig_version=nil, command=nil)
122
121
  #To support old watchtower plugins we'll accept nil pig_version
123
122
  base = Mortar::Command::Base.new
124
123
  set_project_name(base)
125
124
  require_aws_keys()
126
125
 
127
126
  if pig_version.nil?
128
- pig_version = Mortar::PigVersion::Pig09.new
127
+ pig_version = Mortar::PigVersion::Pig012.new
129
128
  end
130
129
 
131
130
  java = Mortar::Local::Java.new()
@@ -154,11 +153,6 @@ EOF
154
153
  jy = Mortar::Local::Jython.new()
155
154
  jy.install_or_update()
156
155
 
157
- if install_sqoop
158
- sqoop = Mortar::Local::Sqoop.new()
159
- sqoop.install_or_update()
160
- end
161
-
162
156
  write_local_readme
163
157
 
164
158
  ensure_local_install_dirs_in_gitignore
@@ -245,27 +239,4 @@ README
245
239
  py.run_luigi_script(luigi_script, luigi_script_parameters)
246
240
  end
247
241
 
248
- def sqoop_export_table(pig_version, connstr, dbtable, s3dest, options)
249
- install_and_configure(pig_version, 'sqoop', true)
250
- sqoop = Mortar::Local::Sqoop.new()
251
- options[:dbtable] = dbtable
252
- sqoop.export(connstr, s3dest, options)
253
- end
254
-
255
- def sqoop_export_query(pig_version, connstr, query, s3dest, options)
256
- install_and_configure(pig_version, 'sqoop', true)
257
- sqoop = Mortar::Local::Sqoop.new()
258
- options[:sqlquery] = sqoop.prep_query(query)
259
- sqoop.export(connstr, s3dest, options)
260
- end
261
-
262
- def sqoop_export_incremental(pig_version, connstr, dbtable, column, max_value, s3dest, options)
263
- install_and_configure(pig_version, 'sqoop', true)
264
- sqoop = Mortar::Local::Sqoop.new()
265
- options[:dbtable] = dbtable
266
- options[:inc_column] = column
267
- options[:inc_value] = max_value
268
- sqoop.export(connstr, s3dest, options)
269
- end
270
-
271
242
  end