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

More job details in pm #3700

Merged
merged 7 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
22 changes: 1 addition & 21 deletions apps/dashboard/app/helpers/active_jobs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,7 @@ def has_grafana(host)
end

def status_label(status)
case status
when "completed"
label = "Completed"
labelclass = "bg-success"
when "running"
label = "Running"
labelclass = "bg-primary"
when "queued"
label = "Queued"
labelclass = "bg-info"
when "queued_held"
label = "Hold"
labelclass = "bg-warning"
when "suspended"
label = "Suspend"
labelclass = "bg-warning"
else
label = "Undetermined"
labelclass = "bg-secondary"
end
"<span class='badge #{labelclass}'>#{label}</span>".html_safe
"<span class='badge #{status_class(status)}'>#{status_text(status)}</span>".html_safe
end

def filters
Expand Down
36 changes: 36 additions & 0 deletions apps/dashboard/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,40 @@ def custom_javascript_paths
{ src: File.join(@user_configuration.public_url, js_file_src), type: js_file_type }
end.compact
end

# Assigns text corresponding to a job status
def status_text(status)
case status
when 'completed'
'Completed'
when 'running'
'Running'
when 'queued'
'Queued'
when 'qued_held'
'Hold'
when 'suspended'
'Suspend'
else
'Undetermined'
end
end

# Assigns a bootstrap class corresponding to the status of a job
def status_class(status)
case status
when 'completed'
'bg-success'
when 'running'
'bg-primary'
when 'queued'
'bg-info'
when 'queued_held'
'bg-warning'
when 'suspended'
'bg-warning'
else
'bg-secondary'
end
end
end
49 changes: 49 additions & 0 deletions apps/dashboard/app/helpers/projects_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,53 @@ def render_readme(readme_location)
simple_format(file_content)
end
end

# Organizes job information in a manner that is easily displayed
def readable_job_data(job)
account_info = {}
status_info = {}
job_info = {}
job.to_h.each do |key, value|
unless value.nil?
case key
when 'job_name'
account_info['Job Name'] = value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With just 1 table, this should simplify a lot. But in any case, I'm not in love with the giant case statement. Maybe try a lookup table to map the key job_name to the new key Job Name. You may even get by with a simple map to key.humanize.

Also I'd say put this somewhere as a member of the HpcJob class so we can just do job.to_human_display or something similar.

when 'job_owner'
account_info['Job Owner'] = value
when 'accounting_id'
account_info['Account'] = value
when 'submission_time'
status_info['Submission Time'] = value
when 'dispatch_time'
status_info['Dispatch Time'] = value
when 'wallclock_time'
status_info['Time Used'] = value
when 'wallclock_limit'
status_info['Time Remaining'] = value - job.wallclock_time
when 'cluster'
job_info['Cluster'] = value
when 'queue_name'
job_info['Queue Name'] = value
when 'procs'
job_info['CPUs'] = value
when 'allocated_nodes'
job_info['Allocated Nodes'] = value unless value.empty?
when 'gpus'
job_info['GPUs'] = value
when 'nodes'
job_info['Nodes'] = value
when 'min_memory'
job_info['Minimum Memory'] = value
when 'tasks'
job_info['Tasks'] = value unless value.empty?
end
end
end

{
'Account Information': account_info,
'Job Status': status_info,
'Job Information': job_info
}
end
end
21 changes: 19 additions & 2 deletions apps/dashboard/app/views/projects/_job_details.turbo_stream.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,25 @@

<turbo-stream action="replace" target="<%= id %>">
<template>
<div>
<%= job.id %> is currently <%= job.status.to_s %>.
<button class="badge <%= status_class(job.status.to_s) %> rounded-pill border-0 btn" type="button" data-bs-toggle="collapse" data-bs-target="#<%= id %>Data">
<span>
<%= job.id %> <%= status_text(job.status.to_s) %>
</span>
</button>
<div class="collapse" id="<%= id %>Data">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep html ids snake_case.

<div class="card card-body">
<% readable_job_data(job).each do |category_name, category| %>
<table class="table table-bordered table-sm m-0 mb-2">
<thead><%= category_name %></thead>
<% category.each do |name, value| %>
<tr>
<td><strong><%= name %></strong></td>
<td><%= value %></td>
</tr>
<% end %>
<% end %>
</table>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - I think I've got this now. I think this should just be 1 table instead of 3. I think that'll simplify the computation for this object as well.

</div>
</div>
</template>
</turbo-stream>
Loading