workflow_manager 0.5.0 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b8d2b5478dda4da2f42ca05754e19e446faa4cab
4
- data.tar.gz: f039f6cfbb00dd6c3a8a911b5d417ed24b413809
2
+ SHA256:
3
+ metadata.gz: c6828da4a43654aa14bb9a4592a42bdc3d0084daf98e7ab29cb11d94928b54de
4
+ data.tar.gz: 87122a9b3e395f12535e700d80568328876f8784917da762956d7abbdd4a77c0
5
5
  SHA512:
6
- metadata.gz: a1ab900a8327e7778e715ba909bf583bb2ad621058123523c41a280bbee55d5148591a70641b3aa8d4aa8df7aeccbca477d92673ea2f735a37cedd4696763cbd
7
- data.tar.gz: eb034e572721c32a6e9b1858b8ca69899a1fd7705494430e4f9590844dc4b2f0e79dfd0dcf05478d75cdf4f2a324d50b74dec9d8b9b415669b02df121d316260
6
+ metadata.gz: a27da5bd02d7d6a8130f9bb8844c3b4a640153a37751e0e7bd34fd64d0c13caaf0e0aade85e34ec4699a3307fe8df6624562e9a0cd48858861ec543bd3c1c910
7
+ data.tar.gz: 6f043fe95d6911baffbd0f606f5790d60651a013cea213caf1728632267987f09a20e161ea186f372eaaf66f7823f07e323990268bdc28ec669f37623f02b409
@@ -38,6 +38,8 @@ module WorkflowManager
38
38
  end
39
39
  def default_node
40
40
  end
41
+ def node_list
42
+ end
41
43
  end
42
44
 
43
45
  class LocalComputer < Cluster
@@ -238,6 +240,63 @@ module WorkflowManager
238
240
  'fgcz-h-010: cpu 8,mem 30 GB,scr 400G' => 'fgcz-h-010',
239
241
  }
240
242
  end
243
+ def node_list
244
+ node2scr = {}
245
+ command = "qhost -F scratch"
246
+ keep = nil
247
+ IO.popen(command) do |out|
248
+ while line=out.gets
249
+ hostname, arch, ncpu, loading, memtot, memuse, *others = line.split
250
+ if hostname =~ /fgcz/
251
+ keep = hostname
252
+ elsif scratch_ = line.chomp.split.last and
253
+ scratch = scratch_.split('=').last
254
+ node2scr[keep] = scratch.to_i
255
+ keep = nil
256
+ end
257
+ end
258
+ end
259
+
260
+ list = {}
261
+ keep = nil
262
+ command = 'qhost -q'
263
+ IO.popen(command) do |out|
264
+ while line=out.gets
265
+ # HOSTNAME ARCH NCPU LOAD MEMTOT MEMUSE SWAPTO SWAPUS
266
+ hostname, arch, ncpu, loading, memtot, memuse, *others = line.split
267
+ if hostname =~ /fgcz/
268
+ #puts [hostname, ncpu, loading, memtot, memuse].join("\t")
269
+ mem = memtot.gsub(/G/, '').to_i
270
+ keep = [hostname, ncpu, "#{mem}G"]
271
+ elsif hostname == "GT" and keep and cores = line.chomp.split.last and cores !~ /[du]/
272
+ hostname = keep.shift
273
+ keep[0] = cores
274
+ if scr = node2scr[hostname] and scr >= 1000
275
+ scr = "%.1f" % (scr.to_f / 1000)
276
+ scr << "T"
277
+ else
278
+ scr = scr.to_s + "G"
279
+ end
280
+ keep << scr
281
+ list[hostname] = keep
282
+ keep = nil
283
+ end
284
+ end
285
+ end
286
+
287
+ # reformat
288
+ nodes = {}
289
+ list.each do |hostname, specs|
290
+ # 20190823 masa tentatively off use f47
291
+ unless hostname =~ /fgcz-c-047/
292
+ cores, ram, scr = specs
293
+ key = "#{hostname}: cores #{cores}, ram #{ram}, scr #{scr}"
294
+ value = hostname
295
+ nodes[key] = value
296
+ end
297
+ end
298
+ nodes
299
+ end
241
300
  end
