sushi_fabric 0.2.7 → 0.2.8
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 +73 -69
- data/lib/sushi_fabric/version.rb +1 -1
- metadata +1 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
|
-
# Version = '20141009-
|
3
|
+
# Version = '20141009-135300'
|
4
4
|
|
5
5
|
require 'csv'
|
6
6
|
require 'fileutils'
|
@@ -518,79 +518,83 @@ rm -rf #{@scratch_dir} || exit 1
|
|
518
518
|
save_parameters_as_tsv
|
519
519
|
save_input_dataset_as_tsv
|
520
520
|
|
521
|
-
t = Thread.new do
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
@job_scripts.each_with_index do |job_script, i|
|
539
|
-
job_id = submit(job_script)
|
540
|
-
@job_ids << job_id
|
541
|
-
print "Submit job #{File.basename(job_script)} job_id=#{job_id}"
|
542
|
-
end
|
521
|
+
# t = Thread.new do
|
522
|
+
pid = Process.fork do
|
523
|
+
Process.fork do
|
524
|
+
|
525
|
+
## sushi writes creates the job scripts and builds the result data set that is to be generated
|
526
|
+
@result_dataset = []
|
527
|
+
@job_scripts = []
|
528
|
+
if @params['process_mode'] == 'SAMPLE'
|
529
|
+
sample_mode
|
530
|
+
elsif @params['process_mode'] == 'DATASET'
|
531
|
+
dataset_mode
|
532
|
+
else
|
533
|
+
#stop
|
534
|
+
warn "the process mode (#{@params['process_mode']}) is not defined"
|
535
|
+
raise "stop job submitting"
|
536
|
+
end
|
537
|
+
copy_inputdataset_parameter_jobscripts
|
543
538
|
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
# copy application data to gstore
|
551
|
-
@next_dataset_tsv_path = save_next_dataset_as_tsv
|
552
|
-
|
553
|
-
if !@job_ids.empty? and @dataset_sushi_id and dataset = DataSet.find_by_id(@dataset_sushi_id.to_i)
|
554
|
-
data_set_arr = []
|
555
|
-
headers = []
|
556
|
-
rows = []
|
557
|
-
next_dataset_name = if name = @next_dataset_name
|
558
|
-
name.to_s
|
559
|
-
else
|
560
|
-
"#{@analysis_category}_#{@name.gsub(/\s/,'').gsub(/_/,'')}_#{dataset.id}"
|
561
|
-
end
|
562
|
-
data_set_arr = {'DataSetName'=>next_dataset_name, 'ProjectNumber'=>@project.gsub(/p/,''), 'ParentID'=>@dataset_sushi_id, 'Comment'=>@next_dataset_comment.to_s}
|
563
|
-
csv = CSV.readlines(@next_dataset_tsv_path, :col_sep=>"\t")
|
564
|
-
csv.each do |row|
|
565
|
-
if headers.empty?
|
566
|
-
headers = row
|
567
|
-
else
|
568
|
-
rows << row
|
569
|
-
end
|
539
|
+
# job submittion
|
540
|
+
@job_scripts.each_with_index do |job_script, i|
|
541
|
+
job_id = submit(job_script)
|
542
|
+
@job_ids << job_id
|
543
|
+
print "Submit job #{File.basename(job_script)} job_id=#{job_id}"
|
570
544
|
end
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
545
|
+
|
546
|
+
puts
|
547
|
+
print 'job scripts: '
|
548
|
+
p @job_scripts
|
549
|
+
print 'result dataset: '
|
550
|
+
p @result_dataset
|
551
|
+
|
552
|
+
# copy application data to gstore
|
553
|
+
@next_dataset_tsv_path = save_next_dataset_as_tsv
|
554
|
+
|
555
|
+
if !@job_ids.empty? and @dataset_sushi_id and dataset = DataSet.find_by_id(@dataset_sushi_id.to_i)
|
556
|
+
data_set_arr = []
|
557
|
+
headers = []
|
558
|
+
rows = []
|
559
|
+
next_dataset_name = if name = @next_dataset_name
|
560
|
+
name.to_s
|
561
|
+
else
|
562
|
+
"#{@analysis_category}_#{@name.gsub(/\s/,'').gsub(/_/,'')}_#{dataset.id}"
|
563
|
+
end
|
564
|
+
data_set_arr = {'DataSetName'=>next_dataset_name, 'ProjectNumber'=>@project.gsub(/p/,''), 'ParentID'=>@dataset_sushi_id, 'Comment'=>@next_dataset_comment.to_s}
|
565
|
+
csv = CSV.readlines(@next_dataset_tsv_path, :col_sep=>"\t")
|
566
|
+
csv.each do |row|
|
567
|
+
if headers.empty?
|
568
|
+
headers = row
|
569
|
+
else
|
570
|
+
rows << row
|
571
|
+
end
|
583
572
|
end
|
573
|
+
unless NO_ROR
|
574
|
+
#@next_dataset_id = save_data_set(data_set_arr.to_a.flatten, headers, rows, current_user)
|
575
|
+
@next_dataset_id = save_data_set(data_set_arr.to_a.flatten, headers, rows)
|
576
|
+
|
577
|
+
# save job and dataset relation in Sushi DB
|
578
|
+
job_ids.each do |job_id|
|
579
|
+
new_job = Job.new
|
580
|
+
new_job.submit_job_id = job_id.to_i
|
581
|
+
new_job.next_dataset_id = @next_dataset_id
|
582
|
+
new_job.save
|
583
|
+
new_job.data_set.jobs << new_job
|
584
|
+
new_job.data_set.save
|
585
|
+
end
|
584
586
|
|
587
|
+
end
|
585
588
|
end
|
586
|
-
|
587
|
-
|
588
|
-
end
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
589
|
+
copy_nextdataset
|
590
|
+
end # grand-child process
|
591
|
+
end # child process
|
592
|
+
Process.waitpid pid
|
593
|
+
# if Thread.main == Thread.current # in case of running script directly on terminal
|
594
|
+
# warn "copy next dataset..."
|
595
|
+
# t.join
|
596
|
+
# warn "copy finish."
|
597
|
+
# end
|
594
598
|
end
|
595
599
|
def test_run
|
596
600
|
set_dir_paths
|
data/lib/sushi_fabric/version.rb
CHANGED