Class: OodJob::Script

Inherits:
Object
  • Object
show all
Defined in:
lib/ood_job/script.rb

Overview

An object that describes a batch job before it is submitted. This includes the resources this batch job will require of the resource manager.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, args: nil, submit_as_hold: nil, rerunnable: nil, job_environment: nil, workdir: nil, email: nil, email_on_started: nil, email_on_terminated: nil, job_name: nil, input_path: nil, output_path: nil, error_path: nil, join_files: nil, reservation_id: nil, queue_name: nil, priority: nil, min_phys_memory: nil, start_time: nil, wall_time: nil, accounting_id: nil, min_procs: nil, nodes: nil, native: nil, **_) ⇒ Script


152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/ood_job/script.rb', line 152

def initialize(content:, args: nil, submit_as_hold: nil, rerunnable: nil,
               job_environment: nil, workdir: nil, email: nil,
               email_on_started: nil, email_on_terminated: nil, job_name: nil,
               input_path: nil, output_path: nil, error_path: nil,
               join_files: nil, reservation_id: nil, queue_name: nil,
               priority: nil, min_phys_memory: nil, start_time: nil,
               wall_time: nil, accounting_id: nil, min_procs: nil, nodes: nil,
               native: nil, **_)
  @content = content.to_s

  @submit_as_hold      = submit_as_hold
  @rerunnable          = rerunnable
  @email_on_started    = email_on_started
  @email_on_terminated = email_on_terminated
  @join_files          = join_files

  @args             = args            && args.map(&:to_s)
  @job_environment  = job_environment && job_environment.each_with_object({}) { |(k, v), h| h[k.to_s] = v.to_s }
  @workdir          = workdir         && Pathname.new(workdir.to_s)
  @email            = email           && Array.wrap(email).map(&:to_s)
  @job_name         = job_name        && job_name.to_s
  @input_path       = input_path      && Pathname.new(input_path.to_s)
  @output_path      = output_path     && Pathname.new(output_path.to_s)
  @error_path       = error_path      && Pathname.new(error_path.to_s)
  @reservation_id   = reservation_id  && reservation_id.to_s
  @queue_name       = queue_name      && queue_name.to_s
  @priority         = priority        && priority.to_i
  @min_phys_memory  = min_phys_memory && min_phys_memory.to_i
  @start_time       = start_time      && Time.at(start_time.to_i)
  @wall_time        = wall_time       && wall_time.to_i
  @accounting_id    = accounting_id   && accounting_id.to_s
  @min_procs        = min_procs       && min_procs.to_i
  @nodes            = nodes           && Array.wrap(nodes).map { |n| n.respond_to?(:to_h) ? NodeRequest.new(n.to_h) : n.to_s }
  @native           = native
end

Instance Attribute Details

#accounting_idString? (readonly)

The attribute used for job accounting purposes


99
100
101
# File 'lib/ood_job/script.rb', line 99

def accounting_id
  @accounting_id
end

#argsArray<String>? (readonly)

Arguments supplied to script to be executed


16
17
18
# File 'lib/ood_job/script.rb', line 16

def args
  @args
end

#contentString (readonly)

Content of the script to be executed on the remote host


12
13
14
# File 'lib/ood_job/script.rb', line 12

def content
  @content
end

#emailArray<String>? (readonly)

List of email addresses that should be used when resource manager sends status notifications


41
42
43
# File 'lib/ood_job/script.rb', line 41

def email
  @email
end

#email_on_startedBoolean? (readonly)

Whether given email addresses should be notified when job starts


45
46
47
# File 'lib/ood_job/script.rb', line 45

def email_on_started
  @email_on_started
end

#email_on_terminatedBoolean? (readonly)

Whether given email addresses should be notified when job ends


49
50
51
# File 'lib/ood_job/script.rb', line 49

def email_on_terminated
  @email_on_terminated
end

#error_pathPathname? (readonly)

Path to file specifying the error stream of the job


65
66
67
# File 'lib/ood_job/script.rb', line 65

def error_path
  @error_path
end

#input_pathPathname? (readonly)

Path to file specifying the input stream of the job


57
58
59
# File 'lib/ood_job/script.rb', line 57

def input_path
  @input_path
end

#job_environmentHash{String=>String}? (readonly)

Note:

These will override the remote host environment settings

Environment variables to be set on remote host when running job


32
33
34
# File 'lib/ood_job/script.rb', line 32

def job_environment
  @job_environment
end

#job_nameString? (readonly)

The name of the job


53
54
55
# File 'lib/ood_job/script.rb', line 53

def job_name
  @job_name
end

#join_filesBoolean? (readonly)

Whether the error stream should be intermixed with the output stream