242
301
 
243
302
  class FGCZCourseCluster < FGCZCluster
@@ -290,4 +349,87 @@ module WorkflowManager
290
349
  }
291
350
  end
292
351
  end
352
+
353
+ class FGCZDevian10Cluster < Cluster
354
+ def submit_job(script_file, script_content, option='')
355
+ if script_name = File.basename(script_file) and script_name =~ /\.sh/
356
+ script_name = script_name.split(/\.sh/).first + ".sh"
357
+ new_job_script = generate_new_job_script(script_name, script_content)
358
+ new_job_script_base = File.basename(new_job_script)
359
+ log_file = File.join(@log_dir, new_job_script_base + "_o.log")
360
+ err_file = File.join(@log_dir, new_job_script_base + "_e.log")
361
+ #command = "g-sub -o #{log_file} -e #{err_file} #{option} #{new_job_script}"
362
+ command = "sbatch -o #{log_file} -e #{err_file} #{option} #{new_job_script}"
363
+ job_id = `#{command}`
364
+ job_id = job_id.match(/Your job (\d+) \(/)[1]
365
+ [job_id, log_file, command]
366
+ else
367
+ err_msg = "FGCZDevian10Cluster#submit_job, ERROR: script_name is not *.sh: #{File.basename(script_file)}"
368
+ warn err_msg
369
+ raise err_msg
370
+ end
371
+ end
372
+ def job_running?(job_id)
373
+ qstat_flag = false
374
+ IO.popen('squeue') do |io|
375
+ while line=io.gets
376
+ # ["JOBID", "PARTITION", "NAME", "USER", "ST", "TIME", "NODES", "NODELIST(REASON)"]
377
+ # ["206", "employee", "test.sh", "masaomi", "R", "0:03", "1", "fgcz-h-030"]
378
+ jobid, partition, name, user, state, *others = line.chomp.split
379
+ if jobid.strip == job_id and state == 'R'
380
+ qstat_flag = true
381
+ break
382
+ end
383
+ end
384
+ end
385
+ qstat_flag
386
+ end
387
+ def job_ends?(log_file)
388
+ log_flag = false
389
+ IO.popen("tail -n 10 #{log_file} 2> /dev/null") do |io|
390
+ while line=io.gets
391
+ if line =~ /__SCRIPT END__/
392
+ log_flag = true
393
+ break
394
+ end
395
+ end
396
+ end
397
+ log_flag
398
+ end
399
+ def job_pending?(job_id)
400
+ qstat_flag = false
401
+ IO.popen('squeue') do |io|
402
+ while line=io.gets
403
+ jobid, partition, name, user, state, *others = line.chomp.split
404
+ if jobid.strip == job_id and state =~ /PD/
405
+ qstat_flag = true
406
+ break
407
+ end
408
+ end
409
+ end
410
+ qstat_flag
411
+ end
412
+ def copy_commands(org_dir, dest_parent_dir, now=nil)
413
+ commands = if now == "force"
414
+ target_file = File.join(dest_parent_dir, File.basename(org_dir))
415
+ ["g-req copynow -f #{org_dir} #{dest_parent_dir}"]
416
+ elsif now
417
+ ["g-req copynow #{org_dir} #{dest_parent_dir}"]
418
+ else
419
+ ["g-req -w copy #{org_dir} #{dest_parent_dir}"]
420
+ end
421
+ end
422
+ def kill_command(job_id)
423
+ command = "scancel #{job_id}"
424
+ end
425
+ def delete_command(target)
426
+ command = "g-req remove #{target}"
427
+ end
428
+ def cluster_nodes
429
+ nodes = {
430
+ 'fgcz-h-900: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-900',
431
+ 'fgcz-h-901: cpu 8,mem 30 GB,scr 400G' => 'fgcz-h-901',
432
+ }
433
+ end
434
+ end
293
435
  end
@@ -5,26 +5,26 @@ require 'drb/drb'
5
5
  require 'fileutils'
6
6
  require 'csv'
7
7
  begin
8
- require 'kyotocabinet'
9
- DB_MODE = "KyotoCabinet"
10
- rescue LoadError
11
- begin
12
- require 'redis'
13
- DB_MODE = "Redis"
14
- class Redis
15
- def [](key)
16
- self.get(key)
17
- end
18
- def []=(key, value)
19
- self.set(key, value)
20
- end
21
- def each
22
- self.scan_each do |key|
23
- value = self.get(key)
24
- yield([key, value])
25
- end
8
+ require 'redis'
9
+ DB_MODE = "Redis"
10
+ class Redis
11
+ def [](key)
12
+ self.get(key)
13
+ end
14
+ def []=(key, value)
15
+ self.set(key, value)
16
+ end
17
+ def each
18
+ self.scan_each do |key|
19
+ value = self.get(key)
20
+ yield([key, value])
26
21
  end
27
22
  end
23
+ end
24
+ rescue LoadError
25
+ begin
26
+ require 'kyotocabinet'
27
+ DB_MODE = "KyotoCabinet"
28
28
  rescue LoadError
29
29
  require 'pstore'
30
30
  DB_MODE = "PStore"
@@ -100,6 +100,7 @@ module WorkflowManager
100
100
  end
101
101
  end
102
102
  class RedisDB
103
+ attr_accessor :port
103
104
  def run_redis_server(redis_conf)
104
105
  @pid = fork do
105
106
  exec("redis-server #{redis_conf}")
@@ -108,11 +109,13 @@ module WorkflowManager
108
109
  Process.waitpid @pid
109
110
  end
110
111
  end
111
- def initialize(db_no=0, redis_conf=nil)
112
+ def initialize(db_no=0, redis_conf)
112
113
  if db_no==0
113
114
  run_redis_server(redis_conf)
114
115
  end
115
- @db = Redis.new(db: db_no)
116
+ conf = Hash[*CSV.readlines(redis_conf, col_sep: " ").map{|a| [a.first, a[1,100].join(",")]}.flatten]
117
+ @port = (conf["port"]||6379).to_i
118
+ @db = Redis.new(port: @port, db: db_no)
116
119
  end
117
120
  def transaction
118
121
  #@db.multi do
@@ -154,7 +157,7 @@ module WorkflowManager
154
157
  when "KyotoCabinet"
155
158
  KyotoDB.new(@db_logs)
156
159
  when "Redis"
157
- RedisDB.new(1)
160
+ RedisDB.new(1, @redis_conf)
158
161
  end
159
162
 
160
163
  @system_log = File.join(@log_dir, "system.log")
@@ -163,6 +166,7 @@ module WorkflowManager
163
166
  puts("DB = #{DB_MODE}")
164
167
  if DB_MODE == "Redis"
165
168
  puts("Redis conf = #{config.redis_conf}")
169
+ puts("Redis port = #{@logs.port}")
166
170
  end
167
171
  puts("Cluster = #{@cluster.name}")
168
172
  log_puts("DB = #{DB_MODE}")
@@ -505,6 +509,9 @@ module WorkflowManager
505
509
  end
506
510
  end
507
511
  alias_method :check_status, :success_or_fail
512
+ def cluster_node_list
513
+ @cluster.node_list
514
+ end
508
515
  end
509
516
  end
510
517
 
@@ -1,3 +1,3 @@
1
1
  module WorkflowManager
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workflow_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Functional Genomics Center Zurich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-26 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -104,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.6.14
107
+ rubygems_version: 3.0.3
109
108
  signing_key:
110
109
  specification_version: 4
111
110
  summary: Workflow Manager manages job submissions using dRuby.