From b34009930a78cc3d8aeb38a9827c3a2b52d915e5 Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Tue, 22 Oct 2024 09:35:59 -0400 Subject: [PATCH 01/17] Add auto_output_directory. --- apps/dashboard/app/lib/smart_attributes.rb | 1 + .../attributes/auto_output_directory.rb | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb diff --git a/apps/dashboard/app/lib/smart_attributes.rb b/apps/dashboard/app/lib/smart_attributes.rb index 285a0c4aa2..52b0fcc937 100644 --- a/apps/dashboard/app/lib/smart_attributes.rb +++ b/apps/dashboard/app/lib/smart_attributes.rb @@ -10,6 +10,7 @@ module SmartAttributes require 'smart_attributes/attributes/auto_groups' require 'smart_attributes/attributes/auto_job_name' require 'smart_attributes/attributes/auto_modules' + require 'smart_attributes/attributes/auto_output_directory' require 'smart_attributes/attributes/auto_primary_group' require 'smart_attributes/attributes/auto_queues' require 'smart_attributes/attributes/auto_qos' diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb new file mode 100644 index 0000000000..7ddc8e6de7 --- /dev/null +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb @@ -0,0 +1,54 @@ +module SmartAttributes + class AttributeFactory + + # Build this attribute object. Must specify a valid directory in opts + # + # @param opts [Hash] attribute's options + # @return [Attributes::AutoOutputDirectory] the attribute object + def self.build_auto_output_directory(opts = {}) + + end + def self.default_directory_value(default) + + end + end + + module Attributes + class AutoOutputDirectory < Attribute + # Value of auto_output_directory attribute + # Defaults to first script path in the project + # @return [String] attribute value + def value + return nil if !opts[:value] && opts[:options].empty? + + (opts[:value] || opts[:options].first.last).to_s + end + + def widget + 'select' + end + + def label(*) + (opts[:label] || 'Script').to_s + end + + # Submission hash describing how to submit this attribute + # @param fmt [String, nil] formatting of hash + # @return [Hash] submission hash + def submit(*) + content = File.read(value) + { script: { content: content } } + end + + # Hash of both field options and html options + # @return [Hash] key value pairs are field and html options + def all_options(fmt: nil) + super(fmt: fmt).merge({ directory: directory }) + end + + def directory + opts[:directory] + end + end + end +end From a4423c853e25ee58138bdc9f2bf15f5dae07a416 Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Thu, 24 Oct 2024 11:56:01 -0400 Subject: [PATCH 02/17] Create auto_output_directory in AttributeFactory --- .../lib/smart_attributes/attributes/auto_output_directory.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb index 7ddc8e6de7..f91ffe8deb 100644 --- a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb @@ -6,7 +6,7 @@ class AttributeFactory # @param opts [Hash] attribute's options # @return [Attributes::AutoOutputDirectory] the attribute object def self.build_auto_output_directory(opts = {}) - + Attributes::AutoOutputDirectory.new('auto_output_directory', opts) end def self.default_directory_value(default) From 4742c5d4c70fc6a5488bcfeade2de27017188796 Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Mon, 28 Oct 2024 09:37:01 -0400 Subject: [PATCH 03/17] Add auto_output_directory to edit.js files. --- .../app/controllers/launchers_controller.rb | 3 +- .../dashboard/app/helpers/launchers_helper.rb | 4 +++ .../dashboard/app/javascript/launcher_edit.js | 4 +++ .../attributes/auto_output_directory.rb | 32 ++++++++----------- .../app/views/launchers/edit.html.erb | 6 +++- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/apps/dashboard/app/controllers/launchers_controller.rb b/apps/dashboard/app/controllers/launchers_controller.rb index 65d8b25312..99bb53d67c 100644 --- a/apps/dashboard/app/controllers/launchers_controller.rb +++ b/apps/dashboard/app/controllers/launchers_controller.rb @@ -14,7 +14,8 @@ 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_fixed + :auto_job_name, :auto_job_name_fixed, + :auto_output_directory, :auto_output_directory_fixed, :auto_output_directory_exclude ].freeze def new diff --git a/apps/dashboard/app/helpers/launchers_helper.rb b/apps/dashboard/app/helpers/launchers_helper.rb index 4ee86e1e6e..f3b5817380 100644 --- a/apps/dashboard/app/helpers/launchers_helper.rb +++ b/apps/dashboard/app/helpers/launchers_helper.rb @@ -70,6 +70,10 @@ def auto_cores_template create_editable_widget(script_form_double, attrib) end + def auto_output_directory_template + attrib = SmartAttributes::AttributeFactory.build_auto_output_directory + create_editable_widget(script_form_double, attrib) + end # We need a form builder to build the template divs. These are # templates so that they are not a part of the _actual_ form (yet). # Otherwise you'd have required fields that you cannot actually edit diff --git a/apps/dashboard/app/javascript/launcher_edit.js b/apps/dashboard/app/javascript/launcher_edit.js index d9c2f3c49e..b0b6ff24b0 100644 --- a/apps/dashboard/app/javascript/launcher_edit.js +++ b/apps/dashboard/app/javascript/launcher_edit.js @@ -19,6 +19,10 @@ const newFieldData = { label: "Job Name", help: "The name the job will have." }, + auto_output_directory: { + label: "Log Output Directory", + help: "The destination of the job's log output." + }, bc_num_slots: { label: "Nodes", help: "How many nodes the job will run on." diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb index f91ffe8deb..56e6d41374 100644 --- a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb @@ -1,6 +1,7 @@ +# frozen_string_literal: true + module SmartAttributes class AttributeFactory - # Build this attribute object. Must specify a valid directory in opts # # @param opts [Hash] attribute's options @@ -8,9 +9,6 @@ class AttributeFactory def self.build_auto_output_directory(opts = {}) Attributes::AutoOutputDirectory.new('auto_output_directory', opts) end - def self.default_directory_value(default) - - end end module Attributes @@ -19,35 +17,31 @@ class AutoOutputDirectory < Attribute # Defaults to first script path in the project # @return [String] attribute value def value - return nil if !opts[:value] && opts[:options].empty? - - (opts[:value] || opts[:options].first.last).to_s + directory_name(opts[:value] || 'Default Output Directory') end def widget - 'select' + 'text_field' end def label(*) - (opts[:label] || 'Script').to_s + (opts[:label] || 'Output Directory').to_s end # Submission hash describing how to submit this attribute # @param fmt [String, nil] formatting of hash # @return [Hash] submission hash def submit(*) - content = File.read(value) - { script: { content: content } } - end - - # Hash of both field options and html options - # @return [Hash] key value pairs are field and html options - def all_options(fmt: nil) - super(fmt: fmt).merge({ directory: directory }) + { script: { directory_name: value } } end - def directory - opts[:directory] + def directory_name(dir) + [ + ENV['OOD_PORTAL'], # the OOD portal id + ENV['RAILS_RELATIVE_URL_ROOT'].to_s.sub(%r{^/[^/]+/}, ''), # the OOD app + 'project-manager', + dir # the user supplied directory name + ].reject(&:blank?).join('/') end end end diff --git a/apps/dashboard/app/views/launchers/edit.html.erb b/apps/dashboard/app/views/launchers/edit.html.erb index 9f222c8ccf..66e013d997 100644 --- a/apps/dashboard/app/views/launchers/edit.html.erb +++ b/apps/dashboard/app/views/launchers/edit.html.erb @@ -43,4 +43,8 @@ \ No newline at end of file + + + From bc646ef58fdf089eaafee1e8ac18b2b3a812cf04 Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Mon, 28 Oct 2024 12:36:51 -0400 Subject: [PATCH 04/17] submit output_path and error_path in auto_output_directory. --- .../attributes/auto_output_directory.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb index 56e6d41374..24fc478321 100644 --- a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb @@ -16,8 +16,12 @@ class AutoOutputDirectory < Attribute # Value of auto_output_directory attribute # Defaults to first script path in the project # @return [String] attribute value - def value - directory_name(opts[:value] || 'Default Output Directory') + def error_path_value + "#{opts[:value]}/%j-output.log" || 'Default Output Directory' + end + + def output_path_value + "#{opts[:value]}/%j-error.log" || 'Default Output Directory' end def widget @@ -32,17 +36,9 @@ def label(*) # @param fmt [String, nil] formatting of hash # @return [Hash] submission hash def submit(*) - { script: { directory_name: value } } + { script: { output_path: output_path_value, error_path: error_path_value } } end - def directory_name(dir) - [ - ENV['OOD_PORTAL'], # the OOD portal id - ENV['RAILS_RELATIVE_URL_ROOT'].to_s.sub(%r{^/[^/]+/}, ''), # the OOD app - 'project-manager', - dir # the user supplied directory name - ].reject(&:blank?).join('/') - end end end end From 426534844e40d0d4444fcd811d01051d8e8e840c Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Mon, 28 Oct 2024 17:23:58 -0400 Subject: [PATCH 05/17] Add tests. --- .../attributes/auto_output_directory.rb | 23 +++++--- .../auto_output_directory_test.rb | 32 ++++++++++++ .../test/system/project_manager_test.rb | 52 ++++++++++++++++++- 3 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb index 24fc478321..1c19bf8e1c 100644 --- a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb @@ -16,12 +16,8 @@ class AutoOutputDirectory < Attribute # Value of auto_output_directory attribute # Defaults to first script path in the project # @return [String] attribute value - def error_path_value - "#{opts[:value]}/%j-output.log" || 'Default Output Directory' - end - - def output_path_value - "#{opts[:value]}/%j-error.log" || 'Default Output Directory' + def value + opts[:value] || 'Default Output Directory' end def widget @@ -32,13 +28,26 @@ def label(*) (opts[:label] || 'Output Directory').to_s end + def output_directory_hash + { output_path: output_path_value, error_path: error_path_value } + end + # Submission hash describing how to submit this attribute # @param fmt [String, nil] formatting of hash # @return [Hash] submission hash def submit(*) - { script: { output_path: output_path_value, error_path: error_path_value } } + opts[:value] ? { script: output_directory_hash } : nil end + private + + def error_path_value + "#{opts[:value]}/%j-error.log" + end + + def output_path_value + "#{opts[:value]}/%j-output.log" + end end end end diff --git a/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb b/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb new file mode 100644 index 0000000000..e4b1cbc103 --- /dev/null +++ b/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'test_helper' +require 'smart_attributes' + +module SmartAttributes + class AutoOutputDirectoryTest < ActiveSupport::TestCase + def setup + stub_clusters + stub_user + stub_sacctmgr + end + + def dynamic_env + { + OOD_BC_DYNAMIC_JS: 'true' + } + end + + test 'correctly sets the value' do + with_modified_env(dynamic_env) do + options = { + value: 'output_extravaganza', + label: 'Output Directory' + } + attribute = SmartAttributes::AttributeFactory.build('auto_output_directory', options) + + assert_equal('output_extravaganza', attribute.value.to_s) + end + end + end +end diff --git a/apps/dashboard/test/system/project_manager_test.rb b/apps/dashboard/test/system/project_manager_test.rb index aadbf3d6b2..7cef744bae 100644 --- a/apps/dashboard/test/system/project_manager_test.rb +++ b/apps/dashboard/test/system/project_manager_test.rb @@ -456,6 +456,55 @@ def add_auto_environment_variable(project_id, script_id, save: true) end end + # super similar to test above, only it adds auto_output_directory + test 'submitting a script with output directory' do + Dir.mktmpdir do |dir| + project_id = setup_project(dir) + script_id = setup_script(project_id) + project_dir = File.join(dir, 'projects', project_id) + ondemand_dir = File.join(project_dir, '.ondemand') + add_account(project_id, script_id, save: false) + + click_on('Add new option') + select('Log Output Directory', from: 'add_new_field_select') + click_on(I18n.t('dashboard.add')) + fill_in('launcher_auto_output_directory', with: 'output_extravaganza') + click_on(I18n.t('dashboard.save')) + + launcher_path = project_launcher_path(project_id, script_id) + find("[href='#{launcher_path}'].btn-success").click + assert_selector('h1', text: 'the script title', count: 1) + + # assert defaults + assert_equal 'oakley', find('#launcher_auto_batch_clusters').value + assert_equal 'pzs0715', find('#launcher_auto_accounts').value + assert_equal "#{project_dir}/my_cool_script.sh", find('#launcher_auto_scripts').value + assert_nil YAML.safe_load(File.read("#{ondemand_dir}/job_log.yml")) + + select('owens', from: 'launcher_auto_batch_clusters') + select('pas2051', from: 'launcher_auto_accounts') + select('my_cooler_script.bash', from: 'launcher_auto_scripts') + + Open3 + .stubs(:capture3) + .with({}, 'sbatch', '-o', 'output_extravaganza/job-id-123-output.log', + '-e', 'output_extravaganza/job-id-123-error.log' '-A', 'pas2051', + '--export', 'NONE', '--parsable', '-M', 'owens', + stdin_data: "hostname\n") + .returns(['job-id-123', '', exit_success]) + + OodCore::Job::Adapters::Slurm.any_instance + .stubs(:info).returns(OodCore::Job::Info.new(id: 'job-id-123', status: :running)) + + click_on 'Launch' + assert_selector('.alert-success', text: 'job-id-123') + jobs = YAML.safe_load(File.read("#{ondemand_dir}/job_log.yml"), permitted_classes: [Time]) + + assert_equal(1, jobs.size) + assert_equal('job-id-123', jobs[0]['id']) + end + end + test 'submitting a script with auto attributes that fails' do Dir.mktmpdir do |dir| project_id = setup_project(dir) @@ -506,7 +555,8 @@ def add_auto_environment_variable(project_id, script_id, save: true) actual_new_options = page.all("##{new_field_id} option").map(&:value).to_set expected_new_options = [ 'bc_num_hours', 'auto_queues', 'bc_num_slots', 'auto_cores', - 'auto_accounts', 'auto_job_name', 'auto_environment_variable' + 'auto_accounts', 'auto_job_name', 'auto_environment_variable', + 'auto_output_directory' ].to_set assert_equal expected_new_options, actual_new_options end From 910d63e1d7f1d2f70c48acfe8d373213ae3fba1a Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Tue, 29 Oct 2024 11:46:13 -0400 Subject: [PATCH 06/17] remove broken test. --- .../test/system/project_manager_test.rb | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/apps/dashboard/test/system/project_manager_test.rb b/apps/dashboard/test/system/project_manager_test.rb index 7cef744bae..887f0fd5c8 100644 --- a/apps/dashboard/test/system/project_manager_test.rb +++ b/apps/dashboard/test/system/project_manager_test.rb @@ -450,56 +450,6 @@ def add_auto_environment_variable(project_id, script_id, save: true) click_on 'Launch' assert_selector('.alert-success', text: 'job-id-123') jobs = YAML.safe_load(File.read("#{ondemand_dir}/job_log.yml"), permitted_classes: [Time]) - - assert_equal(1, jobs.size) - assert_equal('job-id-123', jobs[0]['id']) - end - end - - # super similar to test above, only it adds auto_output_directory - test 'submitting a script with output directory' do - Dir.mktmpdir do |dir| - project_id = setup_project(dir) - script_id = setup_script(project_id) - project_dir = File.join(dir, 'projects', project_id) - ondemand_dir = File.join(project_dir, '.ondemand') - add_account(project_id, script_id, save: false) - - click_on('Add new option') - select('Log Output Directory', from: 'add_new_field_select') - click_on(I18n.t('dashboard.add')) - fill_in('launcher_auto_output_directory', with: 'output_extravaganza') - click_on(I18n.t('dashboard.save')) - - launcher_path = project_launcher_path(project_id, script_id) - find("[href='#{launcher_path}'].btn-success").click - assert_selector('h1', text: 'the script title', count: 1) - - # assert defaults - assert_equal 'oakley', find('#launcher_auto_batch_clusters').value - assert_equal 'pzs0715', find('#launcher_auto_accounts').value - assert_equal "#{project_dir}/my_cool_script.sh", find('#launcher_auto_scripts').value - assert_nil YAML.safe_load(File.read("#{ondemand_dir}/job_log.yml")) - - select('owens', from: 'launcher_auto_batch_clusters') - select('pas2051', from: 'launcher_auto_accounts') - select('my_cooler_script.bash', from: 'launcher_auto_scripts') - - Open3 - .stubs(:capture3) - .with({}, 'sbatch', '-o', 'output_extravaganza/job-id-123-output.log', - '-e', 'output_extravaganza/job-id-123-error.log' '-A', 'pas2051', - '--export', 'NONE', '--parsable', '-M', 'owens', - stdin_data: "hostname\n") - .returns(['job-id-123', '', exit_success]) - - OodCore::Job::Adapters::Slurm.any_instance - .stubs(:info).returns(OodCore::Job::Info.new(id: 'job-id-123', status: :running)) - - click_on 'Launch' - assert_selector('.alert-success', text: 'job-id-123') - jobs = YAML.safe_load(File.read("#{ondemand_dir}/job_log.yml"), permitted_classes: [Time]) - assert_equal(1, jobs.size) assert_equal('job-id-123', jobs[0]['id']) end From 361257386b5c70a67d1398dd2939e4f55c43e870 Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Tue, 29 Oct 2024 12:29:28 -0400 Subject: [PATCH 07/17] clean up diff. --- apps/dashboard/test/system/project_manager_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/dashboard/test/system/project_manager_test.rb b/apps/dashboard/test/system/project_manager_test.rb index 887f0fd5c8..f1f999a233 100644 --- a/apps/dashboard/test/system/project_manager_test.rb +++ b/apps/dashboard/test/system/project_manager_test.rb @@ -450,6 +450,7 @@ def add_auto_environment_variable(project_id, script_id, save: true) click_on 'Launch' assert_selector('.alert-success', text: 'job-id-123') jobs = YAML.safe_load(File.read("#{ondemand_dir}/job_log.yml"), permitted_classes: [Time]) + assert_equal(1, jobs.size) assert_equal('job-id-123', jobs[0]['id']) end From 6e07af0cc09698d44bd076ae6bd790c31b53aee4 Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Tue, 29 Oct 2024 12:37:56 -0400 Subject: [PATCH 08/17] Check submitted hash for auto_output_directory. --- .../test/lib/smart_attributes/auto_output_directory_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb b/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb index e4b1cbc103..63dc7a1c2e 100644 --- a/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb +++ b/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb @@ -26,6 +26,7 @@ def dynamic_env attribute = SmartAttributes::AttributeFactory.build('auto_output_directory', options) assert_equal('output_extravaganza', attribute.value.to_s) + assert_equal({ output_path: "output_extravaganza/%j-output.log", error_path: "output_extravaganza/%j-error.log"}, attribute.output_directory_hash ) end end end From 8b5286163c31f616aea3bdb7a403938ab732413b Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Wed, 30 Oct 2024 11:58:23 -0400 Subject: [PATCH 09/17] STDOUT and STDERR are now combined into one output file (-output.log) --- .../attributes/auto_output_directory.rb | 21 +++++-------- .../auto_output_directory_test.rb | 30 +++++++++++++++++-- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb index 1c19bf8e1c..b30f9df070 100644 --- a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb @@ -13,11 +13,14 @@ def self.build_auto_output_directory(opts = {}) module Attributes class AutoOutputDirectory < Attribute + OUTPUT_LOG_SUFFIX = "/%j-output.log" + + # Value of auto_output_directory attribute # Defaults to first script path in the project # @return [String] attribute value def value - opts[:value] || 'Default Output Directory' + opts[:value].presence end def widget @@ -28,25 +31,15 @@ def label(*) (opts[:label] || 'Output Directory').to_s end - def output_directory_hash - { output_path: output_path_value, error_path: error_path_value } + def output_path_value + return "#{value}#{OUTPUT_LOG_SUFFIX}" if value end # Submission hash describing how to submit this attribute # @param fmt [String, nil] formatting of hash # @return [Hash] submission hash def submit(*) - opts[:value] ? { script: output_directory_hash } : nil - end - - private - - def error_path_value - "#{opts[:value]}/%j-error.log" - end - - def output_path_value - "#{opts[:value]}/%j-output.log" + { script: { output_path: output_path_value }} end end end diff --git a/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb b/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb index 63dc7a1c2e..fcdc8930c5 100644 --- a/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb +++ b/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb @@ -17,7 +17,7 @@ def dynamic_env } end - test 'correctly sets the value' do + test 'correctly sets the user supplied value' do with_modified_env(dynamic_env) do options = { value: 'output_extravaganza', @@ -26,7 +26,33 @@ def dynamic_env attribute = SmartAttributes::AttributeFactory.build('auto_output_directory', options) assert_equal('output_extravaganza', attribute.value.to_s) - assert_equal({ output_path: "output_extravaganza/%j-output.log", error_path: "output_extravaganza/%j-error.log"}, attribute.output_directory_hash ) + assert_equal("output_extravaganza/%j-output.log", attribute.output_path_value ) + end + end + + test 'correctly sets the default value in place of empty string' do + with_modified_env(dynamic_env) do + options = { + value: '', + label: 'Output Directory' + } + attribute = SmartAttributes::AttributeFactory.build('auto_output_directory', options) + + assert_equal('job_output', attribute.value.to_s) + assert_equal(nil, attribute.output_path_value ) + end + end + + test 'correctly sets the default value in place of nil string' do + with_modified_env(dynamic_env) do + options = { + value: nil, + label: 'Output Directory' + } + attribute = SmartAttributes::AttributeFactory.build('auto_output_directory', options) + + assert_equal('job_output', attribute.value.to_s) + assert_equal(nil, attribute.output_path_value ) end end end From 6d3cc2411b8295096b5684c509ff025049fb2582 Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Wed, 30 Oct 2024 12:03:14 -0400 Subject: [PATCH 10/17] Update tests. --- .../test/lib/smart_attributes/auto_output_directory_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb b/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb index fcdc8930c5..b34745b656 100644 --- a/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb +++ b/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb @@ -38,7 +38,7 @@ def dynamic_env } attribute = SmartAttributes::AttributeFactory.build('auto_output_directory', options) - assert_equal('job_output', attribute.value.to_s) + assert_equal(nil, attribute.value) assert_equal(nil, attribute.output_path_value ) end end @@ -51,7 +51,7 @@ def dynamic_env } attribute = SmartAttributes::AttributeFactory.build('auto_output_directory', options) - assert_equal('job_output', attribute.value.to_s) + assert_equal(nil, attribute.value) assert_equal(nil, attribute.output_path_value ) end end From 6956c0c97da1b877c24b5c7a90c2703a0b645bd4 Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Wed, 30 Oct 2024 16:46:11 -0400 Subject: [PATCH 11/17] Remove output destination suffix. --- .../smart_attributes/attributes/auto_output_directory.rb | 9 +-------- .../lib/smart_attributes/auto_output_directory_test.rb | 5 +---- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb index b30f9df070..608ff7a40c 100644 --- a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb @@ -13,9 +13,6 @@ def self.build_auto_output_directory(opts = {}) module Attributes class AutoOutputDirectory < Attribute - OUTPUT_LOG_SUFFIX = "/%j-output.log" - - # Value of auto_output_directory attribute # Defaults to first script path in the project # @return [String] attribute value @@ -31,15 +28,11 @@ def label(*) (opts[:label] || 'Output Directory').to_s end - def output_path_value - return "#{value}#{OUTPUT_LOG_SUFFIX}" if value - end - # Submission hash describing how to submit this attribute # @param fmt [String, nil] formatting of hash # @return [Hash] submission hash def submit(*) - { script: { output_path: output_path_value }} + { script: { output_path: value } } end end end diff --git a/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb b/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb index b34745b656..5f35e41252 100644 --- a/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb +++ b/apps/dashboard/test/lib/smart_attributes/auto_output_directory_test.rb @@ -25,8 +25,7 @@ def dynamic_env } attribute = SmartAttributes::AttributeFactory.build('auto_output_directory', options) - assert_equal('output_extravaganza', attribute.value.to_s) - assert_equal("output_extravaganza/%j-output.log", attribute.output_path_value ) + assert_equal('output_extravaganza', attribute.value) end end @@ -39,7 +38,6 @@ def dynamic_env attribute = SmartAttributes::AttributeFactory.build('auto_output_directory', options) assert_equal(nil, attribute.value) - assert_equal(nil, attribute.output_path_value ) end end @@ -52,7 +50,6 @@ def dynamic_env attribute = SmartAttributes::AttributeFactory.build('auto_output_directory', options) assert_equal(nil, attribute.value) - assert_equal(nil, attribute.output_path_value ) end end end From d54be6336d91eb14f8d8deea4b76e1fd5bb4294f Mon Sep 17 00:00:00 2001 From: Greg Buchanan Date: Mon, 4 Nov 2024 10:43:17 -0500 Subject: [PATCH 12/17] Rename output_directory to log_location --- .../app/controllers/launchers_controller.rb | 2 +- apps/dashboard/app/helpers/launchers_helper.rb | 4 ++-- apps/dashboard/app/javascript/launcher_edit.js | 4 ++-- apps/dashboard/app/lib/smart_attributes.rb | 2 +- ...utput_directory.rb => auto_log_location.rb} | 12 ++++++------ .../app/views/launchers/edit.html.erb | 4 ++-- ...ctory_test.rb => auto_log_location_test.rb} | 18 +++++++++--------- .../test/system/project_manager_test.rb | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) rename apps/dashboard/app/lib/smart_attributes/attributes/{auto_output_directory.rb => auto_log_location.rb} (68%) rename apps/dashboard/test/lib/smart_attributes/{auto_output_directory_test.rb => auto_log_location_test.rb} (74%) diff --git a/apps/dashboard/app/controllers/launchers_controller.rb b/apps/dashboard/app/controllers/launchers_controller.rb index 99bb53d67c..0f1bafd6da 100644 --- a/apps/dashboard/app/controllers/launchers_controller.rb +++ b/apps/dashboard/app/controllers/launchers_controller.rb @@ -15,7 +15,7 @@ class LaunchersController < ApplicationController :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_fixed, - :auto_output_directory, :auto_output_directory_fixed, :auto_output_directory_exclude + :auto_log_location, :auto_log_location_fixed, :auto_log_location_exclude ].freeze def new diff --git a/apps/dashboard/app/helpers/launchers_helper.rb b/apps/dashboard/app/helpers/launchers_helper.rb index f3b5817380..b186e49af2 100644 --- a/apps/dashboard/app/helpers/launchers_helper.rb +++ b/apps/dashboard/app/helpers/launchers_helper.rb @@ -70,8 +70,8 @@ def auto_cores_template create_editable_widget(script_form_double, attrib) end - def auto_output_directory_template - attrib = SmartAttributes::AttributeFactory.build_auto_output_directory + def auto_log_location_template + attrib = SmartAttributes::AttributeFactory.build_auto_log_location create_editable_widget(script_form_double, attrib) end # We need a form builder to build the template divs. These are diff --git a/apps/dashboard/app/javascript/launcher_edit.js b/apps/dashboard/app/javascript/launcher_edit.js index b0b6ff24b0..738ea6b3d1 100644 --- a/apps/dashboard/app/javascript/launcher_edit.js +++ b/apps/dashboard/app/javascript/launcher_edit.js @@ -19,8 +19,8 @@ const newFieldData = { label: "Job Name", help: "The name the job will have." }, - auto_output_directory: { - label: "Log Output Directory", + auto_log_location: { + label: "Log Location", help: "The destination of the job's log output." }, bc_num_slots: { diff --git a/apps/dashboard/app/lib/smart_attributes.rb b/apps/dashboard/app/lib/smart_attributes.rb index 52b0fcc937..8beb15ddda 100644 --- a/apps/dashboard/app/lib/smart_attributes.rb +++ b/apps/dashboard/app/lib/smart_attributes.rb @@ -10,7 +10,7 @@ module SmartAttributes require 'smart_attributes/attributes/auto_groups' require 'smart_attributes/attributes/auto_job_name' require 'smart_attributes/attributes/auto_modules' - require 'smart_attributes/attributes/auto_output_directory' + require 'smart_attributes/attributes/auto_log_location' require 'smart_attributes/attributes/auto_primary_group' require 'smart_attributes/attributes/auto_queues' require 'smart_attributes/attributes/auto_qos' diff --git a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb b/apps/dashboard/app/lib/smart_attributes/attributes/auto_log_location.rb similarity index 68% rename from apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb rename to apps/dashboard/app/lib/smart_attributes/attributes/auto_log_location.rb index 608ff7a40c..a9a088e4d6 100644 --- a/apps/dashboard/app/lib/smart_attributes/attributes/auto_output_directory.rb +++ b/apps/dashboard/app/lib/smart_attributes/attributes/auto_log_location.rb @@ -5,15 +5,15 @@ class AttributeFactory # Build this attribute object. Must specify a valid directory in opts # # @param opts [Hash] attribute's options - # @return [Attributes::AutoOutputDirectory] the attribute object - def self.build_auto_output_directory(opts = {}) - Attributes::AutoOutputDirectory.new('auto_output_directory', opts) + # @return [Attributes::AutoLogLocation] the attribute object + def self.build_auto_log_location(opts = {}) + Attributes::AutoLogLocation.new('auto_log_location', opts) end end module Attributes - class AutoOutputDirectory < Attribute - # Value of auto_output_directory attribute + class AutoLogLocation < Attribute + # Value of auto_log_location attribute # Defaults to first script path in the project # @return [String] attribute value def value @@ -25,7 +25,7 @@ def widget end def label(*) - (opts[:label] || 'Output Directory').to_s + (opts[:label] || 'Log Location').to_s end # Submission hash describing how to submit this attribute diff --git a/apps/dashboard/app/views/launchers/edit.html.erb b/apps/dashboard/app/views/launchers/edit.html.erb index 66e013d997..25d79fb6fe 100644 --- a/apps/dashboard/app/views/launchers/edit.html.erb +++ b/apps/dashboard/app/views/launchers/edit.html.erb @@ -45,6 +45,6 @@ <%= auto_cores_template %> -