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

backport #1955 to 2.0 #2014

Merged
merged 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion apps/dashboard/app/javascript/packs/batchConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ function addMinMaxForHandler(optionId, option, key, configValue) {

minMaxHandlerCache.push(cacheKey);
}

toggleMinMax({ target: document.querySelector(`#${optionId}`) }, id, secondDimId);
}

/**
Expand Down Expand Up @@ -348,7 +350,7 @@ function updateVisibility(event, changeId) {
const id = event.target['id'];
const changeElement = $(`#${changeId}`).parent();

if (changeElement.size() <= 0) return;
if (changeElement.length <= 0) return;

// safe to access directly?
const hide = hideLookup[id].get(changeId, val);
Expand All @@ -359,6 +361,10 @@ function updateVisibility(event, changeId) {
}
}

/**
* Update the min & max values of `changeId` based on the
* event, the `otherId` and the settings in minMaxLookup table.
*/
function toggleMinMax(event, changeId, otherId) {
let x = undefined, y = undefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,18 @@ attributes:
"any",
data-hide-cuda-version: true,
data-hide-advanced-options: true,
# 'any' is the default node_type and here are are overrides for the min & max
# in bc_num_slots definition above.
data-min-bc-num-slots-for-cluster-owens: 3,
data-max-bc-num-slots-for-cluster-owens: 7,
data-min-bc-num-slots-for-cluster-oakley: 4,
data-max-bc-num-slots-for-cluster-oakley: 8,
]
- [
"broken",
data-minnn-bc-not-found-for-cluster-mistype: 30,
data-max-bc-not-found-for-cluster-mistype: 30,
data-maximum-bc-not-found-for-cluster-mistype: 30
data-maximum-bc-not-found-for-cluster-mistype: 30,
]
- [
"gpu",
Expand Down
69 changes: 34 additions & 35 deletions apps/dashboard/test/system/batch_connect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def setup
end

test 'changing node type changes mins & maxs' do
# max starts out at 20
# max starts out at 7
visit new_batch_connect_session_context_url('sys/bc_jupyter')
assert_equal 20, find_max('bc_num_slots')
assert_equal 1, find_min('bc_num_slots')
assert_equal 7, find_max('bc_num_slots')
assert_equal 3, find_min('bc_num_slots')
select('owens', from: bc_ele_id('cluster'))

# change the node type and we should have some new min/max & value
Expand All @@ -64,12 +64,12 @@ def setup
visit new_batch_connect_session_context_url('sys/bc_jupyter')

# defaults
assert_equal 20, find_max('bc_num_slots')
assert_equal 1, find_min('bc_num_slots')
assert_equal 7, find_max('bc_num_slots')
assert_equal 3, find_min('bc_num_slots')
assert_equal 'any', find_value('node_type')

# put the max for 'any'
fill_in bc_ele_id('bc_num_slots'), with: 20
fill_in bc_ele_id('bc_num_slots'), with: 7

# now toggle to gpu. Max is 28 and the value is 28
select('gpu', from: bc_ele_id('node_type'))
Expand All @@ -81,12 +81,12 @@ def setup
visit new_batch_connect_session_context_url('sys/bc_jupyter')

# defaults
assert_equal 20, find_max('bc_num_slots')
assert_equal 1, find_min('bc_num_slots')
assert_equal 7, find_max('bc_num_slots')
assert_equal 3, find_min('bc_num_slots')
assert_equal 'any', find_value('node_type')

# put the max for 'any'
fill_in bc_ele_id('bc_num_slots'), with: 1
# put the min for 'any'
fill_in bc_ele_id('bc_num_slots'), with: 3

# now toggle to gpu. min is 2 and the value is 2
select('gpu', from: bc_ele_id('node_type'))
Expand Down Expand Up @@ -115,8 +115,8 @@ def setup
visit new_batch_connect_session_context_url('sys/bc_jupyter')

# start with defaults
assert_equal 1, find_min('bc_num_slots')
assert_equal 20, find_max('bc_num_slots')
assert_equal 3, find_min('bc_num_slots')
assert_equal 7, find_max('bc_num_slots')
assert_equal 'any', find_value('node_type')

# not the max, but less than the next choices'
Expand All @@ -129,9 +129,9 @@ def setup
end

test 'changing the cluster changes max' do
# max starts out at 20
# max starts out at 7
visit new_batch_connect_session_context_url('sys/bc_jupyter')
assert_equal 20, find_max('bc_num_slots')
assert_equal 7, find_max('bc_num_slots')
select('owens', from: bc_ele_id('cluster'))

select('gpu', from: bc_ele_id('node_type'))
Expand All @@ -143,9 +143,9 @@ def setup
end

test 'using same node sets min/max' do
# max starts out at 20
# max starts out at 7
visit new_batch_connect_session_context_url('sys/bc_jupyter')
assert_equal 20, find_max('bc_num_slots')
assert_equal 7, find_max('bc_num_slots')

select('same', from: bc_ele_id('node_type'))
assert_equal 100, find_min('bc_num_slots')
Expand All @@ -165,40 +165,40 @@ def setup
assert_equal '100', find_value('bc_num_slots')
end

test 'nothing applied to any node type' do
test 'nothing applied to broken node type' do
visit new_batch_connect_session_context_url('sys/bc_jupyter')
assert_equal 20, find_max('bc_num_slots')
assert_equal 1, find_min('bc_num_slots')
assert_equal '1', find_value('bc_num_slots')
assert_equal 7, find_max('bc_num_slots')
assert_equal 3, find_min('bc_num_slots')
assert_equal '3', find_value('bc_num_slots')
select('broken', from: bc_ele_id('node_type'))

# changing clusters does nothing.
select('owens', from: bc_ele_id('cluster'))
select('any', from: bc_ele_id('node_type'))
assert_equal 20, find_max('bc_num_slots')
assert_equal 1, find_min('bc_num_slots')
assert_equal '1', find_value('bc_num_slots')
assert_equal 7, find_max('bc_num_slots')
assert_equal 3, find_min('bc_num_slots')
assert_equal '3', find_value('bc_num_slots')

select('oakley', from: bc_ele_id('cluster'))
assert_equal 20, find_max('bc_num_slots')
assert_equal 1, find_min('bc_num_slots')
assert_equal '1', find_value('bc_num_slots')
assert_equal 7, find_max('bc_num_slots')
assert_equal 3, find_min('bc_num_slots')
assert_equal '3', find_value('bc_num_slots')

# choose same to get a min & max set. Change back to
# any and we keep the same min & max from same.
# broken and we keep the same min & max from same.
# TODO this is _current_ behaviour, will probably break
select('same', from: bc_ele_id('node_type'))
assert_equal 200, find_max('bc_num_slots')
assert_equal 100, find_min('bc_num_slots')
assert_equal '100', find_value('bc_num_slots')
select('any', from: bc_ele_id('node_type'))
select('broken', from: bc_ele_id('node_type'))
assert_equal 200, find_max('bc_num_slots')
assert_equal 100, find_min('bc_num_slots')
assert_equal '100', find_value('bc_num_slots')
end

test 'clamp min values' do
visit new_batch_connect_session_context_url('sys/bc_jupyter')
assert_equal '1', find_value('bc_num_slots')
assert_equal '3', find_value('bc_num_slots')

select('owens', from: bc_ele_id('cluster'))
select('gpu', from: bc_ele_id('node_type'))
Expand All @@ -219,7 +219,7 @@ def setup

test 'clamp max values' do
visit new_batch_connect_session_context_url('sys/bc_jupyter')
assert_equal '1', find_value('bc_num_slots')
assert_equal '3', find_value('bc_num_slots')
# this tests filling values by design, bc we have to set a giant max right off the bat
fill_in bc_ele_id('bc_num_slots'), with: 1000
assert_equal '1000', find_value('bc_num_slots')
Expand Down Expand Up @@ -296,9 +296,8 @@ def setup
assert_equal 'python37', find_value('hidden_change_thing', visible: false)

update_script = <<~JAVASCRIPT
let ele = $('#batch_connect_session_context_hidden_change_thing');
ele.val('some new value');
ele.attr('value', 'some new value');
let ele = document.getElementById('batch_connect_session_context_hidden_change_thing');
ele.value = 'some new value';
JAVASCRIPT

execute_script(update_script)
Expand Down Expand Up @@ -355,7 +354,7 @@ def setup
# defaults
assert_equal 'owens', find_value('cluster')
assert_equal 'any', find_value('node_type')
assert_equal 20, find_max('bc_num_slots')
assert_equal 7, find_max('bc_num_slots')

select('other-40ish-option', from: bc_ele_id('node_type'))
assert_equal 40, find_max('bc_num_slots')
Expand Down