sushi_fabric 1.3.3 → 1.3.4

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: b074a7fdbd851a7304fbeba55f325f321d3a34e2a320ded50512dacddf930dca
4
- data.tar.gz: 18b23e2e1a49317b4458334fe425659ff6b2a3a22d49591a5c035591cd7f95ad
3
+ metadata.gz: 2c375c896829e294b63728368c1fa248e47236726edd3a8e6df9f7652e4795f1
4
+ data.tar.gz: 1028ca9f39a40cf7749b48bc31caf48c2fb234f7e5a8957f4f65a138d581b224
5
5
  SHA512:
6
- metadata.gz: 97f73f230c8b24c169e42dbdf6e7fff28c2a6a76f54e67c24a9a5a97ce346a91d8752903093e00bed6bd20a5adabff239cac85a844c9c7337af4c689b99ec442
7
- data.tar.gz: 1ebf0c03ff97cdf58f3b1f3b399d212bc932e7bfe91658cad3f01ca7fb55fc8627b2768d62e97f6b90231b78367605f6a431a5e16eb2210ea53dbdcc031cac3d
6
+ metadata.gz: ad376aa52cb707acb2250641e06f6147c5595a62e2e117659e151baec9f67309118b51ca6e83d8365a111632f25ab769a6e5f227c05d9edb28396dac1245e90e
7
+ data.tar.gz: 0c115c81c3c1f929780a061cd2628a356794f0cc8f59ea9d2187df76d3c5346a8139a828765c23828ef06613dbcf0cba8841dfacde82ad4109fc9b80e284f119
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
- # Version = '20241122-134036'
3
+ # Version = '20250109-110636'
4
4
 
5
5
  require 'csv'
6
6
  require 'fileutils'
@@ -21,6 +21,7 @@ module SushiFabric
21
21
  config.module_source = nil
22
22
  config.course_mode = nil
23
23
  config.rails_host = nil
24
+ config.submit_job_script_dir = nil
24
25
  end
25
26
 
26
27
  # load custmized parameters if there is
@@ -43,6 +44,7 @@ module SushiFabric
43
44
  config.module_source = nil
44
45
  config.course_mode = nil
45
46
  config.rails_host = nil
47
+ config.submit_job_script_dir = nil
46
48
  end
47
49
  end
48
50
  EOF
@@ -56,6 +58,7 @@ end
56
58
  SCRATCH_DIR = config.scratch_dir
57
59
  MODULE_SOURCE = config.module_source
58
60
  RAILS_HOST = config.rails_host
61
+ SUBMIT_JOB_SCRIPT_DIR = config.submit_job_script_dir
59
62
  unless File.exist?(GSTORE_DIR)
60
63
  FileUtils.mkdir_p GSTORE_DIR
61
64
  end
@@ -523,58 +526,42 @@ rm -rf #{@scratch_dir} || exit 1
523
526
  def commands
524
527
  # this should be overwritten in a subclass
525
528
  end
526
- def submit_command(job_script)
527
- gsub_options = []
528
- gsub_options << "-c #{@params['cores']}" unless @params['cores'].to_s.empty?
529
- gsub_options << "-n #{@params['node']}" unless @params['node'].to_s.empty?
530
- gsub_options << "-p #{@params['partition']}" unless @params['partition'].to_s.empty?
531
- gsub_options << "-r #{@params['ram']}" unless @params['ram'].to_s.empty?
532
- gsub_options << "-s #{@params['scratch']}" unless @params['scratch'].to_s.empty?
533
- gsub_options << "-i #{@params['nice']}" unless @params['nice'].to_s.empty?
534
- command = "wfm_monitoring --server #{WORKFLOW_MANAGER} --user #{@user} --project #{@project.gsub(/p/,'')} --logdir #{@gstore_script_dir} #{job_script} #{gsub_options.join(' ')}"
535
- puts "submit: #{command}"
536
-
537
- project_number = @project.gsub(/p/, '')
538
- @workflow_manager||=DRbObject.new_with_uri(WORKFLOW_MANAGER)
539
- script_content = File.read(job_script)
540
- job_id = 0
541
- begin
542
- #job_id = @workflow_manager.start_monitoring(job_script, @user, 0, script_content, project_number, gsub_options.join(' '), @gstore_script_dir)
543
- job_id = @workflow_manager.start_monitoring3(job_script, script_content, @user, project_number, gsub_options.join(' '), @gstore_script_dir, @next_dataset_id, RAILS_HOST)
544
- rescue => e
545
- time = Time.now.strftime("[%Y.%m.%d %H:%M:%S]")
546
- @logger.error("*"*50)
547
- @logger.error("submit_command error #{time}")
548
- @logger.error("error: #{e}")
549
- @logger.error("job_script: #{job_script}, @user: #{@user}, script_content: #{script_content.class} #{script_content.to_s.length} chrs, project_number: #{project_number}, gsub_options: #{gsub_options}, job_id: #{job_id}")
550
- @logger.error("*"*50)
551
- end
552
- job_id
529
+ def generate_new_job_script(script_name, script_content)
530
+ new_job_script = File.basename(script_name) + "_" + Time.now.strftime("%Y%m%d%H%M%S%L")
531
+ new_job_script = File.join(SUBMIT_JOB_SCRIPT_DIR, new_job_script)
532
+ open(new_job_script, 'w') do |out|
533
+ out.print script_content
534
+ out.print "\necho __SCRIPT END__\n"
535
+ end
536
+ new_job_script
553
537
  end