69
70
71
# File 'lib/ood_job/script.rb', line 69

def join_files
  @join_files
end

#min_phys_memoryFixnum? (readonly)

The minmimum amount of physical memory in kilobyte that should be available for the job


86
87
88
# File 'lib/ood_job/script.rb', line 86

def min_phys_memory
  @min_phys_memory
end

#min_procsFixnum? (readonly)

The minimum number of procs requested per job


103
104
105
# File 'lib/ood_job/script.rb', line 103

def min_procs
  @min_procs
end

#nativeObject? (readonly)

Note:

Should not be used at all costs.

Object detailing any native specifications that are implementation specific


126
127
128
# File 'lib/ood_job/script.rb', line 126

def native
  @native
end

#nodesArray<String, NodeRequest>? (readonly)

Node or list of nodes detailing the specifications the job should run on

Examples:

Job to run on a list of defined nodes

my_job.nodes
#=> ["n0001", "n0002", "n0003"]

Job to run on 2 nodes with 12 procs per node

my_job.nodes
#=> [
#     #<OodJob::NodeRequest procs=12, properties={}>,
#     #<OodJob::NodeRequest procs=12, properties={}>
#   ]

Create job script that will run on 100 nodes with 20 procs per node

OodJob::Script.new(
  script: Pathname.new('/path/to/script'),
  nodes: [OodJob::NodeRequest.new(procs: 20)] * 100
)

121
122
123
# File 'lib/ood_job/script.rb', line 121

def nodes
  @nodes
end

#output_pathPathname? (readonly)

Path to file specifying the output stream of the job


61
62
63
# File 'lib/ood_job/script.rb', line 61

def output_path
  @output_path
end

#priorityFixnum? (readonly)

The scheduling priority for the job


81
82
83
# File 'lib/ood_job/script.rb', line 81

def priority
  @priority
end

#queue_nameString? (readonly)

Name of the queue the job should be submitted to


77
78
79
# File 'lib/ood_job/script.rb', line 77

def queue_name
  @queue_name
end

#rerunnableBoolean? (readonly)

Note:

This SHOULD NOT be used to let the application denote the checkpointability of a job

Whether job can safely be restarted by the resource manager, for example on node failure or some other re-scheduling event


27
28
29
# File 'lib/ood_job/script.rb', line 27

def rerunnable
  @rerunnable
end

#reservation_idString? (readonly)

Identifier of existing reservation to be associated with the job


73
74
75
# File 'lib/ood_job/script.rb', line 73

def reservation_id
  @reservation_id
end

#start_timeTime? (readonly)

The earliest time when the job may be eligible to run


90
91
92
# File 'lib/ood_job/script.rb', line 90

def start_time
  @start_time
end

#submit_as_holdBoolean? (readonly)

Whether job is held after submitted


20
21
22
# File 'lib/ood_job/script.rb', line 20

def submit_as_hold
  @submit_as_hold
end

#wall_timeFixnum? (readonly)

The maximum amount of real time during which the job can be running in seconds


95
96
97
# File 'lib/ood_job/script.rb', line 95

def wall_time
  @wall_time
end

#workdirPathname? (readonly)

Directory where the job is executed from


36
37
38
# File 'lib/ood_job/script.rb', line 36

def workdir
  @workdir
end

Instance Method Details

#==(other) ⇒ Boolean

The comparison operator


222
223
224
# File 'lib/ood_job/script.rb', line 222

def ==(other)
  to_h == other.to_h
end

#eql?(other) ⇒ Boolean

Whether objects are identical to each other


229
230
231
# File 'lib/ood_job/script.rb', line 229

def eql?(other)
  self.class == other.class && self == other
end

#hashFixnum

Generate a hash value for this object


235
236
237
# File 'lib/ood_job/script.rb', line 235

def hash
  [self.class, to_h].hash
end

#to_hHash

Convert object to hash


190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/ood_job/script.rb', line 190

def to_h
  {
    content:             content,
    args:                args,
    submit_as_hold:      submit_as_hold,
    rerunnable:          rerunnable,
    job_environment:     job_environment,
    workdir:             workdir,
    email:               email,
    email_on_started:    email_on_started,
    email_on_terminated: email_on_terminated,
    job_name:            job_name,
    input_path:          input_path,
    output_path:         output_path,
    error_path:          error_path,
    join_files:          join_files,
    reservation_id:      reservation_id,
    queue_name:          queue_name,
    priority:            priority,
    min_phys_memory:     min_phys_memory,
    start_time:          start_time,
    wall_time:           wall_time,
    accounting_id:       accounting_id,
    min_procs:           min_procs,
    nodes:               nodes,
    native:              native
  }
end