neptune 0.0.9 → 0.1.0

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.
Files changed (2) hide show
  1. data/lib/neptune.rb +39 -20
  2. metadata +4 -4
@@ -33,7 +33,7 @@ ALLOWED_STORAGE_TYPES = ["appdb", "gstorage", "s3", "walrus"]
33
33
 
34
34
  # A list of jobs that require some kind of work to be done before
35
35
  # the actual computation can be performed.
36
- NEED_PREPROCESSING = ["compile", "erlang", "mpi"]
36
+ NEED_PREPROCESSING = ["compile", "erlang", "mpi", "ssa"]
37
37
 
38
38
  # A set of methods and constants that we've monkey-patched to enable Neptune
39
39
  # support. In the future, it is likely that the only exposed / monkey-patched
@@ -58,6 +58,7 @@ end
58
58
  # Shadow node so that it can be compiled there. A future version
59
59
  # of this method may also copy over libraries as well.
60
60
  def preprocess_compile(job_data)
61
+ verbose = job_data["@verbose"]
61
62
  code = File.expand_path(job_data["@code"])
62
63
  unless File.exists?(code)
63
64
  abort("The source file #{code} does not exist.")
@@ -70,7 +71,7 @@ def preprocess_compile(job_data)
70
71
 
71
72
  ssh_args = "-i ~/.appscale/#{keyname}.key -o StrictHostkeyChecking=no root@#{shadow_ip}"
72
73
  remove_dir = "ssh #{ssh_args} 'rm -rf #{dest}' 2>&1"
73
- #puts remove_dir
74
+ puts remove_dir if verbose
74
75
  `#{remove_dir}`
75
76
 
76
77
  CommonFunctions.scp_to_shadow(code, dest, keyname, is_dir=true)
@@ -95,6 +96,7 @@ end
95
96
  # code to the master node in AppScale - this node will
96
97
  # then copy it to whoever will run the MPI job.
97
98
  def preprocess_mpi(job_data)
99
+ verbose = job_data["@verbose"]
98
100
  if job_data["@procs_to_use"]
99
101
  p = job_data["@procs_to_use"]
100
102
  n = job_data["@nodes_to_use"]
@@ -123,9 +125,19 @@ def preprocess_mpi(job_data)
123
125
  dest_code = "/tmp/thempicode"
124
126
 
125
127
  keyname = job_data["@keyname"]
126
- puts "Copying over code..."
128
+ puts "Copying over code..." if verbose
127
129
  CommonFunctions.scp_to_shadow(source_code, dest_code, keyname)
128
- puts "Done copying code!"
130
+ puts "Done copying code!" if verbose
131
+ end
132
+
133
+ def preprocess_ssa(job_data)
134
+ if job_data["@simulations"]
135
+ job_data["@trajectories"] = job_data["@simulations"]
136
+ end
137
+
138
+ unless job_data["@trajectories"]
139
+ abort(":trajectories needs to be specified when running ssa jobs")
140
+ end
129
141
  end
130
142
 
131
143
  # TODO: actually use me!
@@ -145,8 +157,10 @@ end
145
157
  # job can be used to set it to public later (and
146
158
  # vice-versa).
147
159
  def neptune(params)
148
- puts "Received a request to run a job."
149
- puts params[:type]
160
+ verbose = params[:verbose]
161
+
162
+ puts "Received a request to run a job." if verbose
163
+ puts params[:type] if verbose
150
164
 
151
165
  keyname = params[:keyname] || "appscale"
152
166
 
