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.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
- # Version = '20141009-103900'
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
- ## sushi writes creates the job scripts and builds the result data set that is to be generated
524
- @result_dataset = []
525
- @job_scripts = []
526
- if @params['process_mode'] == 'SAMPLE'
527
- sample_mode
528
- elsif @params['process_mode'] == 'DATASET'
529
- dataset_mode
530
- else
531
- #stop
532
- warn "the process mode (#{@params['process_mode']}) is not defined"
533
- raise "stop job submitting"
534
- end
535
- copy_inputdataset_parameter_jobscripts
536
-
537
- # job submittion
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
- puts
545
- print 'job scripts: '
546
- p @job_scripts
547
- print 'result dataset: '
548
- p @result_dataset
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
- unless NO_ROR
572
- #@next_dataset_id = save_data_set(data_set_arr.to_a.flatten, headers, rows, current_user)
573
- @next_dataset_id = save_data_set(data_set_arr.to_a.flatten, headers, rows)
574
-
575
- # save job and dataset relation in Sushi DB
576
- job_ids.each do |job_id|
577
- new_job = Job.new
578
- new_job.submit_job_id = job_id.to_i
579
- new_job.next_dataset_id = @next_dataset_id
580
- new_job.save
581
- new_job.data_set.jobs << new_job
582
- new_job.data_set.save
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
- end
587
- copy_nextdataset
588
- end
589
- if Thread.main == Thread.current # in case of running script directly on terminal
590
- warn "copy next dataset..."
591
- t.join
592
- warn "copy finish."
593
- end
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
@@ -1,3 +1,3 @@
1
1
  module SushiFabric
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
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.7
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: