workflow_manager 0.5.4 → 0.5.9

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
  SHA256:
3
- metadata.gz: 5d30a3a06c3c0eb512d58215a2e8c3da59a3995c61701417bfa446dd40689149
4
- data.tar.gz: 0a1ac6b93e877da5ced89faeb37e11cad399d91653aa7d7bbca32c570601d14f
3
+ metadata.gz: e3a20779e1619045849c524cf4fe603bdbced0afe86fe4272d9f83b240acd809
4
+ data.tar.gz: 79fa7a76bfb0609b62643b6db8c877c65af793e12829382127143099a9f1157b
5
5
  SHA512:
6
- metadata.gz: 423b03ccc17b5e78c4f7a323967e23d8f608ab199ef757cf595a0bb7d4c58f82e2a2b19435dfae8ee09e68b24d314ed9931738f1c09abf5f1ddfb956befc6fa6
7
- data.tar.gz: de329289a5bff13cea1f45943467c917bfb5f058167c2386973b45d76a40117d0adbb3d837501560f14dcdf7a800c9a2a453db2a20e1320fefd8a06a49b4204b
6
+ metadata.gz: 8fd3996b803fe0fc1bf83f9f96c1cea5ec3bb6e4843a98d11e305f96a44955abb8fe6709a95592c1c29bc4cb38f303a8863db6700fc6bbd20338f0978fc6f50d
7
+ data.tar.gz: fe354ac590c778eac3daaf4647e71c5ffa4c541386c4cf3a3d9487d2611f71bfa72c273ebfdadbed4c8e27be8ab79e879abc7fe07b9312dda9a2076de4f27ab4
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
  # 20121112 masa workflow manager client
4
- Version = '20130517-111334'
4
+ Version = '20200522-134606'
5
5
 
6
6
  require 'drb/drb'
7
7
 
@@ -28,3 +28,4 @@ if wfmrc
28
28
  end
29
29
  workflow_manager = DRbObject.new_with_uri(uri)
30
30
  puts workflow_manager.hello
31
+ puts workflow_manager.cluster_node_list
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
  # 20121112 masa workflow manager client
4
- Version = '20160317-153614'
4
+ Version = '20200722-161135'
5
5
 
6
6
  require 'drb/drb'
7
7
  require 'workflow_manager/optparse_ex'
@@ -16,6 +16,7 @@ opt = OptionParser.new do |o|
16
16
  o.on(:nodes, '-n nodes', '--nodes', 'Comma separated list of nodes to submit to for g-sub')
17
17
  o.on(:ram, '-r RAM', '--RAM', 'Amount of RAM to request in Gigs for g-sub')
18
18
  o.on(:scratch, '-s scratch', '--scratch', 'Amount of scratch space to request in Gigs for g-sub')
19
+ o.on(:queue, '-q queue', '--queue', 'Queue name')
19
20
  o.parse!(ARGV)
20
21
  end
21
22
  unless script_file = ARGV[0] and script_file =~ /\.sh/
@@ -308,6 +308,7 @@ module WorkflowManager
308
308
  end
309
309
  end
310
310
 
311
+
311
312
  class HydraCluster < Cluster
312
313
  def submit_job(script_file, script_content, option='')
313
314
  # TODO
@@ -349,4 +350,294 @@ module WorkflowManager
349
350
  }
350
351
  end
351
352
  end
