autoflow 0.9.6 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e2701342ff440d0d59eb570fe27b29207d53086ba8136a7a36cf4d6645282c1
4
- data.tar.gz: 617a0049af3be6e649947f73eabe68ac38016fd0e687b42ef1c3081faebe3db7
3
+ metadata.gz: 03720c11e2c6d967b2907823e0de305e34f8e141a792f6f4291ce6db41b3083b
4
+ data.tar.gz: cf00a1b7ef0f26e6a82c4044792d68b8e66783efe652bff50956c6c706bfa785
5
5
  SHA512:
6
- metadata.gz: 768d88e9b31cce325d703a27659e63485ae801701bdc4a668218df71888d4517a62be5f95c681f29828a7ef93d00a3cacf51af66e354cd4c56b0d5b415511722
7
- data.tar.gz: e5495d58e69440871e743613716866eeb1a93968214cc50fc5da2298beb5cb3d5dadcf67bdcf0ce0ce208696740866805ba6cbfc12cce1d056e2d0ead6f44ce7
6
+ metadata.gz: 6feeef52e7c4e92f630c2ad9e01d3d08b056a588c562fb87cae587e58dcf213fda8b86e7e61d72df6b507827ec6cb48360c25a3ce8e56fb2c4ed9be899057d52
7
+ data.tar.gz: 1b27d3309c7e1a30a2e31f01dde55b7b35d9be32bf4ef13c683b002941df60f61bb6385bb57bc6e226325c863f6eceae21170e5d8797f5e2623608da65bf48ce
data/bin/AutoFlow CHANGED
@@ -9,7 +9,7 @@ require 'optparse'
9
9
  require 'autoflow'
10
10
  require 'io/console'
11
11
  require 'net/ssh'
12
- require 'queue_manager'
12
+ #require 'queue_manager'
13
13
  require 'fileutils'
14
14
  require 'git'
15
15
 
@@ -347,7 +347,6 @@ if !options[:graph].nil?
347
347
  stack.draw(template_file, options[:graph])
348
348
  else
349
349
  stack.inspect if options[:verbose]
350
- stack.comment_main_command if options[:comment]
351
350
  options[:write_sh] = true # Set in flow logger to FALSE, it is used for relaunch failed jobs
352
351
  manager = QueueManager.select_queue_manager(stack.exec_folder, options, stack.jobs, stack.persist_variables)
353
352
  manager.exec
