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

Returns a new instance of Script

Parameters:

  • content (#to_s)

    the script content

  • args (Array<#to_s>, nil)

    arguments supplied to script

  • submit_as_hold (Boolean, nil)

    whether job is held after submit

  • rerunnable (Boolean, nil)

    whether job can be restarted

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

    environment variables

  • workdir (#to_s, nil)

    working directory

  • email (#to_s, Array<#to_s>, nil)

    list of emails

  • email_on_started (Boolean, nil)

    whether email when job starts

  • email_on_terminated (Boolean, nil)

    whether email when job ends

  • job_name (#to_s, nil)

    name of job

  • shell_path (#to_s, nil)

    file path specifying login shell

  • error_path (#to_s, nil)

    file path specifying error stream

  • input_path (#to_s, nil)

    file path specifying input stream

  • output_path (#to_s, nil)

    file path specifying output stream

  • error_path (#to_s, nil)

    file path specifying error stream

  • reservation_id (#to_s, nil)

    reservation id

  • queue_name (#to_s, nil)

    queue name

  • priority (#to_i, nil)

    scheduling priority

  • start_time (#to_i, nil)

    eligible start time

  • wall_time (#to_i, nil)

    max real time

  • accounting_id (#to_s, nil)

    accounting id

  • native (Object, nil)

    native specifications



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/ood_core/job/script.rb', line 129

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, 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

  @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
  @native             = native
end

Instance Attribute Details

#accounting_idString? (readonly)

The attribute used for job accounting purposes

Returns:

  • (String, nil)

    accounting id



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

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

#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

#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



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

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



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

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



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

def priority
  @priority
end

#queue_nameString? (readonly)

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



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

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



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

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



194
195
196
# File 'lib/ood_core/job/script.rb', line 194

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



201
202
203
# File 'lib/ood_core/job/script.rb', line 201

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

#hashInteger

Generate a hash value for this object

Returns:

  • (Integer)

    hash value of object



207
208
209
# File 'lib/ood_core/job/script.rb', line 207

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

#to_hHash

Convert object to hash

Returns:

  • (Hash)

    object as hash



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

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