Class: OodCore::Job::Script

Inherits:
Object
  • Object
show all
Defined in:
lib/ood_core/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, shell_path: nil, input_path: nil, output_path: nil, error_path: nil, reservation_id: nil, queue_name: nil, priority: nil, start_time: nil, wall_time: nil, accounting_id: nil, job_array_request: nil, qos: nil, gpus_per_node: nil, native: nil, copy_environment: nil, cores: nil, **_) ⇒ Script



151
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
187
188
# File 'lib/ood_core/job/script.rb', line 151

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, shell_path: nil, input_path: nil,
               output_path: nil, error_path: nil, reservation_id: nil,
               queue_name: nil, priority: nil, start_time: nil,
               wall_time: nil, accounting_id: nil, job_array_request: nil,
               qos: nil, gpus_per_node: nil, native: nil, copy_environment: nil,
               cores: 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

  @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
  @shell_path         = shell_path        && Pathname.new(shell_path.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
  @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
  @job_array_request  = job_array_request && job_array_request.to_s
  @qos                = qos               && qos.to_s
  @gpus_per_node      = gpus_per_node     && gpus_per_node.to_i
  @native             = native
  @copy_environment   = (copy_environment.nil?) ? nil : !! copy_environment
  @cores              = cores&.to_i
end

Instance Attribute Details

#accounting_idString? (readonly)

The attribute used for job accounting purposes



97
98
99
# File 'lib/ood_core/job/script.rb', line 97

def accounting_id
  @accounting_id
end

#argsArray<String>? (readonly)

Arguments supplied to script to be executed



18
19
20
# File 'lib/ood_core/job/script.rb', line 18

def args
  @args
end

#contentString (readonly)

Content of the script to be executed on the remote host



14
15
16
# File 'lib/ood_core/job/script.rb', line 14

def content
  @content
end

#copy_environmentBoolean (readonly) Also known as: copy_environment?

Flag whether the job should contain a copy of its calling environment



122
123
124
# File 'lib/ood_core/job/script.rb', line 122

def copy_environment
  @copy_environment
end

#coresInteger? (readonly)

The core request for this job



113
114
115
# File 'lib/ood_core/job/script.rb', line 113

def cores
  @cores
end

#emailArray<String>? (readonly)

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



43
44
45
# File 'lib/ood_core/job/script.rb', line 43

def email
  @email
end

#email_on_startedBoolean? (readonly)

Whether given email addresses should be notified when job starts



47
48
49
# File 'lib/ood_core/job/script.rb', line 47

def email_on_started
  @email_on_started
end

#email_on_terminatedBoolean? (readonly)

Whether given email addresses should be notified when job ends



51
52
53
# File 'lib/ood_core/job/script.rb', line 51

def email_on_terminated
  @email_on_terminated
end

#error_pathPathname? (readonly)

Path to file specifying the error stream of the job



71
72
73
# File 'lib/ood_core/job/script.rb', line 71

def error_path
  @error_path
end

#gpus_per_nodeInteger? (readonly)

The GPUs per node for the job



109
110
111
# File 'lib/ood_core/job/script.rb', line 109

def gpus_per_node
  @gpus_per_node
end

#input_pathPathname? (readonly)

Path to file specifying the input stream of the job



63
64
65
# File 'lib/ood_core/job/script.rb', line 63

def input_path
  @input_path
end

#job_array_requestString? (readonly)

The job array request, commonly in the format ‘$START-$STOP’



101
102
103
# File 'lib/ood_core/job/script.rb', line 101

def job_array_request
  @job_array_request
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



34
35
36
# File 'lib/ood_core/job/script.rb', line 34

def job_environment
  @job_environment
end

#job_nameString? (readonly)

The name of the job



55
56
57
# File 'lib/ood_core/job/script.rb', line 55

def job_name
  @job_name
end

#nativeObject? (readonly)

Note:

Should not be used at all costs.

Object detailing any native specifications that are implementation specific



118
119
120
# File 'lib/ood_core/job/script.rb', line 118

def native
  @native
end

#output_pathPathname? (readonly)

Path to file specifying the output stream of the job



67
68
69
# File 'lib/ood_core/job/script.rb', line 67

def output_path
  @output_path
end

#priorityInteger? (readonly)

The scheduling priority for the job



84
85
86
# File 'lib/ood_core/job/script.rb', line 84

def priority
  @priority
end

#qosString? (readonly)

The qos selected for the job



105
106
107
# File 'lib/ood_core/job/script.rb', line 105

def qos
  @qos
end

#queue_nameString? (readonly) Also known as: queue

Name of the queue the job should be submitted to



79
80
81
# File 'lib/ood_core/job/script.rb', line 79

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



29
30
31
# File 'lib/ood_core/job/script.rb', line 29

def rerunnable
  @rerunnable
end

#reservation_idString? (readonly)

Identifier of existing reservation to be associated with the job



75
76
77
# File 'lib/ood_core/job/script.rb', line 75

def reservation_id
  @reservation_id
end

#shell_pathPathname? (readonly)

Path to file specifying the login shell of the job



59
60
61
# File 'lib/ood_core/job/script.rb', line 59

def shell_path
  @shell_path
end

#start_timeTime? (readonly)

The earliest time when the job may be eligible to run



88
89
90
# File 'lib/ood_core/job/script.rb', line 88

def start_time
  @start_time
end

#submit_as_holdBoolean? (readonly)

Whether job is held after submitted



22
23
24
# File 'lib/ood_core/job/script.rb', line 22

def submit_as_hold
  @submit_as_hold
end

#wall_timeInteger? (readonly)

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



93
94
95
# File 'lib/ood_core/job/script.rb', line 93

def wall_time
  @wall_time
end

#workdirPathname? (readonly)

Directory where the job is executed from



38
39
40
# File 'lib/ood_core/job/script.rb', line 38

def workdir
  @workdir
end

Instance Method Details

#==(other) ⇒ Boolean

The comparison operator



226
227
228
# File 'lib/ood_core/job/script.rb', line 226

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

#eql?(other) ⇒ Boolean

Whether objects are identical to each other



233
234
235
# File 'lib/ood_core/job/script.rb', line 233

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

#hashInteger

Generate a hash value for this object



239
240
241
# File 'lib/ood_core/job/script.rb', line 239

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

#to_hHash

Convert object to hash



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
218
219
220
221
# File 'lib/ood_core/job/script.rb', line 192

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,
    shell_path:          shell_path,
    input_path:          input_path,
    output_path:         output_path,
    error_path:          error_path,
    reservation_id:      reservation_id,
    queue_name:          queue_name,
    priority:            priority,
    start_time:          start_time,
    wall_time:           wall_time,
    accounting_id:       accounting_id,
    job_array_request:   job_array_request,
    qos:                 qos,
    gpus_per_node:       gpus_per_node,
    native:              native,
    cores:               cores,
    copy_environment:    copy_environment,
  }
end