data/bin/flow_logger CHANGED
@@ -7,11 +7,8 @@ $: << File.expand_path(File.join(ROOT_PATH, "..", "lib", "autoflow", "queue_mana
7
7
  require 'autoflow'
8
8
  require 'optparse'
9
9
  require 'colorize'
10
- require 'logging'
11
10
  require 'json'
12
11
  require 'terminal-table'
13
- require 'queue_manager'
14
- require 'program'
15
12
  require 'erb'
16
13
 
17
14
  #################################################################################################
@@ -1,4 +1,3 @@
1
- require 'logging'
2
1
  require 'json'
3
2
  class QueueManager
4
3
 
@@ -16,6 +15,7 @@ class QueueManager
16
15
  @external_dependencies = options[:external_dependencies]
17
16
  @active_jobs = []
18
17
  @extended_logging = options[:extended_logging]
18
+ @comment = options[:comment]
19
19
  end
20
20
 
21
21
  ########################################################################################
@@ -36,6 +36,7 @@ class QueueManager
36
36
  else
37
37
  queue_manager = select_manager(options)
38
38
  end
39
+ warn("Selected queue manager: #{queue_manager}")
39
40
  return queue_manager.new(exec_folder, options, jobs, persist_variables)
40
41
  end
41
42
 
@@ -268,12 +269,17 @@ class QueueManager
268
269
 
269
270
  def write_job(job, sh_name)
270
271
  write_file(sh_name, job.initialization) if !job.initialization.nil?
271
- if @extended_logging
272
- log_command = '/usr/bin/time -o process_data -v '
272
+ if @comment
273
+ cmd = '#' + job.parameters
273
274
  else
274
- log_command = 'time '
275
+ if @extended_logging
276
+ log_command = '/usr/bin/time -o process_data -v '
277
+ else
278
+ log_command = 'time '
279
+ end
280
+ cmd = log_command + job.parameters
275
281
  end
276
- write_file(sh_name, log_command + job.parameters)
282
+ write_file(sh_name, cmd)
277
283
  end
278
284
 
279
285
  def get_dependencies(job, id = nil)
@@ -0,0 +1,66 @@
1
+ require 'queue_manager'
2
+ class SlurmManager2 < QueueManager
3
+ # SLURM 20 or greater
4
+ def parse_additional_options(string, attribs)
5
+ expresions = %w[%C %T %M %N ]
6
+ values = [attribs[:cpu], attribs[:time], attribs[:mem], attribs[:node]]
7
+ new_string = string.dup
8
+ expresions.each_with_index do |exp, i|
9
+ new_string.gsub!(exp, "#{values[i]}")
10
+ end
11
+ return new_string
12
+ end
13
+
14
+ def write_header(id, job, sh_name)
15
+ if !job.attrib[:ntask]
16
+ write_file(sh_name, "#SBATCH --cpus-per-task=#{job.attrib[:cpu]}")
17
+ else
18
+ write_file(sh_name, "#SBATCH --ntasks=#{job.attrib[:cpu]}")
19
+ write_file(sh_name, "#SBATCH --nodes=#{job.attrib[:multinode]}") if job.attrib[:multinode] > 0
20
+ end
21
+ write_file(sh_name, "#SBATCH --mem=#{job.attrib[:mem]}")
22
+ write_file(sh_name, "#SBATCH --time=#{job.attrib[:time]}")
23
+ write_file(sh_name, "#SBATCH --constraint=#{job.attrib[:node]}") if !job.attrib[:node].nil?
24
+ write_file(sh_name, '#SBATCH --error=job.%J.err')
25
+ write_file(sh_name, '#SBATCH --output=job.%J.out')
26
+ write_file(sh_name, "#SBATCH --#{job.attrib[:additional_job_options][0]}=#{parse_additional_options(job.attrib[:additional_job_options][1], job.attrib)}") if !job.attrib[:additional_job_options].nil?
27
+ if job.attrib[:ntask]
28
+ write_file(sh_name, 'srun hostname -s > workers') if job.attrib[:cpu_asign] == 'list'
29
+ end
30
+ end
31
+
32
+
33
+ def submit_job(job, ar_dependencies)
34
+ final_dep = get_all_deps(ar_dependencies)
35
+ dependencies = nil
36
+ dependencies='--dependency=afterok:'+final_dep.join(':') if !final_dep.empty?
37
+ cmd = "sbatch #{dependencies} #{job.name}.sh"
38
+ STDOUT.puts cmd if @show_submit
39
+ queue_id = get_queue_system_id(system_call(cmd, job.attrib[:exec_folder]))
40
+ return queue_id
41
+ end
42
+
43
+ def get_queue_system_id(shell_output)
44
+ queue_id = nil
45
+ shell_output.chomp!
46
+ shell_output =~ /Submitted batch job (\d+)/
47
+ queue_id = $1
48
+ raise("A queue id cannot be obtained. The queue manager has given this message:#{shell_output}") if queue_id.nil?
49
+ return queue_id
50
+ end
51
+
52
+ def self.available?(options)
53
+ available = false
54
+ shell_output = system_call("type 'sbatch'", nil, options[:remote], options[:ssh])
55
+ if !shell_output.empty?
56
+ shell_output = system_call("sbatch --version", nil, options[:remote], options[:ssh])
57
+ slurm_version = shell_output.split(' ').last.split('.').first.to_i # "slurm 17.11.4"
58
+ available = true if slurm_version >= 20
59
+ end
60
+ return available
61
+ end
62
+
63
+ def self.priority
64
+ return 100
65
+ end
66
+ end
@@ -42,19 +42,24 @@ class SlurmManager < QueueManager
42
42
  def get_queue_system_id(shell_output)
43
43
  queue_id = nil
44
44
  shell_output.chomp!
45
- fields = shell_output.split(' ')
46
- queue_id = fields[3]
45
+ shell_output =~ /Submitted batch job (\d+)/
46
+ queue_id = $1
47
+ raise("A queue id cannot be obtained. The queue manager has given this message:#{shell_output}") if queue_id.nil?
47
48
  return queue_id
48
49
  end
49
50
 
50
51
  def self.available?(options)
51
- available = true
52
+ available = false
52
53
  shell_output = system_call("type 'sbatch'", nil, options[:remote], options[:ssh])
53
- available = false if shell_output.empty?
54
+ if !shell_output.empty?
55
+ shell_output = system_call("sbatch --version", nil, options[:remote], options[:ssh])
56
+ slurm_version = shell_output.split(' ').last.split('.').first.to_i # "slurm 17.11.4"
57
+ available = true if slurm_version < 20
58
+ end
54
59
  return available
55
60
  end
56
61
 
57
62
  def self.priority
58
- return 100
63
+ return 120
59
64
  end
60
65
  end
@@ -1,5 +1,5 @@
1
- require 'program'
2
- require 'batch'
1
+ #require 'program'
2
+ #require 'batch'
3
3
 
4
4
  require 'win32console' if !ENV['OS'].nil? && ENV['OS'].downcase.include?('windows')
5
5
  require 'colorize'
@@ -225,11 +225,6 @@ class Stack
225
225
  return hash
226
226
  end
227
227
 
228
- def comment_main_command
229
- @jobs.each do |name, job|
230
- job.parameters = "##{job.parameters}"
231
- end
232
- end
233
228
  ##########################################################################################
234
229
  ## WORKFLOW REPRESENTATION
235
230
  ##########################################################################################
@@ -1,3 +1,3 @@
1
1
  module Autoflow
2
- VERSION = "0.9.6"
2
+ VERSION = "0.9.9"
3
3
  end
data/lib/autoflow.rb CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  require "autoflow/version"
3
3
  require "autoflow/stack"
4
+ require "autoflow/queue_manager"
5
+ require "autoflow/program"
6
+ require "autoflow/batch"
7
+ require "autoflow/logging"
4
8
 
5
9
  module Autoflow
6
10
  # Your code goes here...
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Seoane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2022-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -136,6 +136,7 @@ files:
136
136
  - lib/autoflow/program.rb
137
137
  - lib/autoflow/queue_manager.rb
138
138
  - lib/autoflow/queue_managers/bash_manager.rb
139
+ - lib/autoflow/queue_managers/slurm2_manager.rb
139
140
  - lib/autoflow/queue_managers/slurm_manager.rb
140
141
  - lib/autoflow/stack.rb
141
142
  - lib/autoflow/version.rb
@@ -160,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
161
  - !ruby/object:Gem::Version
161
162
  version: '0'
162
163
  requirements: []
163
- rubygems_version: 3.2.3
164
+ rubygems_version: 3.2.15
164
165
  signing_key:
165
166
  specification_version: 4
166
167
  summary: '"This gem take a pipeline and launch it on a queue system"'