554
- def submit(job_script, mock=false)
555
- begin
556
- job_id = unless mock
557
- i = submit_command(job_script)
558
- i.to_i
559
- else
560
- #Time.now.to_f.to_s.gsub('.', '')
561
- 1234
562
- end
563
- unless job_id.to_i > 1
564
- @logger.error("#"*50)
565
- time = Time.now.strftime("[%Y.%m.%d %H:%M:%S]")
566
- @logger.error("error happened in job submitting, but maybe fine. #{time}")
567
- @logger.error("#"*50)
568
- job_id = nil
569
- end
570
- rescue
571
- @logger.error("@"*50)
572
- time = Time.now.strftime("[%Y.%m.%d %H:%M:%S]")
573
- @logger.error("error happened in job submitting, but maybe fine. #{time}")
574
- @logger.error("@"*50)
575
- job_id = nil
538
+ def submit_job_command(script_file, script_content, option='')
539
+ if script_name = File.basename(script_file) and script_name =~ /\.sh/
540
+ script_name = script_name.split(/\.sh/).first + ".sh"
541
+ new_job_script = generate_new_job_script(script_name, script_content)
542
+ new_job_script_base = File.basename(new_job_script)
543
+ log_file = File.join(SUBMIT_JOB_SCRIPT_DIR, new_job_script_base + "_o.log")
544
+ err_file = File.join(SUBMIT_JOB_SCRIPT_DIR, new_job_script_base + "_e.log")
545
+ command = "sbatch -o #{log_file} -e #{err_file} -N 1 #{option} #{new_job_script}"
546
+ [command, new_job_script, log_file, err_file]
547
+ else
548
+ err_msg = "submit_job_command, ERROR: script_name is not *.sh: #{File.basename(script_file)}"
549
+ warn err_msg
550
+ raise err_msg
576
551
  end
577
- job_id
552
+ end
553
+ def submit(script_path, mock=false)
554
+ sbatch_options = []
555
+ sbatch_options << "--mem=#{@params['ram']}G" unless @params['ram'].to_s.empty?
556
+ sbatch_options << "-n #{@params['cores']}" unless @params['cores'].to_s.empty?
557
+ sbatch_options << "--gres=scratch:#{@params['scratch']}" unless @params['scratch'].to_s.empty?
558
+ sbatch_options << "-p #{@params['partition']}" unless @params['partition'].to_s.empty?
559
+ sbatch_options << "--nice=#{@params['nice']}" unless @params['nice'].to_s.empty?
560
+
561
+ script_content = File.read(script_path)
562
+
563
+ submit_command, new_script_path, stdout_path, stderr_path = submit_job_command(script_path, script_content, sbatch_options.join(' '))
564
+ [submit_command, new_script_path, stdout_path, stderr_path]
578
565
  end
579
566
  def preprocess
580
567
  # this should be overwritten in a subclass
@@ -890,29 +877,37 @@ rm -rf #{@scratch_dir} || exit 1
890
877
 
891
878
  # job submittion
892
879
  gstore_job_script_paths = []
880
+ #submit_jobs = []
893
881
  @job_scripts.each_with_index do |job_script, i|
894
- if job_id = submit(job_script, mock)
895
- @job_ids << job_id
896
- print "Submit job #{File.basename(job_script)} job_id=#{job_id}"
897
- gstore_job_script_paths << File.join(@gstore_script_dir, File.basename(job_script))
898
- end
882
+ #submit_command, script_path, stdout_path, stderr_path = submit(job_script, mock)
883
+ #submit_jobs << [submit_command, script_path, stdout_path, stderr_path]
884
+ gstore_job_script_paths << File.join(@gstore_script_dir, File.basename(job_script))
899
885
  end
900
886
 
901
887
  puts
902
888
  print 'job scripts: '
903
889
  p @job_scripts
890
+ print 'gstore_job_script_paths: '
891
+ p gstore_job_script_paths
904
892
 
905
893
 
906
- unless @job_ids.empty? or NO_ROR
894
+ #unless @job_ids.empty? or NO_ROR
895
+ #unless submit_jobs.empty?
896
+ unless gstore_job_script_paths.empty?
907
897
  # save job and dataset relation in Sushi DB
908
- job_ids.each_with_index do |job_id, i|
898
+ gstore_job_script_paths.each do |script_path|
909
899
  new_job = Job.new
910
- new_job.submit_job_id = job_id.to_i
911
- new_job.script_path = gstore_job_script_paths[i]
900
+ new_job.script_path = script_path
912
901
  new_job.next_dataset_id = @next_dataset_id
902
+ new_job.status = "CREATED"
903
+ new_job.user = (@user || "sushi_lover")
904
+ new_job.input_dataset_id = dataset.id if dataset
913
905
  new_job.save
914
- new_job.data_set.jobs << new_job
915
- new_job.data_set.save
906
+ #if dataset
907
+ # new_job.data_set = dataset
908
+ # new_job.data_set.jobs << new_job
909
+ # new_job.data_set.save
910
+ #end
916
911
  end
917
912
  end
918
913
 
@@ -1,3 +1,3 @@
1
1
  module SushiFabric
2
- VERSION = "1.3.3"
2
+ VERSION = "1.3.4"
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: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Functional Genomics Center Zurich