sushi_fabric 0.2.2 → 0.2.3
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.
- data/lib/sushi_fabric/sushiApp.rb +76 -63
- data/lib/sushi_fabric/version.rb +1 -1
- metadata +2 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
|
-
# Version = '
|
3
|
+
# Version = '20140613-165327'
|
4
4
|
|
5
5
|
require 'csv'
|
6
6
|
require 'fileutils'
|
@@ -412,9 +412,20 @@ rm -rf #{@scratch_dir} || exit 1
|
|
412
412
|
def copy_commands(org_dir, dest_parent_dir)
|
413
413
|
@workflow_manager.copy_commands(org_dir, dest_parent_dir)
|
414
414
|
end
|
415
|
-
def
|
415
|
+
def copy_inputdataset_parameter_jobscripts
|
416
416
|
org = @scratch_result_dir
|
417
417
|
dest = @gstore_project_dir
|
418
|
+
copy_commands(org, dest).each do |command|
|
419
|
+
puts command
|
420
|
+
unless system command
|
421
|
+
raise "fails in copying input_dataset, parameters and jobscript files from /scratch to /gstore"
|
422
|
+
end
|
423
|
+
end
|
424
|
+
sleep 1
|
425
|
+
end
|
426
|
+
def copy_nextdataset
|
427
|
+
org = @next_dataset_tsv_path
|
428
|
+
dest = @gstore_project_dir
|
418
429
|
copy_commands(org, dest).each do |command|
|
419
430
|
puts command
|
420
431
|
unless system command
|
@@ -425,6 +436,7 @@ rm -rf #{@scratch_dir} || exit 1
|
|
425
436
|
command = "rm -rf #{@scratch_result_dir}"
|
426
437
|
`#{command}`
|
427
438
|
end
|
439
|
+
|
428
440
|
def make_job_script
|
429
441
|
@out = open(@job_script, 'w')
|
430
442
|
job_header
|
@@ -500,74 +512,75 @@ rm -rf #{@scratch_dir} || exit 1
|
|
500
512
|
save_parameters_as_tsv
|
501
513
|
save_input_dataset_as_tsv
|
502
514
|
|
515
|
+
t = Thread.new do
|
516
|
+
copy_inputdataset_parameter_jobscripts
|
517
|
+
|
518
|
+
## sushi writes creates the job scripts and builds the result data set that is to be generated
|
519
|
+
@result_dataset = []
|
520
|
+
@job_scripts = []
|
521
|
+
if @params['process_mode'] == 'SAMPLE'
|
522
|
+
sample_mode
|
523
|
+
elsif @params['process_mode'] == 'DATASET'
|
524
|
+
dataset_mode
|
525
|
+
else
|
526
|
+
#stop
|
527
|
+
warn "the process mode (#{@params['process_mode']}) is not defined"
|
528
|
+
raise "stop job submitting"
|
529
|
+
end
|
503
530
|
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
elsif @params['process_mode'] == 'DATASET'
|
510
|
-
dataset_mode
|
511
|
-
else
|
512
|
-
#stop
|
513
|
-
warn "the process mode (#{@params['process_mode']}) is not defined"
|
514
|
-
raise "stop job submitting"
|
515
|
-
end
|
516
|
-
|
517
|
-
# job submittion
|
518
|
-
@job_scripts.each_with_index do |job_script, i|
|
519
|
-
job_id = submit(job_script)
|
520
|
-
@job_ids << job_id
|
521
|
-
print "Submit job #{File.basename(job_script)} job_id=#{job_id}"
|
522
|
-
end
|
523
|
-
|
524
|
-
puts
|
525
|
-
print 'job scripts: '
|
526
|
-
p @job_scripts
|
527
|
-
print 'result dataset: '
|
528
|
-
p @result_dataset
|
529
|
-
|
530
|
-
# copy application data to gstore
|
531
|
-
next_dataset_tsv_path = save_next_dataset_as_tsv
|
532
|
-
|
533
|
-
if !@job_ids.empty? and @dataset_sushi_id and dataset = DataSet.find_by_id(@dataset_sushi_id.to_i)
|
534
|
-
data_set_arr = []
|
535
|
-
headers = []
|
536
|
-
rows = []
|
537
|
-
next_dataset_name = if name = @next_dataset_name
|
538
|
-
name.to_s
|
539
|
-
else
|
540
|
-
"#{@analysis_category}_#{@name.gsub(/\s/,'').gsub(/_/,'')}_#{dataset.id}"
|
541
|
-
end
|
542
|
-
data_set_arr = {'DataSetName'=>next_dataset_name, 'ProjectNumber'=>@project.gsub(/p/,''), 'ParentID'=>@dataset_sushi_id, 'Comment'=>@next_dataset_comment.to_s}
|
543
|
-
csv = CSV.readlines(next_dataset_tsv_path, :col_sep=>"\t")
|
544
|
-
csv.each do |row|
|
545
|
-
if headers.empty?
|
546
|
-
headers = row
|
547
|
-
else
|
548
|
-
rows << row
|
549
|
-
end
|
531
|
+
# job submittion
|
532
|
+
@job_scripts.each_with_index do |job_script, i|
|
533
|
+
job_id = submit(job_script)
|
534
|
+
@job_ids << job_id
|
535
|
+
print "Submit job #{File.basename(job_script)} job_id=#{job_id}"
|
550
536
|
end
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
537
|
+
|
538
|
+
puts
|
539
|
+
print 'job scripts: '
|
540
|
+
p @job_scripts
|
541
|
+
print 'result dataset: '
|
542
|
+
p @result_dataset
|
543
|
+
|
544
|
+
# copy application data to gstore
|
545
|
+
@next_dataset_tsv_path = save_next_dataset_as_tsv
|
546
|
+
|
547
|
+
if !@job_ids.empty? and @dataset_sushi_id and dataset = DataSet.find_by_id(@dataset_sushi_id.to_i)
|
548
|
+
data_set_arr = []
|
549
|
+
headers = []
|
550
|
+
rows = []
|
551
|
+
next_dataset_name = if name = @next_dataset_name
|
552
|
+
name.to_s
|
553
|
+
else
|
554
|
+
"#{@analysis_category}_#{@name.gsub(/\s/,'').gsub(/_/,'')}_#{dataset.id}"
|
555
|
+
end
|
556
|
+
data_set_arr = {'DataSetName'=>next_dataset_name, 'ProjectNumber'=>@project.gsub(/p/,''), 'ParentID'=>@dataset_sushi_id, 'Comment'=>@next_dataset_comment.to_s}
|
557
|
+
csv = CSV.readlines(@next_dataset_tsv_path, :col_sep=>"\t")
|
558
|
+
csv.each do |row|
|
559
|
+
if headers.empty?
|
560
|
+
headers = row
|
561
|
+
else
|
562
|
+
rows << row
|
563
|
+
end
|
562
564
|
end
|
565
|
+
unless NO_ROR
|
566
|
+
@next_dataset_id = save_data_set(data_set_arr.to_a.flatten, headers, rows)
|
567
|
+
|
568
|
+
# save job and dataset relation in Sushi DB
|
569
|
+
job_ids.each do |job_id|
|
570
|
+
new_job = Job.new
|
571
|
+
new_job.submit_job_id = job_id.to_i
|
572
|
+
new_job.next_dataset_id = @next_dataset_id
|
573
|
+
new_job.save
|
574
|
+
new_job.data_set.jobs << new_job
|
575
|
+
new_job.data_set.save
|
576
|
+
end
|
563
577
|
|
578
|
+
end
|
564
579
|
end
|
565
|
-
|
566
|
-
t = Thread.new do
|
567
|
-
copy_dataset_parameter_jobscripts
|
580
|
+
copy_nextdataset
|
568
581
|
end
|
569
582
|
if Thread.main == Thread.current # in case of running script directly on terminal
|
570
|
-
warn "copy dataset
|
583
|
+
warn "copy next dataset..."
|
571
584
|
t.join
|
572
585
|
warn "copy finish."
|
573
586
|
end
|
data/lib/sushi_fabric/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sushi_fabric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|