Class: OodCore::Job::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/ood_core/job/info.rb

Overview

An object that describes a submitted job.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, status:, allocated_nodes: [], submit_host: nil, job_name: nil, job_owner: nil, accounting_id: nil, procs: nil, queue_name: nil, wallclock_time: nil, wallclock_limit: nil, cpu_time: nil, submission_time: nil, dispatch_time: nil, native: nil, gpus: 0, tasks: [], total_memory: nil, **_) ⇒ Info

Returns a new instance of Info.

Parameters:

  • id (#to_s)

    job id

  • status (#to_sym)

    job state

  • allocated_nodes (Array<#to_h>) (defaults to: [])

    allocated nodes

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

    submit host

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

    job name

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

    job owner

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

    accounting id

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

    allocated total number of procs

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

    queue name

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

    wallclock time

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

    wallclock time limit

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

    cpu time

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

    submission time

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

    dispatch time

  • tasks (Array<Hash>) (defaults to: [])

    tasks e.g. { id: '12345.owens-batch', status: :running }

  • native (Object) (defaults to: nil)

    native info

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

    bytes of allocated memory

  • gpus (#to_i, 0) (defaults to: 0)

    allocated total number of gpus



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ood_core/job/info.rb', line 100

def initialize(id:, status:, allocated_nodes: [], submit_host: nil,
               job_name: nil, job_owner: nil, accounting_id: nil,
               procs: nil, queue_name: nil, wallclock_time: nil,
               wallclock_limit: nil, cpu_time: nil, submission_time: nil,
               dispatch_time: nil, native: nil, gpus: 0, tasks: [],
               total_memory: nil, **_)
  @id              = id.to_s
  @status          = Status.new(state: status.to_sym)
  @allocated_nodes = allocated_nodes.map { |n| NodeInfo.new(**n.to_h) }
  @submit_host     = submit_host     && submit_host.to_s
  @job_name        = job_name        && job_name.to_s
  @job_owner       = job_owner       && job_owner.to_s
  @accounting_id   = accounting_id   && accounting_id.to_s
  @procs           = procs           && procs.to_i
  @queue_name      = queue_name      && queue_name.to_s
  @wallclock_time  = wallclock_time  && wallclock_time.to_i
  @wallclock_limit = wallclock_limit && wallclock_limit.to_i
  @cpu_time        = cpu_time        && cpu_time.to_i
  @submission_time = submission_time && Time.at(submission_time.to_i)
  @dispatch_time   = dispatch_time   && Time.at(dispatch_time.to_i)
  @tasks = tasks.map {|task_status| Task.new(**task_status)}

  @status = job_array_aggregate_status unless @tasks.empty?

  @native          = native
  @total_memory    = total_memory    && total_memory.to_i
  @gpus            = gpus            && gpus.to_i
end

Instance Attribute Details

#accounting_idString? (readonly)

The account the job is charged against

Returns:

  • (String, nil)

    accounting id



33
34
35
# File 'lib/ood_core/job/info.rb', line 33

def accounting_id
  @accounting_id
end

#allocated_nodesArray<NodeInfo> (readonly)

Set of machines that is utilized for job execution

Returns:



17
18
19
# File 'lib/ood_core/job/info.rb', line 17

def allocated_nodes
  @allocated_nodes
end

#cpu_timeInteger? (readonly)

The accumulated CPU time in seconds

Returns:

  • (Integer, nil)

    cpu time



53
54
55
# File 'lib/ood_core/job/info.rb', line 53

def cpu_time
  @cpu_time
end

#dispatch_timeTime? (readonly)

The time the job first entered a "Started" state

Returns:

  • (Time, nil)

    dispatch time



61
62
63
# File 'lib/ood_core/job/info.rb', line 61

def dispatch_time
  @dispatch_time
end

#gpusInteger? (readonly)

Number of gpus allocated for job

Returns:

  • (Integer, nil)

    allocated total number of gpus



70
71
72
# File 'lib/ood_core/job/info.rb', line 70

def gpus
  @gpus
end

#idString (readonly)

The identifier of the job

Returns:

  • (String)

    job id



9
10
11
# File 'lib/ood_core/job/info.rb', line 9

def id
  @id
end

#job_nameString? (readonly)

Name of the job

Returns:

  • (String, nil)

    job name



25
26
27
# File 'lib/ood_core/job/info.rb', line 25

def job_name
  @job_name
end

#job_ownerString? (readonly)

Owner of job

Returns:

  • (String, nil)

    job owner



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

def job_owner
  @job_owner
end

#nativeObject (readonly)

Note:

Should not be used by generic apps

Native resource manager output for job info

Returns:

  • (Object)

    native info



66
67
68
# File 'lib/ood_core/job/info.rb', line 66

def native
  @native
end

#procsInteger? (readonly)

Number of procs allocated for job

Returns:

  • (Integer, nil)

    allocated total number of procs



37
38
39
# File 'lib/ood_core/job/info.rb', line 37

def procs
  @procs
end

#queue_nameString? (readonly)

Name of the queue in which the job was queued or started

Returns:

  • (String, nil)

    queue name



41
42
43
# File 'lib/ood_core/job/info.rb', line 41

def queue_name
  @queue_name
end

#statusStatus (readonly)

The status of the job

Returns:



13
14
15
# File 'lib/ood_core/job/info.rb', line 13

def status
  @status
end

#submission_timeTime? (readonly)

The time at which the job was submitted

Returns:

  • (Time, nil)

    submission time



57
58
59
# File 'lib/ood_core/job/info.rb', line 57

def submission_time
  @submission_time
end

#submit_hostString? (readonly)

Name of the submission host for this job

Returns:

  • (String, nil)

    submit host



21
22
23
# File 'lib/ood_core/job/info.rb', line 21

def submit_host
  @submit_host
end

#tasksArray<Task> (readonly)

Note:

only relevant for job arrays

List of job array child task statuses

Returns:

  • (Array<Task>)

    tasks



80
81
82
# File 'lib/ood_core/job/info.rb', line 80

def tasks
  @tasks
end

#total_memoryInteger? (readonly)

Note:

computed from the adapter, if supported

Total memory used by job in bytes

Returns:

  • (Integer, nil)

    total bytes used for job



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

def total_memory
  @total_memory
end

#wallclock_limitInteger? (readonly)

The total wall clock time limit in seconds

Returns:

  • (Integer, nil)

    wallclock time limit



49
50
51
# File 'lib/ood_core/job/info.rb', line 49

def wallclock_limit
  @wallclock_limit
end

#wallclock_timeInteger? (readonly)

The accumulated wall clock time in seconds

Returns:

  • (Integer, nil)

    wallclock time



45
46
47
# File 'lib/ood_core/job/info.rb', line 45

def wallclock_time
  @wallclock_time
end

Instance Method Details

#==(other) ⇒ Boolean

The comparison operator

Parameters:

  • other (#to_h)

    object to compare against

Returns:

  • (Boolean)

    whether objects are equivalent



176
177
178
# File 'lib/ood_core/job/info.rb', line 176

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

#build_child_info(task) ⇒ Info

Create a new Info for a child task

Returns:

  • (Info)

    merging the parent and the child task



131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/ood_core/job/info.rb', line 131

def build_child_info(task)
  parent_only_keys = [
    :allocated_nodes,
    :procs,
    :cpu_time,
    :dispatch_time,
    :native,
    :tasks
  ]

  new(**to_h.merge(task.to_h).delete_if{|k, v| parent_only_keys.include?(k)})
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



183
184
185
# File 'lib/ood_core/job/info.rb', line 183

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

#gpu?Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/ood_core/job/info.rb', line 169

def gpu?
  gpus.positive?
end

#hashInteger

Generate a hash value for this object

Returns:

  • (Integer)

    hash value of object



189
190
191
# File 'lib/ood_core/job/info.rb', line 189

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

#to_hHash

Convert object to hash

Returns:

  • (Hash)

    object as hash



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/ood_core/job/info.rb', line 146

def to_h
  {
    id:              id,
    status:          status,
    allocated_nodes: allocated_nodes,
    submit_host:     submit_host,
    job_name:        job_name,
    job_owner:       job_owner,
    accounting_id:   accounting_id,
    procs:           procs,
    queue_name:      queue_name,
    wallclock_time:  wallclock_time,
    wallclock_limit: wallclock_limit,
    cpu_time:        cpu_time,
    submission_time: submission_time,
    dispatch_time:   dispatch_time,
    native:          native,
    total_memory:    total_memory,
    gpus:            gpus,
    tasks: tasks
  }
end