condor 1.0.0 → 1.1.0

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.
data/README CHANGED
@@ -6,13 +6,21 @@ It consists of a wrapper for a Condor submit file and a program, <tt>condor-exec
6
6
 
7
7
  condor-exec prog --option arg1 arg2
8
8
 
9
- queues up a job for the +prog+ with arguments <tt>--option arg1 arg2</tt>. To pass options to <tt>condor-exec</tt> itself, place them before +prog+. For example:
9
+ queues up a job for the program +prog+ with arguments <tt>--option arg1 arg2</tt>. To pass options to <tt>condor-exec</tt> itself, place them before +prog+. For example:
10
10
 
11
11
  condor-exec --universe=MPI prog --option arg1 arg2
12
12
 
13
+ Alternately arguments may be specified in a separate arguments file, and one
14
+ Condor job will be queued for each line in the file
15
+
16
+ condor-exec --argfile=args prog
17
+
18
+ See <tt>condor-exec --help</tt> for more information.
19
+
13
20
  = History
14
21
 
15
22
  1.0.0:: Basic submit file wrapper; <tt>condor-exec</tt> program
23
+ 1.1.0:: Additional options in <tt>condor-exec</tt>, including argument files; Add logging support
16
24
 
17
25
  = Copyright
18
26
 
@@ -38,7 +38,7 @@ class CommandPassingOptionParser < OptionParser
38
38
  end
39
39
  end
40
40
 
41
- options = {}
41
+ options = {:submit => true}
42
42
  p = CommandPassingOptionParser.new do |opts|
43
43
  opts.banner = <<EOS
44
44
  Usage: #{File.basename(__FILE__)} [options] command [arguments]
@@ -51,12 +51,32 @@ It creates a condor_submit.nnn file in the current directory along with
51
51
  a Condor log file in the system temporary directory.
52
52
 
53
53
  Switch options appearing before the first non-switch argument are passed to
54
- #{File.basename(__FILE__)}. Switch optios appearing after the first
55
- non-switch argument are treated as arguments to the command.
54
+ #{File.basename(__FILE__)}. There must be no spaces in these arguments (e.g.
55
+ '--universe=vanilla' and not '--universe vanilla'). Switch options appearing
56
+ after the first non-switch argument are treated as arguments to the command.
57
+
58
+ If an argument file is specified, one Condor job is created for each line in
59
+ the file, using the text of the line as arguments. These arguments are
60
+ appended after any specified on the command line.
56
61
 
57
- Options:
58
62
  EOS
59
63
 
64
+ opts.on("-aVALUE", "--argfile VALUE", "Argument filename") do |value|
65
+ options[:argfile] = value
66
+ end
67
+
68
+ opts.on("-l", "--logging LEVEL", "Logging level") do |level|
69
+ Condor.set_log_level(eval("Logger::#{level.upcase}"))
70
+ end
71
+
72
+ opts.on("-oVALUE", "--output VALUE", "Output filename") do |value|
73
+ options[:output] = value
74
+ end
75
+
76
+ opts.on("-eVALUE", "--error VALUE", "Error filename") do |value|
77
+ options[:error] = value
78
+ end
79
+
60
80
  opts.on("-gVALUE", "--getenv VALUE", "Get environment") do |value|
61
81
  options[:getenv] = value
62
82
  end
@@ -69,6 +89,10 @@ EOS
69
89
  options[:universe] = value
70
90
  end
71
91
 
92
+ opts.on("-s", "--[no-]submit", "no-submit generates the submit file but does not call condor_submit") do |value|
93
+ options[:submit] = value
94
+ end
95
+
72
96
  end
73
97
 
74
98
  command_line = p.parse_command_line
@@ -17,12 +17,34 @@
17
17
  # St, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
19
  require "erb"
20
+ require "logger"
20
21
  require "tempfile"
21
22
 
22
23
  # Wrapper for the Condor distributed computing system.
23
24
  module Condor
25
+ VERSION = "1.1.0"
24
26
 
