From 5e284192a891fba74d10c53e235ae81d679f7b5b Mon Sep 17 00:00:00 2001 From: Ashton South Date: Mon, 29 Jul 2024 09:34:29 -0400 Subject: [PATCH 1/6] turn job status into clickable badge --- .../app/views/projects/_job_details.turbo_stream.erb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb index d9d06b3ab2..30a299f103 100644 --- a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb +++ b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb @@ -5,8 +5,10 @@ From 99639f4fa54e3b6f668963374ab617a5666a185e Mon Sep 17 00:00:00 2001 From: Ashton South Date: Mon, 29 Jul 2024 15:45:00 -0400 Subject: [PATCH 2/6] add cards with job data --- .../app/helpers/active_jobs_helper.rb | 22 +----------- .../app/helpers/application_helper.rb | 36 +++++++++++++++++++ .../projects/_job_details.turbo_stream.erb | 20 +++++++++-- 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/apps/dashboard/app/helpers/active_jobs_helper.rb b/apps/dashboard/app/helpers/active_jobs_helper.rb index 69aea21553..36a166ddfb 100644 --- a/apps/dashboard/app/helpers/active_jobs_helper.rb +++ b/apps/dashboard/app/helpers/active_jobs_helper.rb @@ -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 - "#{label}".html_safe + "#{status_text(status)}".html_safe end def filters diff --git a/apps/dashboard/app/helpers/application_helper.rb b/apps/dashboard/app/helpers/application_helper.rb index 4773925aac..bb169ef07c 100644 --- a/apps/dashboard/app/helpers/application_helper.rb +++ b/apps/dashboard/app/helpers/application_helper.rb @@ -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 diff --git a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb index 30a299f103..da241e00e7 100644 --- a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb +++ b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb @@ -1,14 +1,30 @@ <%- id = "job_#{job.cluster}_#{job.id}" + data = { + :cluster => job.cluster, + :gpus => job.gpus + } -%> From 1ff41420fb21084c7f011d194c90967f4d89ae59 Mon Sep 17 00:00:00 2001 From: Ashton South Date: Mon, 29 Jul 2024 16:48:39 -0400 Subject: [PATCH 3/6] minor changes to current layout --- .../app/views/projects/_job_details.turbo_stream.erb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb index da241e00e7..79e524e3a1 100644 --- a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb +++ b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb @@ -2,8 +2,8 @@ <%- id = "job_#{job.cluster}_#{job.id}" data = { - :cluster => job.cluster, - :gpus => job.gpus + :Cluster => job.cluster, + :Gpus => job.gpus } -%> @@ -16,11 +16,11 @@
- - <% data.each do |k, v| %> +
+ <% data.each do |name, value| %> - - + + <% end %>
<%= k %><%= v %><%= name %><%= value %>
From 0850f1cd02fd1d41c21f11ddf338cf57965f04f9 Mon Sep 17 00:00:00 2001 From: Ashton South Date: Fri, 2 Aug 2024 09:47:54 -0400 Subject: [PATCH 4/6] add more job details --- apps/dashboard/app/helpers/projects_helper.rb | 49 +++++++++++++++++++ .../projects/_job_details.turbo_stream.erb | 22 ++++----- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/apps/dashboard/app/helpers/projects_helper.rb b/apps/dashboard/app/helpers/projects_helper.rb index c725ac7b8b..9e60580556 100644 --- a/apps/dashboard/app/helpers/projects_helper.rb +++ b/apps/dashboard/app/helpers/projects_helper.rb @@ -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 + when 'job_owner' + account_info['Job Owner'] = value + when 'accounting_id' + account_info['Accounting ID'] = value + when 'submission_time' + status_info['Submission Time'] = value + when 'dispatch_time' + status_info['Dispatch Time'] = value + when 'wallclock_time' + status_info['Time Running'] = value + when 'wallclock_limit' + status_info['Time Limit'] = value + when 'cpu_time' + status_info['CPU Time'] = value + when 'cluster' + job_info['Cluster'] = value + when 'queue_name' + job_info['Queue Name'] = value + when 'procs' + job_info['Procs'] = value + when 'allocated_nodes' + job_info['Allocated Nodes'] = value unless value.empty? + when 'gpus' + job_info['GPUs'] = value + when 'cpus' + job_info['CPUs'] = 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_info, status_info, job_info] + end end \ No newline at end of file diff --git a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb index 79e524e3a1..bf96c82ac9 100644 --- a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb +++ b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb @@ -1,10 +1,6 @@ <%- id = "job_#{job.cluster}_#{job.id}" - data = { - :Cluster => job.cluster, - :Gpus => job.gpus - } -%> @@ -16,14 +12,16 @@
- - <% data.each do |name, value| %> - - - - - <% end %> -
<%= name %><%= value %>
+ <% readable_job_data(job).each do |category| %> + + <% category.each do |name, value| %> + + + + + <% end %> +
<%= name %><%= value %>
+ <% end %>
From 4b14bd4804fec7aef3b7d7537c43d34e55653ecb Mon Sep 17 00:00:00 2001 From: Ashton South Date: Fri, 2 Aug 2024 14:49:56 -0400 Subject: [PATCH 5/6] change presentation of information --- apps/dashboard/app/helpers/projects_helper.rb | 18 +++++++++--------- .../projects/_job_details.turbo_stream.erb | 11 ++++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/apps/dashboard/app/helpers/projects_helper.rb b/apps/dashboard/app/helpers/projects_helper.rb index 9e60580556..3e4b5c8ac3 100644 --- a/apps/dashboard/app/helpers/projects_helper.rb +++ b/apps/dashboard/app/helpers/projects_helper.rb @@ -28,29 +28,25 @@ def readable_job_data(job) when 'job_owner' account_info['Job Owner'] = value when 'accounting_id' - account_info['Accounting ID'] = value + 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 Running'] = value + status_info['Time Used'] = value when 'wallclock_limit' - status_info['Time Limit'] = value - when 'cpu_time' - status_info['CPU Time'] = value + 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['Procs'] = value + job_info['CPUs'] = value when 'allocated_nodes' job_info['Allocated Nodes'] = value unless value.empty? when 'gpus' job_info['GPUs'] = value - when 'cpus' - job_info['CPUs'] = value when 'nodes' job_info['Nodes'] = value when 'min_memory' @@ -61,6 +57,10 @@ def readable_job_data(job) end end - [account_info, status_info, job_info] + { + 'Account Information': account_info, + 'Job Status': status_info, + 'Job Information': job_info + } end end \ No newline at end of file diff --git a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb index bf96c82ac9..86c7c0a0ad 100644 --- a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb +++ b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb @@ -11,17 +11,18 @@
-
- <% readable_job_data(job).each do |category| %> - +
+ <% readable_job_data(job).each do |category_name, category| %> +
+ <%= category_name %> <% category.each do |name, value| %> <% end %> -
<%= name %> <%= value %>
- <% end %> + <% end %> +
From f7b5f4b85eb25c73220b3a1dddab52da24150a51 Mon Sep 17 00:00:00 2001 From: Ashton South Date: Mon, 12 Aug 2024 15:52:22 -0400 Subject: [PATCH 6/6] move data to one table --- apps/dashboard/app/helpers/projects_helper.rb | 49 ------------------- apps/dashboard/app/models/hpc_job.rb | 4 ++ .../projects/_job_details.turbo_stream.erb | 19 +++---- 3 files changed, 12 insertions(+), 60 deletions(-) diff --git a/apps/dashboard/app/helpers/projects_helper.rb b/apps/dashboard/app/helpers/projects_helper.rb index 3e4b5c8ac3..c725ac7b8b 100644 --- a/apps/dashboard/app/helpers/projects_helper.rb +++ b/apps/dashboard/app/helpers/projects_helper.rb @@ -14,53 +14,4 @@ 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 - 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 \ No newline at end of file diff --git a/apps/dashboard/app/models/hpc_job.rb b/apps/dashboard/app/models/hpc_job.rb index 7ab2706e2d..2eb564a036 100644 --- a/apps/dashboard/app/models/hpc_job.rb +++ b/apps/dashboard/app/models/hpc_job.rb @@ -26,4 +26,8 @@ def to_h status: status.to_s, allocated_nodes: [] }).deep_stringify_keys end + + def to_human_display + to_h.transform_keys { |k| k.humanize }.compact_blank + end end diff --git a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb index 86c7c0a0ad..416cfdac3d 100644 --- a/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb +++ b/apps/dashboard/app/views/projects/_job_details.turbo_stream.erb @@ -5,22 +5,19 @@