qtools 0.4.0 → 0.4.1
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/README.md +15 -33
- data/bin/qcount +1 -1
- data/bin/qnode +1 -1
- data/bin/qqsub +48 -17
- data/bin/qundo +1 -1
- data/lib/qtools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb43e525d2cab83fa5e423abc7fdf93b5493cd61
|
4
|
+
data.tar.gz: 42d03f7c9712b282c247a99d89bf422a23191cfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42ed7171a340d405c3dbdb637fa7701bf4725ec58fa6d9b741a49b31c3c8296174284404f86d583cf1459ac2f98f8dff777fb6837fe2cd1dca239446c74c5573
|
7
|
+
data.tar.gz: c8cacf15a8717b023ed54ffcfafe8cc91b83a25694ba132af72857659f39c254198c25e91b4501c8153b270134264350a4f24b0ec75bf2c5b0bb610fb8c62fcd
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# qtools
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/qtools)
|
4
|
+
|
3
5
|
`qtools` offers the shortcuts for some common procedures when working with the Open Grid Scheduler.
|
4
6
|
|
5
7
|
|
@@ -27,57 +29,37 @@ Usage:
|
|
27
29
|
|
28
30
|
The command above will create a shell script file with the corresponding content and submit a job which will feature the name `my_name` and require `8gb` of memory.
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
Usage:
|
33
|
-
|
34
|
-
$ qwatch
|
32
|
+
Available parameters:
|
35
33
|
|
36
|
-
|
34
|
+
- `-n`, `--name` - job title
|
35
|
+
- `-m`, `--memory` - memory (e.g., `80gb`)
|
36
|
+
- `-q`, `--queue` - queue title
|
37
|
+
- `-t`, `--time` - job time limit in hours (default is `24`)
|
38
|
+
- `-c`, `--cpu` - number of CPUs
|
37
39
|
|
38
|
-
|
40
|
+
### qwatch
|
39
41
|
|
40
|
-
|
42
|
+
`qwatch` is equivalent to running `watch -n1 -d "qstat -u $USER"`. Use `-n` (`--nodes`) flag to show information on nodes too (`qstat -n1 -u $USER`)
|
41
43
|
|
42
44
|
### qclean
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
$ qclean
|
47
|
-
|
48
|
-
The command above will run `rm *.[eo][0-9]*` in the current directory (if such files exist).
|
46
|
+
`qclean` will run `rm *.[eo][0-9]*` in the current directory (if such files exist).
|
49
47
|
|
50
48
|
### qcount
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
$ qcount
|
55
|
-
|
56
|
-
Count the number of jobs for the `$USER`. Running `qcount -a` will output the number of jobs for all the users.
|
50
|
+
Use `qcount` to count the number of jobs for the `$USER`. Running `qcount -a` will output the number of jobs for all the users.
|
57
51
|
|
58
52
|
### qnode
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
$ qnode
|
63
|
-
|
64
|
-
The command above will print the list of free nodes sorted by their `LOAD`. Use `qnode -m` to sort the list of free nodes by memory available and `qnode -c` to sort the list by the number of free cores.
|
54
|
+
Run `qnode` to print the list of free nodes sorted by their `LOAD`. Use `qnode -m` to sort the list of free nodes by memory available and `qnode -c` to sort the list by the number of free cores.
|
65
55
|
|
66
56
|
### qundo
|
67
57
|
|
68
|
-
|
69
|
-
|
70
|
-
$ qundo
|
71
|
-
|
72
|
-
The command above will try to run `qdel` for the last job submitted.
|
58
|
+
`qundo` will try to run `qdel` for the last job submitted (for the current user).
|
73
59
|
|
74
60
|
### qless
|
75
61
|
|
76
|
-
|
77
|
-
|
78
|
-
$ qless
|
79
|
-
|
80
|
-
The command above will try to read the last default error log `.e[0-9]*` in the current folder. Use `-o` flag to read the last default output file.
|
62
|
+
Run `qless` to read the last default error log `.e[0-9]*` in the current folder. Use `-o` flag to read the last default output file.
|
81
63
|
|
82
64
|
## Contributing
|
83
65
|
|
data/bin/qcount
CHANGED
data/bin/qnode
CHANGED
@@ -27,5 +27,5 @@ else
|
|
27
27
|
new_header = header.strip.gsub("CORES_TOTAL(USED)", "CORES_TOTAL\tCORES_USED") + "\tCORES_FREE"
|
28
28
|
puts new_header
|
29
29
|
puts `qhost | head -n2 | tail -n1`
|
30
|
-
puts `qhost | egrep 'free' |
|
30
|
+
puts `qhost | egrep 'free' | tr "(" "\t" | tr -d ")" | awk 'BEGIN {OFS="\t"}; {print $0, $2-$3}' | sort -k8nr`
|
31
31
|
end
|
data/bin/qqsub
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
require 'qtools'
|
4
4
|
require 'optparse'
|
5
5
|
|
6
|
-
Options = Struct.new(:name, :mem)
|
6
|
+
Options = Struct.new(:name, :mem, :queue, :cpus, :time)
|
7
7
|
|
8
|
-
args = Options.new
|
8
|
+
args = Options.new
|
9
9
|
OptionParser.new do |opts|
|
10
10
|
opts.banner = "Usage: qtools 'python3 my_script.py ...' [options]"
|
11
11
|
|
@@ -15,6 +15,15 @@ OptionParser.new do |opts|
|
|
15
15
|
opts.on("-m", "--memory MEMORY", "Memory for the job (e.g., 80gb)") do |m|
|
16
16
|
args.mem = m
|
17
17
|
end
|
18
|
+
opts.on("-q", "--queue QUEUE_TITLE", "Select a queue for the job") do |q|
|
19
|
+
args.queue = q
|
20
|
+
end
|
21
|
+
opts.on("-c", "--cpu NUMBER_OF_CORES", "Number of CPIs for the job (e.g., 8)") do |c|
|
22
|
+
args.cpus = c
|
23
|
+
end
|
24
|
+
opts.on("-t", "--time TIME_IN_HOURS", "Set the time limit for the job (default is 24 hours)") do |t|
|
25
|
+
args.time = t
|
26
|
+
end
|
18
27
|
end.parse!
|
19
28
|
|
20
29
|
command = ARGV
|
@@ -23,34 +32,56 @@ if command.empty?
|
|
23
32
|
fail "Usage: qtools 'python3 my_script.py ...' [options]"
|
24
33
|
end
|
25
34
|
|
26
|
-
header_sge = <<-HEADER
|
27
|
-
#!/bin/bash
|
28
35
|
|
29
|
-
|
30
|
-
|
31
|
-
|
36
|
+
# Guess the scheduler (SGE or PBS)
|
37
|
+
scheduler_temp = `pbs-config 2> /dev/null`
|
38
|
+
SCHEDULER = (scheduler_temp.empty? or scheduler_temp.nil?) ? :sge : :pbs
|
39
|
+
# puts "the scheduler is guessed to be #{SCHEDULER}"
|
32
40
|
|
33
41
|
header_shell = "#!/bin/bash\n"
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
43
|
+
if SCHEDULER == :sge
|
44
|
+
header_tree = Hash.new
|
45
|
+
header_tree[:V] = []
|
46
|
+
header_tree[:cwd] = []
|
47
|
+
header_tree[:l] = []
|
48
|
+
header_tree[:l] << "h_rt=#{args.time ? args.time : '24'}:00:00"
|
49
|
+
else
|
50
|
+
header_tree = Hash.new
|
51
|
+
header_tree[:l] = []
|
52
|
+
header_tree[:l] << "walltime=#{args.time ? args.time : '24'}:00:00"
|
53
|
+
header_tree[:d] = ['.']
|
54
|
+
end
|
55
|
+
|
38
56
|
|
39
|
-
|
40
|
-
|
57
|
+
if args.name
|
58
|
+
header_tree[:N] = [args.name]
|
41
59
|
end
|
42
60
|
|
43
|
-
|
44
|
-
|
61
|
+
if args.mem
|
62
|
+
header_tree[:l] << "#{SCHEDULER == :sge ? "h_vmem" : "mem"}=#{args.mem}"
|
63
|
+
end
|
64
|
+
|
65
|
+
if args.queue
|
66
|
+
header_tree[:q] = [args.queue]
|
67
|
+
end
|
68
|
+
|
69
|
+
if args.cpus
|
70
|
+
if SCHEDULER == :sge
|
71
|
+
header_tree[:pe] = "smp #{args.cpus}"
|
72
|
+
else
|
73
|
+
header_tree[:l] << "ncpus=#{args.cpus}"
|
74
|
+
end
|
45
75
|
end
|
46
76
|
|
47
|
-
|
77
|
+
scheduler_prefix = SCHEDULER == :sge ? "$" : "PBS"
|
78
|
+
header = header_tree.map { |k, v| "##{scheduler_prefix} -#{k} #{v.join(',')}" }.join("\n")
|
48
79
|
|
49
80
|
sh_prefix_guess = (command[0].split[1].include?('.') or command[0].split.length == 1) ? command[0].split[1] : command[0].split[0] # guess if script or executable
|
50
81
|
sh_prefix = sh_prefix_guess.include?('.') ? sh_prefix_guess.match(/(.*)\.(.*?)/)[1] : sh_prefix_guess
|
51
|
-
sh_name = (
|
82
|
+
sh_name = (header_tree[:N] ? header_tree[:N][0] : sh_prefix) + '.sh'
|
52
83
|
|
53
|
-
File.write(sh_name, [header_shell,
|
84
|
+
File.write(sh_name, [header_shell, header, "", command[0]].join("\n"))
|
54
85
|
|
55
86
|
puts "-- Submit #{sh_name} for execution? [y/n]"
|
56
87
|
answer = STDIN.gets.strip.downcase
|
data/bin/qundo
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'qtools'
|
4
4
|
|
5
5
|
last_job = `qstat -u $USER | tail -n 1`
|
6
|
-
last_job_id = `qstat -u $USER | tail -n 1 | sed -rn 's/(^[0-9]*)
|
6
|
+
last_job_id = `qstat -u $USER | tail -n 1 | sed -rn 's/(^[0-9]*).*/\\1/p'`.strip
|
7
7
|
|
8
8
|
unless last_job.empty?
|
9
9
|
puts "-- The following job will be stopped:"
|
data/lib/qtools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05
|
11
|
+
date: 2016-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|