From 10b696cb5bcb4f08e944694fc3cc66ccbecdde92 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Fri, 23 Aug 2024 16:11:45 -0400 Subject: [PATCH 1/4] allow auto_job_name to be fixed --- .../smart_attributes/attributes/auto_job_name.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_job_name.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_job_name.rb index d03760c444..893b52c80d 100644 --- a/apps/dashboard/app/lib/smart_attributes/attributes/auto_job_name.rb +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_job_name.rb @@ -2,7 +2,6 @@ module SmartAttributes class AttributeFactory - # Build this attribute object. Must specify a valid directory in opts # # @param opts [Hash] attribute's options @@ -18,8 +17,7 @@ class AutoJobName < Attribute # Defaults to ondemand/[dev,sys]/projects # @return [String] attribute value def value - env = Rails.env.production? ? 'sys' : 'dev' - opts[:value] || "ondemand/#{env}/projects" + job_name(opts[:value] || 'Project Manager Job') end def widget @@ -36,6 +34,15 @@ def label(*) def submit(*) { script: { job_name: value } } end + + def job_name(name) + [ + ENV['OOD_PORTAL'], # the OOD portal id + ENV['RAILS_RELATIVE_URL_ROOT'].to_s.sub(%r{^/[^/]+/}, ''), # the OOD app + 'project-manager', + name # the user supplied job name + ].reject(&:blank?).join('/') + end end end end From 7e8139f56c8205c74fcf277ba921e1c2b21279b2 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Fri, 23 Aug 2024 16:12:53 -0400 Subject: [PATCH 2/4] add a TODO note here --- .../app/lib/smart_attributes/attributes/auto_job_name.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_job_name.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_job_name.rb index 893b52c80d..0761ec7a18 100644 --- a/apps/dashboard/app/lib/smart_attributes/attributes/auto_job_name.rb +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_job_name.rb @@ -35,6 +35,7 @@ def submit(*) { script: { job_name: value } } end + # TODO: need to sanitize the job name for some schedulers def job_name(name) [ ENV['OOD_PORTAL'], # the OOD portal id From 8b5a2ed0761c86f9fc80eabb050188b1462ffd38 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Mon, 26 Aug 2024 09:47:32 -0400 Subject: [PATCH 3/4] add the param to the controller allowlist --- apps/dashboard/app/controllers/launchers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dashboard/app/controllers/launchers_controller.rb b/apps/dashboard/app/controllers/launchers_controller.rb index 519b7c7829..fe1b86a053 100644 --- a/apps/dashboard/app/controllers/launchers_controller.rb +++ b/apps/dashboard/app/controllers/launchers_controller.rb @@ -13,7 +13,7 @@ class LaunchersController < ApplicationController :auto_batch_clusters, :auto_batch_clusters_exclude, :auto_batch_clusters_fixed, :bc_num_slots, :bc_num_slots_fixed, :bc_num_slots_min, :bc_num_slots_max, :bc_num_hours, :bc_num_hours_fixed, :bc_num_hours_min, :bc_num_hours_max, - :auto_job_name + :auto_job_name, :auto_job_name_fixed ].freeze def new From 8cb41b980d2066d1bed80e6fbfc0684ee4476973 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Mon, 26 Aug 2024 10:46:20 -0400 Subject: [PATCH 4/4] fix test --- apps/dashboard/test/system/project_manager_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dashboard/test/system/project_manager_test.rb b/apps/dashboard/test/system/project_manager_test.rb index f6fe41821c..ee78c9f499 100644 --- a/apps/dashboard/test/system/project_manager_test.rb +++ b/apps/dashboard/test/system/project_manager_test.rb @@ -429,7 +429,7 @@ def add_auto_environment_variable(project_id, script_id, save: true) Open3 .stubs(:capture3) - .with({}, 'sbatch', '-J', 'my cool job name', '-A', 'pas2051', '--export', + .with({}, 'sbatch', '-J', 'project-manager/my cool job name', '-A', 'pas2051', '--export', 'NONE', '--parsable', '-M', 'owens', stdin_data: "hostname\n") .returns(['job-id-123', '', exit_success])