Skip to content

Commit

Permalink
support fields with numbers in dynamic bc (#3507)
Browse files Browse the repository at this point in the history
support fields that start with numbers in dynamic bc.
  • Loading branch information
johrstrom authored Apr 22, 2024
1 parent a0c708d commit 6f0c12e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/dashboard/app/javascript/dynamic_forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ function snakeCaseWords(str) {
snakeCase += c.toLowerCase();
} else if(c == c.toUpperCase() && isNaN(c)) {
const nextIsUpper = (index + 1 !== str.length) ? str[index + 1] === str[index + 1].toUpperCase() : true;
if (str[index-1] === '_' || nextIsUpper) {
const nextIsNum = !isNaN(str[index + 1]);
if ((str[index-1] === '_' || nextIsUpper) && !nextIsNum) {
snakeCase += c.toLowerCase();
} else {
snakeCase += `_${c.toLowerCase()}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ attributes:
data-max-bc-num-slots-for-cluster-oakley: 8,
data-min-gpus: 0,
data-max-gpus: 0,
data-hide-gpus-num-v100: true,
]
- [
"broken",
Expand All @@ -46,6 +47,7 @@ attributes:
data-maximum-bc-not-found-for-cluster-mistype: 30,
data-min-gpus: 0,
data-max-gpus: 0,
data-hide-gpus-num-v100: true,
]
- [
"gpu",
Expand Down Expand Up @@ -76,6 +78,7 @@ attributes:

data-min-gpus: 0,
data-max-gpus: 0,
data-hide-gpus-num-v100: true,
]
- [
"advanced",
Expand All @@ -85,6 +88,7 @@ attributes:

data-min-gpus: 0,
data-max-gpus: 0,
data-hide-gpus-num-v100: true,
]
# this node type is the same for both clusters, so there's no 'for-cluster-...' clause
- [
Expand All @@ -99,6 +103,7 @@ attributes:

data-min-gpus: 0,
data-max-gpus: 0,
data-hide-gpus-num-v100: true,
]
- [
"other-40ish-option",
Expand All @@ -108,6 +113,7 @@ attributes:

data-min-gpus: 0,
data-max-gpus: 0,
data-hide-gpus-num-v100: true,
]
python_version:
# let's set the account used by the python version for some reason
Expand Down Expand Up @@ -214,3 +220,4 @@ form:
- auto_modules_intel
- auto_modules_netcdf-serial
- checkbox_test
- gpus_num_v100
3 changes: 2 additions & 1 deletion apps/dashboard/test/models/batch_connect/session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ def completed?
'auto_modules_app_jupyter' => '',
'auto_modules_intel' => '',
'auto_modules_netcdf_serial' => '',
'checkbox_test' => ''
'checkbox_test' => '',
'gpus_num_v100' => ''
}

assert session.save(app: bc_jupyter_app, context: ctx), session.errors.each(&:to_s).to_s
Expand Down
12 changes: 12 additions & 0 deletions apps/dashboard/test/system/batch_connect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,18 @@ def make_bc_app(dir, form)
assert_equal 'display: none;', find_option_style('classroom_size', 'large')
end

test 'can hide fields with numbers and characters' do
visit new_batch_connect_session_context_url('sys/bc_jupyter')

# defaults - gpus_num_v100 is hidden on page load.
assert_equal('any', find_value('node_type'))
refute(find("##{bc_ele_id('gpus_num_v100')}", visible: false).visible?)

# select gpu and now it's shown.
select('gpu', from: bc_ele_id('node_type'))
assert(find("##{bc_ele_id('gpus_num_v100')}").visible?)
end

test 'options can check and uncheck' do
visit new_batch_connect_session_context_url('sys/bc_jupyter')

Expand Down

0 comments on commit 6f0c12e

Please sign in to comment.