@@ -206,7 +220,7 @@ def neptune(params)
206
220
  ["EC2_ACCESS_KEY", "EC2_SECRET_KEY", "S3_URL"].each { |item|
207
221
  unless job_data["@#{item}"]
208
222
  if ENV[item]
209
- puts "Using #{item} from environment"
223
+ puts "Using #{item} from environment" if verbose
210
224
  job_data["@#{item}"] = ENV[item]
211
225
  else
212
226
  msg = "When storing data to S3, #{item} must be specified or be in " +
@@ -226,7 +240,7 @@ def neptune(params)
226
240
  # job_data["@can_run_on"] = [job_data["@can_run_on"]]
227
241
  #end
228
242
 
229
- puts "job data = #{job_data.inspect}"
243
+ puts "job data = #{job_data.inspect}" if verbose
230
244
 
231
245
  do_preprocessing(job_data)
232
246
 
@@ -248,11 +262,11 @@ def neptune(params)
248
262
 
249
263
  remote = "/tmp/neptune-input-#{rand(100000)}"
250
264
  scp_cmd = "scp #{ssh_args} #{local_file} root@#{shadow_ip}:#{remote}"
251
- puts scp_cmd
265
+ puts scp_cmd if verbose
252
266
  `#{scp_cmd}`
253
267
 
254
268
  job_data["@local"] = remote
255
- puts "job data = #{job_data.inspect}"
269
+ puts "job data = #{job_data.inspect}" if verbose
256
270
  result[:input] = controller.put_input(job_data)
257
271
  elsif type == "output"
258
272
  result[:output] = controller.get_output(job_data)
@@ -269,24 +283,24 @@ def neptune(params)
269
283
 
270
284
  loop {
271
285
  ssh_command = "ssh #{ssh_args} root@#{shadow_ip} 'ls #{compiled_location}' 2>&1"
272
- #puts ssh_command
286
+ puts ssh_command if verbose
273
287
  result = `#{ssh_command}`
274
- #puts "result was [#{result}]"
288
+ puts "result was [#{result}]" if verbose
275
289
  if result =~ /No such file or directory/
276
- puts "Still waiting for code to be compiled..."
290
+ puts "Still waiting for code to be compiled..." if verbose
277
291
  else
278
- puts "compilation complete! Copying compiled code to #{copy_to}"
292
+ puts "compilation complete! Copying compiled code to #{copy_to}" if verbose
279
293
  break
280
294
  end
281
295
  sleep(5)
282
296
  }
283
297
 
284
298
  rm_local = "rm -rf #{copy_to}"
285
- #puts rm_local
299
+ puts rm_local if verbose
286
300
  `#{rm_local}`
287
301
 
288
302
  scp_command = "scp -r #{ssh_args} root@#{shadow_ip}:#{compiled_location} #{copy_to} 2>&1"
289
- puts scp_command
303
+ puts scp_command if verbose
290
304
  `#{scp_command}`
291
305
 
292
306
  code = job_data["@code"]
@@ -294,19 +308,24 @@ def neptune(params)
294
308
  remote_dir = "/tmp/" + dirs[-1]
295
309
 
296
310
  ssh_command = "ssh #{ssh_args} root@#{shadow_ip} 'rm -rf #{remote_dir}' 2>&1"
297
- puts ssh_command
311
+ puts ssh_command if verbose
298
312
  `#{ssh_command}`
299
313
 
300
314
  ssh_command = "ssh #{ssh_args} root@#{shadow_ip} 'rm -rf #{compiled_location}' 2>&1"
301
- puts ssh_command
315
+ puts ssh_command if verbose
302
316
  `#{ssh_command}`
303
317
 
304
318
  out = File.open("#{copy_to}/compile_out") { |f| f.read.chomp! }
305
319
  err = File.open("#{copy_to}/compile_err") { |f| f.read.chomp! }
320
+ result = {}
306
321
  result[:out] = out
307
322
  result[:err] = err
308
-
309
- result[:result] = :failure if result[:err].any?
323
+
324
+ if result[:err]
325
+ result[:result] = :failure
326
+ else
327
+ result[:result] = :success
328
+ end
310
329
  else
311
330
  msg = controller.start_neptune_job(job_data)
312
331
  result[:msg] = msg
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neptune
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 9
10
- version: 0.0.9
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Bunch
@@ -15,7 +15,7 @@ autorequire: neptune
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-28 00:00:00 -07:00
18
+ date: 2011-06-04 00:00:00 -07:00
19
19
  default_executable: neptune
20
20
  dependencies: []
21
21