class OodCore::Job::Info

An object that describes a submitted job

Attributes

accounting_id[R]

The account the job is charged against @return [String, nil] accounting id

allocated_nodes[R]

Set of machines that is utilized for job execution @return [Array<NodeInfo>] allocated nodes

cpu_time[R]

The accumulated CPU time in seconds @return [Integer, nil] cpu time

dispatch_time[R]

The time the job first entered a “Started” state @return [Time, nil] dispatch time

id[R]

The identifier of the job @return [String] job id

job_name[R]

Name of the job @return [String, nil] job name

job_owner[R]

Owner of job @return [String, nil] job owner

native[R]

Native resource manager output for job info @note Should not be used by generic apps @return [Object] native info

procs[R]

Number of procs allocated for job @return [Integer, nil] allocated total number of procs

queue_name[R]

Name of the queue in which the job was queued or started @return [String, nil] queue name

status[R]

The status of the job @return [Status] job state

submission_time[R]

The time at which the job was submitted @return [Time, nil] submission time

submit_host[R]

Name of the submission host for this job @return [String, nil] submit host

tasks[R]

List of job array child task statuses @note only relevant for job arrays @return [Array<Task>] tasks

wallclock_limit[R]

The total wall clock time limit in seconds @return [Integer, nil] wallclock time limit

wallclock_time[R]

The accumulated wall clock time in seconds @return [Integer, nil] wallclock time

Public Class Methods

new(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, tasks: [], **_) click to toggle source

@param id [#to_s] job id @param status [#to_sym] job state @param allocated_nodes [Array<#to_h>] allocated nodes @param submit_host [#to_s, nil] submit host @param job_name [#to_s, nil] job name @param job_owner [#to_s, nil] job owner @param accounting_id [#to_s, nil] accounting id @param procs [#to_i, nil] allocated total number of procs @param queue_name [#to_s, nil] queue name @param wallclock_time [#to_i, nil] wallclock time @param wallclock_limit [#to_i, nil] wallclock time limit @param cpu_time [#to_i, nil] cpu time @param submission_time [#to_i, nil] submission time @param dispatch_time [#to_i, nil] dispatch time @param tasks [Array<Hash>] tasks e.g. { id: '12345.owens-batch', status: :running } @param native [Object] native info

# File lib/ood_core/job/info.rb, line 89
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, tasks: [],
               **_)
  @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
end

Public Instance Methods

==(other) click to toggle source

The comparison operator @param other [#to_h] object to compare against @return [Boolean] whether objects are equivalent

# File lib/ood_core/job/info.rb, line 157
def ==(other)
  to_h == other.to_h
end
build_child_info(task) click to toggle source

Create a new Info for a child task @return [Info] merging the parent and the child task

# File lib/ood_core/job/info.rb, line 118
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) click to toggle source

Whether objects are identical to each other @param other [#to_h] object to compare against @return [Boolean] whether objects are identical

# File lib/ood_core/job/info.rb, line 164
def eql?(other)
  self.class == other.class && self == other
end
hash() click to toggle source

Generate a hash value for this object @return [Integer] hash value of object

# File lib/ood_core/job/info.rb, line 170
def hash
  [self.class, to_h].hash
end
to_h() click to toggle source

Convert object to hash @return [Hash] object as hash

# File lib/ood_core/job/info.rb, line 133
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,
    tasks: tasks
  }
end

Private Instance Methods

job_array_aggregate_status() click to toggle source

Generate an aggregate status from child tasks @return [OodCore::Job::Status]

# File lib/ood_core/job/info.rb, line 178
def job_array_aggregate_status
  @tasks.map { |task_status| task_status.status }.max
end