rbbt-util 5.39.0 → 5.40.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rbbt-util'
4
+ require 'rbbt/util/simpleopt'
5
+ require 'rbbt/hpc'
6
+
7
+ #$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
8
+
9
+ options = SOPT.setup <<EOF
10
+
11
+ Queue a job in Marenostrum
12
+
13
+ $ rbbt slurm tail <directory|jobid> [options]
14
+
15
+ -h--help Print this help
16
+ EOF
17
+
18
+ if options[:help]
19
+ if defined? rbbt_usage
20
+ rbbt_usage
21
+ else
22
+ puts SOPT.doc
23
+ end
24
+ exit 0
25
+ end
26
+
27
+ batch_system = options.delete :batch_system
28
+ batch_system ||= 'auto'
29
+
30
+ HPC::BATCH_MODULE = HPC.batch_system batch_system
31
+
32
+ raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint batch_system}") if HPC::BATCH_MODULE.nil?
33
+
34
+ directory = ARGV.shift
35
+
36
+ raise ParameterException if directory.nil?
37
+
38
+ if directory =~ /^[0-9]*$/
39
+ workdir = File.expand_path('~/rbbt-batch')
40
+ Path.setup(workdir)
41
+
42
+ workdir.glob("**/job.id").each do |file|
43
+ next unless directory == Open.read(file).strip
44
+ directory = File.dirname(file)
45
+ break
46
+ end
47
+ end
48
+
49
+ raise ParameterException, "Could not identify job #{directory}" unless File.exist?(directory)
50
+
51
+ require 'rbbt/hpc/slurm'
52
+
53
+ command_txt = Open.read(File.join(directory, 'command.batch'))
54
+ if m = command_txt.match(/#STEP_PATH: (.*)/)
55
+ step_path = m[1]
56
+ else
57
+ step_path = nil
58
+ end
59
+
60
+ puts Log.color(:magenta, "Directory: ") + directory if directory
61
+ puts Log.color(:magenta, "Step path: ") + step_path if step_path
62
+
63
+ HPC::BATCH_MODULE.follow_job directory, true
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rbbt/util/simpleopt'
4
+ require 'rbbt/workflow'
5
+ require 'rbbt/workflow/usage'
6
+ require 'rbbt/workflow/remote_workflow'
7
+ require 'rbbt/hpc'
8
+ require 'time'
9
+
10
+ rbbt_options = SOPT::GOT_OPTIONS
11
+
12
+ $slurm_options = SOPT.get <<EOF
13
+ -dr--dry_run Print only the template
14
+ -cj--clean_job Clean job
15
+ --drbbt* Use development version of rbbt
16
+ -sing--singularity Use Singularity
17
+ -si--singularity_img* Singularity image to use
18
+ -sm--singularity_mounts* Singularity image to use
19
+ -ug--user_group* Use alternative user group for group project directory
20
+ -c--contain* Contain in directory (using Singularity)
21
+ -s--sync* Contain in directory and sync jobs
22
+ -e--exclusive Make exclusive use of the node
23
+ -hm--highmem Make use of highmem cores
24
+ -wc--wipe_container* Wipe the jobs from the contain directory
25
+ -pd--purge_deps Purge job dependencies
26
+ -CS--contain_and_sync Contain and sync to default locations
27
+ -ci--copy_image When using a container directory, copy image there
28
+ -t--tail Tail the logs
29
+ -BPP--batch_procpath* Save Procpath performance for batch job; specify only options
30
+ -q--queue* Queue
31
+ -a--account* Account
32
+ -p--partition* Partition
33
+ -t--task_cpus* Tasks
34
+ -tm--time* Time
35
+ -m--mem* minimum memory
36
+ --gres* Generic resources
37
+ -mcpu--mem_per_cpu* minimum memory per CPU
38
+ -lin--licenses* licenses
39
+ -cons--constraint* constraint
40
+ -W--workflows* Additional workflows
41
+ -rmb--remove_batch_dir Remove the batch working directory (command, STDIN, exit status, ...)
42
+ -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
43
+ -lmod--lua_modules* Lua Modules to load
44
+ -co--conda* Conda environment to use
45
+ -OR--orchestration_rules* Orchestration rules
46
+ EOF
47
+
48
+ batch_system = $slurm_options.delete :batch_system
49
+ batch_system ||= 'auto'
50
+
51
+ HPC::BATCH_MODULE = HPC.batch_system batch_system
52
+
53
+ raise ParameterException.new("Could not detect batch_system: #{Misc.fingerprint batch_system}") if HPC::BATCH_MODULE.nil?
54
+
55
+ class Step
56
+
57
+ def run(*args)
58
+ if done?
59
+ self.load
60
+ else
61
+ begin
62
+ Log.debug "Issuing BATCH job for #{self.path}"
63
+ HPC::BATCH_MODULE.run_job(self, $slurm_options)
64
+ rescue HPC::BATCH_DRY_RUN
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ module RemoteStep::SSH
71
+
72
+ def _run
73
+ RemoteWorkflow::SSH.run_slurm_job(File.join(base_url, task.to_s), @input_id, @base_name, $slurm_options)
74
+ end
75
+
76
+ end
77
+
78
+ SOPT.current_options = rbbt_options
79
+ load Rbbt.share.rbbt_commands.workflow.task.find
@@ -253,6 +253,8 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
253
253
  text = CMD.cmd('grep "^#SBATCH" ', :in => Open.read(fcmd)).read.strip
254
254
  when 'lsf'
255
255
  text = CMD.cmd('grep "^#BSUB" ', :in => Open.read(fcmd)).read.strip
256
+ when 'pbs'
257
+ text = CMD.cmd('grep "^#PBS" ', :in => Open.read(fcmd)).read.strip
256
258
  else
257
259
  text = ""
258
260
  end
@@ -73,7 +73,7 @@ class Step
73
73
  join
74
74
  self.load
75
75
  end
76
- rescue HPC::SBATCH
76
+ rescue HPC::BATCH_DRY_RUN
77
77
  end
78
78
  end
79
79
  end
@@ -32,16 +32,17 @@ $slurm_options = SOPT.get <<EOF
32
32
  -p--partition* Partition
33
33
  -t--task_cpus* Tasks
34
34
  -tm--time* Time
35
- -m--mem* SLURM minimum memory
36
- --gres* SLURM Generic resources
37
- -mcpu--mem_per_cpu* SLURM minimum memory per CPU
38
- -lin--licenses* SLURM licenses
39
- -cons--constraint* SLURM constraint
35
+ -m--mem* minimum memory
36
+ --gres* Generic resources
37
+ -mcpu--mem_per_cpu* minimum memory per CPU
38
+ -lin--licenses* licenses
39
+ -cons--constraint* constraint
40
40
  -W--workflows* Additional workflows
41
41
  -rmb--remove_batch_dir Remove the batch working directory (command, STDIN, exit status, ...)
42
42
  -bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
43
43
  -lmod--lua_modules* Lua Modules to load
44
44
  -co--conda* Conda environment to use
45
+ -OR--orchestration_rules* Orchestration rules
45
46
  EOF
46
47
 
47
48
  batch_system = $slurm_options.delete :batch_system
@@ -58,9 +59,9 @@ class Step
58
59
  self.load
59
60
  else
60
61
  begin
61
- Log.debug "Issuing SLURM job for #{self.path}"
62
+ Log.debug "Issuing BATCH job for #{self.path}"
62
63
  HPC::BATCH_MODULE.run_job(self, $slurm_options)
63
- rescue HPC::SBATCH
64
+ rescue HPC::BATCH_DRY_RUN
64
65
  end
65
66
  end
66
67
  end
@@ -0,0 +1,43 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'rbbt/workflow'
5
+
6
+ class TestPBS < Test::Unit::TestCase
7
+ def workflow
8
+ @workflow ||= Module.new do
9
+ extend Workflow
10
+
11
+ def self.to_s
12
+ "TestWorkflow"
13
+ end
14
+
15
+ input :name, :string
16
+ task :hello => :string do |name|
17
+ "hello #{name}"
18
+ end
19
+ end
20
+ end
21
+
22
+ def test_template
23
+ job = workflow.job(:hello, "TEST", :name => "world")
24
+
25
+ TmpFile.with_file do |batch_dir|
26
+
27
+ template = HPC::PBS.job_template(job, :batch_dir => batch_dir, :lua_modules => 'java')
28
+ ppp template
29
+
30
+ end
31
+ end
32
+
33
+ def __test_run_job
34
+ job = Sample.job(:mutect2, "small", :reference => "hg38")
35
+
36
+ job.clean
37
+
38
+ jobid = HPC::SLURM.run_job(job, :workflows => "HTS", :batch_modules => 'java', :env_cmd => '_JAVA_OPTIONS="-Xms1g -Xmx${MAX_MEMORY}m"', :queue => :debug, :time => '01:00:00', :config_keys => "HTS_light", :task_cpus => '10', :tail => true, :clean_task => "HTS#mutect2")
39
+ assert jobid.to_s =~ /^\d+$/
40
+ end
41
+
42
+ end
43
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.39.0
4
+ version: 5.40.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-02 00:00:00.000000000 Z
11
+ date: 2023-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -136,20 +136,6 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: nokogiri
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
139
  description: Utilities for handling tsv files, caches, etc
154
140
  email: miguel.vazquez.g@bsc.es
155
141
  executables:
@@ -206,6 +192,7 @@ files:
206
192
  - lib/rbbt/hpc/orchestrate/batches.rb
207
193
  - lib/rbbt/hpc/orchestrate/chains.rb
208
194
  - lib/rbbt/hpc/orchestrate/rules.rb
195
+ - lib/rbbt/hpc/pbs.rb
209
196
  - lib/rbbt/hpc/slurm.rb
210
197
  - lib/rbbt/knowledge_base.rb
211
198
  - lib/rbbt/knowledge_base/enrichment.rb
@@ -301,6 +288,7 @@ files:
301
288
  - lib/rbbt/util/open.rb
302
289
  - lib/rbbt/util/procpath.rb
303
290
  - lib/rbbt/util/python.rb
291
+ - lib/rbbt/util/python/step.rb
304
292
  - lib/rbbt/util/python/util.rb
305
293
  - lib/rbbt/util/semaphore.rb
306
294
  - lib/rbbt/util/simpleDSL.rb
@@ -389,6 +377,11 @@ files:
389
377
  - share/rbbt_commands/lsf/task
390
378
  - share/rbbt_commands/migrate
391
379
  - share/rbbt_commands/migrate_job
380
+ - share/rbbt_commands/pbs/clean
381
+ - share/rbbt_commands/pbs/list
382
+ - share/rbbt_commands/pbs/orchestrate
383
+ - share/rbbt_commands/pbs/tail
384
+ - share/rbbt_commands/pbs/task
392
385
  - share/rbbt_commands/purge_job
393
386
  - share/rbbt_commands/resource/claims
394
387
  - share/rbbt_commands/resource/exists
@@ -476,6 +469,7 @@ files:
476
469
  - test/rbbt/hpc/orchestrate/test_rules.rb
477
470
  - test/rbbt/hpc/test_batch.rb
478
471
  - test/rbbt/hpc/test_orchestrate.rb
472
+ - test/rbbt/hpc/test_pbs.rb
479
473
  - test/rbbt/hpc/test_slurm.rb
480
474
  - test/rbbt/knowledge_base/test_enrichment.rb
481
475
  - test/rbbt/knowledge_base/test_entity.rb
@@ -590,7 +584,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
590
584
  - !ruby/object:Gem::Version
591
585
  version: '0'
592
586
  requirements: []
593
- rubygems_version: 3.4.13
587
+ rubygems_version: 3.4.19
594
588
  signing_key:
595
589
  specification_version: 4
596
590
  summary: Utilities for the Ruby Bioinformatics Toolkit (rbbt)
@@ -607,6 +601,7 @@ test_files:
607
601
  - test/rbbt/hpc/orchestrate/test_rules.rb
608
602
  - test/rbbt/hpc/test_batch.rb
609
603
  - test/rbbt/hpc/test_orchestrate.rb
604
+ - test/rbbt/hpc/test_pbs.rb
610
605
  - test/rbbt/hpc/test_slurm.rb
611
606
  - test/rbbt/knowledge_base/test_enrichment.rb
612
607
  - test/rbbt/knowledge_base/test_entity.rb