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

3414 launcher editable log location support #3911

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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 apps/dashboard/app/controllers/launchers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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_log_location, :auto_log_location_fixed
].freeze

def new
Expand Down
4 changes: 4 additions & 0 deletions apps/dashboard/app/helpers/launchers_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def auto_cores_template
create_editable_widget(script_form_double, attrib)
end

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
# templates so that they are not a part of the _actual_ form (yet).
# Otherwise you'd have required fields that you cannot actually edit
Expand Down
4 changes: 4 additions & 0 deletions apps/dashboard/app/javascript/launcher_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const newFieldData = {
label: "Job Name",
help: "The name the job will have."
},
auto_log_location: {
label: "Log Location",
help: "The destination of the job's log output."
},
bc_num_slots: {
label: "Nodes",
help: "How many nodes the job will run on."
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/app/lib/smart_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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_log_location'
require 'smart_attributes/attributes/auto_primary_group'
require 'smart_attributes/attributes/auto_queues'
require 'smart_attributes/attributes/auto_qos'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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
# @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 AutoLogLocation < Attribute
# Value of auto_log_location attribute
# Defaults to first script path in the project
# @return [String] attribute value
def value
opts[:value].presence
end

def widget
'text_field'
end

def label(*)
# (opts[:label] || 'Log Location').to_s
(opts[:label] || I18n.t('dashboard.auto_log_location_title')).to_s
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: value } }
end
end
end
end
6 changes: 5 additions & 1 deletion apps/dashboard/app/views/launchers/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@

<template id="auto_cores_template">
<%= auto_cores_template %>
</template>
</template>

<template id="auto_log_location_template">
<%= auto_log_location_template %>
</template>
2 changes: 2 additions & 0 deletions apps/dashboard/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ en:
deleted_message: "Saved settings %{settings_name} deleted."
settings_values_label: "Values"
outdated_message: "%{app_title} parameters have changed since these settings were created."

auto_log_location_title: "Log Location"

user_configuration:
support_ticket_error: "support_ticket is misconfigured. \"email\" or \"rt_api\" sections are required in the configuration YAML."
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/config/locales/ja_JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ ja_JP:
show: "見せる"
# project: "Project"
# directory: "Directory"
auto_log_location_title: "ログの場所"
2 changes: 2 additions & 0 deletions apps/dashboard/config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ zh-CN:
可以从上方导航栏中的下拉菜单访问群集访问应用程序。
<br>自定义共享应用程序可以在下面使用。

auto_log_location_title: "日志位置"

# all_apps_table_app_column: "Name"
# all_apps_table_category_column: "Category"
# all_apps_table_sub_category_column: "Sub Category"
Expand Down
56 changes: 56 additions & 0 deletions apps/dashboard/test/lib/smart_attributes/auto_log_location_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# frozen_string_literal: true

require 'test_helper'
require 'smart_attributes'

module SmartAttributes
class AutoLogLocationTest < ActiveSupport::TestCase
def setup
stub_clusters
stub_user
stub_sacctmgr
end

def dynamic_env
{
OOD_BC_DYNAMIC_JS: 'true'
}
end

test 'correctly sets the user supplied value' do
with_modified_env(dynamic_env) do
options = {
value: 'logerrific_locale',
label: 'Log Location'
}
attribute = SmartAttributes::AttributeFactory.build('auto_log_location', options)

assert_equal('logerrific_locale', attribute.value)
end
end

test 'correctly sets the default value in place of empty string' do
with_modified_env(dynamic_env) do
options = {
value: '',
label: 'Log Location'
}
attribute = SmartAttributes::AttributeFactory.build('auto_log_location', options)

assert_equal(nil, attribute.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: 'Log Location'
}
attribute = SmartAttributes::AttributeFactory.build('auto_log_location', options)

assert_equal(nil, attribute.value)
end
end
end
end
3 changes: 2 additions & 1 deletion apps/dashboard/test/system/project_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,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_log_location'
].to_set
assert_equal expected_new_options, actual_new_options
end
Expand Down
Loading