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, **_) ⇒ Script

Returns a new instance of Script.

Parameters:

  • content (#to_s)

    the script content

  • args (Array<#to_s>, nil) (defaults to: nil)

    arguments supplied to script

  • submit_as_hold (Boolean, nil) (defaults to: nil)

    whether job is held after submit

  • rerunnable (Boolean, nil) (defaults to: nil)

    whether job can be restarted

  • job_environment (Hash{#to_s => #to_s}, nil) (defaults to: nil)

    environment variables

  • workdir (#to_s, nil) (defaults to: nil)

    working directory

  • email (#to_s, Array<#to_s>, nil) (defaults to: nil)

    list of emails

  • email_on_started (Boolean, nil) (defaults to: nil)

    whether email when job starts

  • email_on_terminated (Boolean, nil) (defaults to: nil)

    whether email when job ends

  • job_name (#to_s, nil) (defaults to: nil)

    name of job

  • shell_path (#to_s, nil) (defaults to: nil)

    file path specifying login shell

  • error_path (#to_s, nil) (defaults to: nil)

    file path specifying error stream

  • input_path (#to_s, nil) (defaults to: nil)

    file path specifying input stream

  • output_path (#to_s, nil) (defaults to: nil)

    file path specifying output stream

  • error_path (#to_s, nil) (defaults to: nil)

    file path specifying error stream

  • reservation_id (#to_s, nil) (defaults to: nil)

    reservation id

  • queue_name (#to_s, nil) (defaults to: nil)

    queue name

  • priority (#to_i, nil) (defaults to: nil)

    scheduling priority

  • start_time (#to_i, nil) (defaults to: nil)

    eligible start time

  • wall_time (#to_i, nil) (defaults to: nil)

    max real time

  • accounting_id (#to_s, nil) (defaults to: nil)

    accounting id

  • job_array_request (#to_s, nil) (defaults to: nil)

    job array request

  • qos (#to_s, nil) (defaults to: nil)

    qos

  • gpus_per_node (#to_i, nil) (defaults to: nil)

    gpus per node

  • native (Object, nil) (defaults to: nil)

    native specifications

  • copy_environment (Boolean, nil) (defaults to: nil)

    copy the environment



147
148
149
150
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
# File 'lib/ood_core/job/script.rb', line 147

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, **_)
  @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
end

Instance Attribute Details

#accounting_idString? (readonly)

The attribute used for job accounting purposes

Returns:

  • (String, nil)

    accounting id



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

Returns:

  • (Array<String>, nil)

    arguments supplied to script



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

Returns:

  • (String)

    the script content



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

Returns:

  • (Boolean)

    copy environment



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

def copy_environment
  @copy_environment
end

#emailArray<String>? (readonly)

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

Returns:

  • (Array<String>, nil)

    list of emails



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

Returns:

  • (Boolean, nil)

    whether email 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

Returns:

  • (Boolean, nil)

    whether email 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

Returns:

  • (Pathname, nil)

    file path specifying error stream



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

Returns:

  • (Integer, nil)

    gpus per node



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

Returns:

  • (Pathname, nil)

    file path specifying input stream



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’

Returns:

  • (String, nil)

    job array request



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

Returns:

  • (Hash{String=>String}, nil)

    environment variables



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

Returns:

  • (String, nil)

    name of 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

Returns:

  • (Object, nil)

    native specifications



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

def native
  @native
end

#output_pathPathname? (readonly)

Path to file specifying the output stream of the job

Returns:

  • (Pathname, nil)

    file path specifying output stream



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

Returns:

  • (Integer, nil)

    scheduling priority



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

def priority
  @priority
end

#qosString? (readonly)

The qos selected for the job

Returns:

  • (String, nil)

    qos



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

Returns:

  • (String, nil)

    queue name



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

Returns:

  • (Boolean, nil)

    whether job can be restarted



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

Returns:

  • (String, nil)

    reservation id



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

Returns:

  • (Pathname, nil)

    file path specifying login shell



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

Returns:

  • (Time, nil)

    eligible start time



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

Returns:

  • (Boolean, nil)

    whether job is held after submit



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

Returns:

  • (Integer, nil)

    max real time



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

Returns:

  • (Pathname, nil)

    working directory



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

def workdir
  @workdir
end

Instance Method Details

#==(other) ⇒ Boolean

The comparison operator

Parameters:

  • other (#to_h)

    object to compare against

Returns:

  • (Boolean)

    whether objects are equivalent



219
220
221
# File 'lib/ood_core/job/script.rb', line 219

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

#eql?(other) ⇒ Boolean

Whether objects are identical to each other

Parameters:

  • other (#to_h)

    object to compare against

Returns:

  • (Boolean)

    whether objects are identical



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

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

#hashInteger

Generate a hash value for this object

Returns:

  • (Integer)

    hash value of object



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

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

#to_hHash

Convert object to hash

Returns:

  • (Hash)

    object as hash



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

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,
    copy_environment:    copy_environment
  }
end