25
- VERSION = "1.0.0"
27
+ # Create the logger and set its default log level to ERROR. This function
28
+ # is called when the module is loaded.
29
+ def Condor.initialize_logger
30
+ logger = Logger.new(STDOUT)
31
+ logger.level = Logger::ERROR
32
+ logger.datetime_format = "%Y-%m-%d %H:%M:%S"
33
+ logger
34
+ end
35
+
36
+ private_class_method :initialize_logger
37
+
38
+ # Logger used by all objects in this module. This is initialized at module
39
+ # load time. The default log level is ERROR.
40
+ LOGGER = initialize_logger
41
+
42
+ # Set the logging level. For example:
43
+ #
44
+ # > Condor.set_log_level(Logger::DEBUG)
45
+ def Condor.set_log_level(level)
46
+ Condor::LOGGER.level = level
47
+ end
26
48
 
27
49
  # The text of a file that can be sent to the condor_submit program.
28
50
  class SubmitFile < ERB
@@ -39,8 +61,8 @@ module Condor
39
61
  @executable = executable
40
62
  @argument_list = argument_list
41
63
  @log = File.join(Dir::tmpdir, "#{ENV['USER']}.condor.$(Cluster).$(Process)")
42
- @output = current_dir_log_file("output")
43
- @error = current_dir_log_file("error")
64
+ @output = options.fetch(:output, current_dir_log_file("output"))
65
+ @error = options.fetch(:error, current_dir_log_file("error"))
44
66
  # Create the header common to all the jobs.
45
67
  template = <<-EOTEXT
46
68
  Universe = <%= @options[:universe] %>
@@ -81,13 +103,14 @@ Queue
81
103
  # and STDERR are routed to *.output and *.error files with the names of the
82
104
  # executable and the process ID in the name. The Condor log file is written
83
105
  # to the system's temporary directory.
84
- def Condor.submit(executable, arguments, options = {})
106
+ def Condor.submit(executable, command_line_arguments, options = {})
85
107
  if executable.nil? or executable.empty?
86
108
  raise "You must specify a command to run"
87
109
  end
88
- # Get full path to the command. BUGBUG This is UNIX specific.
110
+ # Condor needs the full path to the command.
111
+ # BUGBUG This is UNIX specific.
89
112
  executable = `which #{executable} 2> /dev/null`.strip
90
- raise "Invalid executable #{executable}" if executable.empty?
113
+ not executable.empty? or raise "#{executable} is not executable."
91
114
  # Create a unique submit file name of the form condor_submit.nnn.
92
115
  n = 0
93
116
  while n < 1000
@@ -97,12 +120,24 @@ Queue
97
120
  n += 1
98
121
  end
99
122
  raise "Cannot create unique submit file name" if n == 1000
123
+ # Optionally read arguments from a file.
124
+ arguments_list = if options.has_key?(:argfile)
125
+ open(options[:argfile]) do |file|
126
+ file.collect do |line|
127
+ line.strip!
128
+ next if line.empty?
129
+ command_line_arguments + line.split
130
+ end
131
+ end
132
+ else
133
+ [command_line_arguments]
134
+ end
100
135
  # Write Condor information to the submit file.
101
136
  File.open(submit_name, "w") do |file|
102
- file << Condor::SubmitFile.new(executable, [arguments], options).to_s
137
+ file << Condor::SubmitFile.new(executable, arguments_list, options)
103
138
  end
104
- # Submit the Condor job.
105
- `condor_submit #{submit_name}`
139
+ # Optionally submit the Condor job.
140
+ `condor_submit #{submit_name}` if options[:submit]
106
141
  end
107
142
 
108
143
  end # Condor
@@ -30,6 +30,6 @@ require "condor"
30
30
 
31
31
  class CondorTestCase < Test::Unit::TestCase
32
32
  def test_submit_file
33
- s = Condor::SubmitFile.new("ruby", "arg1 arg2")
33
+ s = Condor::SubmitFile.new("ruby", [["arg1", "arg2"]])
34
34
  end
35
35
  end # CondorTestCase
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: condor
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2009-01-16 00:00:00 -08:00
6
+ version: 1.1.0
7
+ date: 2009-02-12 00:00:00 -08:00
8
8
  summary: Ruby wrapper for the Condor distributed computing system
9
9
  require_paths:
10
10
  - lib