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 +4 -4
- data/lib/sushi_fabric/sushiApp.rb +57 -62
- data/lib/sushi_fabric/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c375c896829e294b63728368c1fa248e47236726edd3a8e6df9f7652e4795f1
|
4
|
+
data.tar.gz: 1028ca9f39a40cf7749b48bc31caf48c2fb234f7e5a8957f4f65a138d581b224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 = '
|
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
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
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
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
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
|
-
|
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
|
-
|
895
|
-
|
896
|
-
|
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
|
-
|
898
|
+
gstore_job_script_paths.each do |script_path|
|
909
899
|
new_job = Job.new
|
910
|
-
new_job.
|
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
|
-
|
915
|
-
new_job.data_set
|
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
|
|
data/lib/sushi_fabric/version.rb
CHANGED