353
+
354
+ class FGCZDevian10Cluster < Cluster
355
+ def submit_job(script_file, script_content, option='')
356
+ if script_name = File.basename(script_file) and script_name =~ /\.sh/
357
+ script_name = script_name.split(/\.sh/).first + ".sh"
358
+ new_job_script = generate_new_job_script(script_name, script_content)
359
+ new_job_script_base = File.basename(new_job_script)
360
+ log_file = File.join(@log_dir, new_job_script_base + "_o.log")
361
+ err_file = File.join(@log_dir, new_job_script_base + "_e.log")
362
+ command = "g-sub -o #{log_file} -e #{err_file} -q course #{option} #{new_job_script}"
363
+ #command = "sbatch -o #{log_file} -e #{err_file} #{new_job_script}"
364
+ job_id = `#{command}`
365
+ #job_id = job_id.match(/Your job (\d+) \(/)[1]
366
+ job_id = job_id.chomp.split.last
367
+ [job_id, log_file, command]
368
+ else
369
+ err_msg = "FGCZDevian10Cluster#submit_job, ERROR: script_name is not *.sh: #{File.basename(script_file)}"
370
+ warn err_msg
371
+ raise err_msg
372
+ end
373
+ end
374
+ def job_running?(job_id)
375
+ qstat_flag = false
376
+ IO.popen('squeue') do |io|
377
+ while line=io.gets
378
+ # ["JOBID", "PARTITION", "NAME", "USER", "ST", "TIME", "NODES", "NODELIST(REASON)"]
379
+ # ["206", "employee", "test.sh", "masaomi", "R", "0:03", "1", "fgcz-h-030"]
380
+ jobid, partition, name, user, state, *others = line.chomp.split
381
+ if jobid.strip == job_id and state == 'R'
382
+ qstat_flag = true
383
+ break
384
+ end
385
+ end
386
+ end
387
+ qstat_flag
388
+ end
389
+ def job_ends?(log_file)
390
+ log_flag = false
391
+ IO.popen("tail -n 10 #{log_file} 2> /dev/null") do |io|
392
+ while line=io.gets
393
+ if line =~ /__SCRIPT END__/
394
+ log_flag = true
395
+ break
396
+ end
397
+ end
398
+ end
399
+ log_flag
400
+ end
401
+ def job_pending?(job_id)
402
+ qstat_flag = false
403
+ IO.popen('squeue') do |io|
404
+ while line=io.gets
405
+ jobid, partition, name, user, state, *others = line.chomp.split
406
+ if jobid.strip == job_id and state =~ /PD/
407
+ qstat_flag = true
408
+ break
409
+ end
410
+ end
411
+ end
412
+ qstat_flag
413
+ end
414
+ def copy_commands(org_dir, dest_parent_dir, now=nil)
415
+ commands = if now == "force"
416
+ target_file = File.join(dest_parent_dir, File.basename(org_dir))
417
+ ["g-req copynow -f #{org_dir} #{dest_parent_dir}"]
418
+ elsif now
419
+ ["g-req copynow #{org_dir} #{dest_parent_dir}"]
420
+ else
421
+ ["g-req -w copy #{org_dir} #{dest_parent_dir}"]
422
+ end
423
+ end
424
+ def kill_command(job_id)
425
+ command = "scancel #{job_id}"
426
+ end
427
+ def delete_command(target)
428
+ command = "g-req remove #{target}"
429
+ end
430
+ def cluster_nodes
431
+ nodes = {
432
+ 'fgcz-h-900: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-900',
433
+ 'fgcz-h-901: cpu 8,mem 30 GB,scr 400G' => 'fgcz-h-901',
434
+ }
435
+ end
436
+ end
437
+
438
+ class FGCZDebian10CourseCluster < Cluster
439
+ def submit_job(script_file, script_content, option='')
440
+ if script_name = File.basename(script_file) and script_name =~ /\.sh/
441
+ script_name = script_name.split(/\.sh/).first + ".sh"
442
+ new_job_script = generate_new_job_script(script_name, script_content)
443
+ new_job_script_base = File.basename(new_job_script)
444
+ log_file = File.join(@log_dir, new_job_script_base + "_o.log")
445
+ err_file = File.join(@log_dir, new_job_script_base + "_e.log")
446
+ command = "g-sub -o #{log_file} -e #{err_file} -q course #{option} #{new_job_script}"
447
+ job_id = `#{command}`
448
+ job_id = job_id.chomp.split.last
449
+ [job_id, log_file, command]
450
+ else
451
+ err_msg = "FGCZDebian10CourseCluster#submit_job, ERROR: script_name is not *.sh: #{File.basename(script_file)}"
452
+ warn err_msg
453
+ raise err_msg
454
+ end
455
+ end
456
+ def job_running?(job_id)
457
+ qstat_flag = false
458
+ IO.popen('squeue') do |io|
459
+ while line=io.gets
460
+ # ["JOBID", "PARTITION", "NAME", "USER", "ST", "TIME", "NODES", "NODELIST(REASON)"]
461
+ # ["206", "employee", "test.sh", "masaomi", "R", "0:03", "1", "fgcz-h-030"]
462
+ jobid, partition, name, user, state, *others = line.chomp.split
463
+ if jobid.strip == job_id and state == 'R'
464
+ qstat_flag = true
465
+ break
466
+ end
467
+ end
468
+ end
469
+ qstat_flag
470
+ end
471
+ def job_ends?(log_file)
472
+ log_flag = false
473
+ IO.popen("tail -n 10 #{log_file} 2> /dev/null") do |io|
474
+ while line=io.gets
475
+ if line =~ /__SCRIPT END__/
476
+ log_flag = true
477
+ break
478
+ end
479
+ end
480
+ end
481
+ log_flag
482
+ end
483
+ def job_pending?(job_id)
484
+ qstat_flag = false
485
+ IO.popen('squeue') do |io|
486
+ while line=io.gets
487
+ jobid, partition, name, user, state, *others = line.chomp.split
488
+ if jobid.strip == job_id and state =~ /PD/
489
+ qstat_flag = true
490
+ break
491
+ end
492
+ end
493
+ end
494
+ qstat_flag
495
+ end
496
+ def copy_commands(org_dir, dest_parent_dir, now=nil)
497
+ commands = ["cp -r #{org_dir} #{dest_parent_dir}"]
498
+ end
499
+ def kill_command(job_id)
500
+ command = "scancel #{job_id}"
501
+ end
502
+ def delete_command(target)
503
+ command = "rm -rf #{target}"
504
+ end
505
+ def cluster_nodes
506
+ nodes = {
507
+ 'fgcz-h-900: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-900',
508
+ 'fgcz-h-901: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-901',
509
+ 'fgcz-h-902: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-902',
510
+ 'fgcz-h-903: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-903',
511
+ 'fgcz-h-904: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-904',
512
+ 'fgcz-h-905: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-905',
513
+ 'fgcz-h-906: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-906',
514
+ 'fgcz-h-907: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-907',
515
+ 'fgcz-h-908: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-908',
516
+ 'fgcz-h-909: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-909',
517
+ 'fgcz-h-910: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-910',
518
+ 'fgcz-h-911: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-911',
519
+ 'fgcz-h-912: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-912',
520
+ 'fgcz-h-913: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-913',
521
+ 'fgcz-h-914: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-914',
522
+ 'fgcz-h-915: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-915',
523
+ 'fgcz-h-916: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-916',
524
+ 'fgcz-h-917: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-917',
525
+ }
526
+ end
527
+ end
528
+
529
+ class FGCZDebian10Cluster < Cluster
530
+ def parse(options)
531
+ options = options.split
532
+ ram = if i = options.index("-r")
533
+ options[i+1]
534
+ end
535
+ cores = if i = options.index("-c")
536
+ options[i+1]
537
+ end
538
+ scratch = if i = options.index("-s")
539
+ options[i+1]
540
+ end
541
+ queue = if i = options.index("-q")
542
+ options[i+1]
543
+ end
544
+ new_options = []
545
+ new_options << "--mem=#{ram}G" if ram
546
+ new_options << "-n #{cores}" if cores
547
+ new_options << "--tmp=#{scratch}G" if scratch
548
+ new_options << "-p #{queue}" if queue
549
+ new_options.join(" ")
550
+ end
551
+ def submit_job(script_file, script_content, option='')
552
+ if script_name = File.basename(script_file) and script_name =~ /\.sh/
553
+ script_name = script_name.split(/\.sh/).first + ".sh"
554
+ new_job_script = generate_new_job_script(script_name, script_content)
555
+ new_job_script_base = File.basename(new_job_script)
556
+ log_file = File.join(@log_dir, new_job_script_base + "_o.log")
557
+ err_file = File.join(@log_dir, new_job_script_base + "_e.log")
558
+ #command = "g-sub -o #{log_file} -e #{err_file} -q user #{option} #{new_job_script}"
559
+ sbatch_options = parse(option)
560
+ command = "sbatch -o #{log_file} -e #{err_file} -N 1 #{sbatch_options} #{new_job_script}"
561
+ puts command
562
+ job_id = `#{command}`
563
+ job_id = job_id.chomp.split.last
564
+ [job_id, log_file, command]
565
+ else
566
+ err_msg = "FGCZDebian10Cluster#submit_job, ERROR: script_name is not *.sh: #{File.basename(script_file)}"
567
+ warn err_msg
568
+ raise err_msg
569
+ end
570
+ end
571
+ def job_running?(job_id)
572
+ qstat_flag = false
573
+ IO.popen('squeue') do |io|
574
+ while line=io.gets
575
+ # ["JOBID", "PARTITION", "NAME", "USER", "ST", "TIME", "NODES", "NODELIST(REASON)"]
576
+ # ["206", "employee", "test.sh", "masaomi", "R", "0:03", "1", "fgcz-h-030"]
577
+ jobid, partition, name, user, state, *others = line.chomp.split
578
+ if jobid.strip == job_id and state == 'R'
579
+ qstat_flag = true
580
+ break
581
+ end
582
+ end
583
+ end
584
+ qstat_flag
585
+ end
586
+ def job_ends?(log_file)
587
+ log_flag = false
588
+ IO.popen("tail -n 10 #{log_file} 2> /dev/null") do |io|
589
+ while line=io.gets
590
+ if line =~ /__SCRIPT END__/
591
+ log_flag = true
592
+ break
593
+ end
594
+ end
595
+ end
596
+ log_flag
597
+ end
598
+ def job_pending?(job_id)
599
+ qstat_flag = false
600
+ IO.popen('squeue') do |io|
601
+ while line=io.gets
602
+ jobid, partition, name, user, state, *others = line.chomp.split
603
+ if jobid.strip == job_id and state =~ /PD/
604
+ qstat_flag = true
605
+ break
606
+ end
607
+ end
608
+ end
609
+ qstat_flag
610
+ end
611
+ def copy_commands(org_dir, dest_parent_dir, now=nil)
612
+ commands = if now == "force"
613
+ target_file = File.join(dest_parent_dir, File.basename(org_dir))
614
+ ["g-req copynow -f #{org_dir} #{dest_parent_dir}"]
615
+ elsif now
616
+ ["g-req copynow #{org_dir} #{dest_parent_dir}"]
617
+ else
618
+ ["g-req -w copy #{org_dir} #{dest_parent_dir}"]
619
+ end
620
+ end
621
+ def kill_command(job_id)
622
+ command = "scancel #{job_id}"
623
+ end
624
+ def delete_command(target)
625
+ command = "g-req remove #{target}"
626
+ end
627
+ def cluster_nodes
628
+ nodes = {
629
+ 'fgcz-h-110: cpu 8,mem 30 GB,scr 500G' => 'fgcz-h-110',
630
+ 'fgcz-h-111: cpu 8,mem 30 GB,scr 400G' => 'fgcz-h-111',
631
+ }
632
+ end
633
+ end
634
+
635
+ class FGCZDebian10DemoCluster < FGCZDebian10Cluster
636
+ def copy_commands(org_dir, dest_parent_dir, now=nil)
637
+ commands = ["cp -r #{org_dir} #{dest_parent_dir}"]
638
+ end
639
+ def delete_command(target)
640
+ command = "rm -rf #{target}"
641
+ end
642
+ end
352
643
  end
@@ -1,3 +1,3 @@
1
1
  module WorkflowManager
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.9"
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.4
4
+ version: 0.5.9
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-05-22 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler