Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added uses_gpu flag to Job Info class #753

Merged
merged 20 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ood_core/job/adapters/slurm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,8 @@ def parse_job_info(v)
cpu_time: nil,
submission_time: v[:submit_time] ? Time.parse(v[:submit_time]) : nil,
dispatch_time: (v[:start_time].nil? || v[:start_time] == "N/A") ? nil : Time.parse(v[:start_time]),
native: v
native: v,
gpus: v[:gres]&.include?("gpu") ? 1 : 0
lukew3 marked this conversation as resolved.
Show resolved Hide resolved
)
end

Expand Down
18 changes: 12 additions & 6 deletions lib/ood_core/job/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class Info
# @return [Object] native info
attr_reader :native

# If the job is using/requesting a gpu
# @return [Boolean] job uses gpu
attr_reader :uses_gpu
# Number of gpus allocated for job
# @return [Integer, nil] allocated total number of gpus
attr_reader :gpus

# List of job array child task statuses
# @note only relevant for job arrays
Expand All @@ -90,11 +90,12 @@ class Info
# @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
# @param gpus [#to_i, nil] allocated total number of gpus
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, uses_gpu: nil, tasks: [],
dispatch_time: nil, native: nil, gpus: nil, tasks: [],
**_)
@id = id.to_s
@status = Status.new(state: status.to_sym)
Expand All @@ -115,7 +116,7 @@ def initialize(id:, status:, allocated_nodes: [], submit_host: nil,
@status = job_array_aggregate_status unless @tasks.empty?

@native = native
@uses_gpu = uses_gpu || native&.dig(:gres)&.include?("gpu") || false
@gpus = gpus && gpus.to_i
end

# Create a new Info for a child task
Expand Down Expand Up @@ -152,11 +153,16 @@ def to_h
submission_time: submission_time,
dispatch_time: dispatch_time,
native: native,
uses_gpu: uses_gpu,
gpus: gpus,
tasks: tasks
}
end

def gpu?
gpus.positive?
#native&.dig(:gres)&.include?("gpu") || false
end

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