-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.yml.erb
147 lines (139 loc) · 4.07 KB
/
form.yml.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<%-
def size_lookup
Hash.new(0).tap do |hsh|
hsh[:small] = 0
hsh[:medium] = 1
hsh[:large] = 2
hsh[:xlarge] = 3
end
end
def size_to_num(size)
size_lookup[size.to_sym].to_i
end
groups = OodSupport::User.new.groups.sort_by(&:id).tap do |groups|
groups.unshift(groups.delete(OodSupport::Process.group))
end.map(&:name).grep(/^P./)
classrooms = OodAppkit.clusters.map do |cluster|
[ cluster.id.to_s, cluster.custom_config[:classrooms].to_h ]
end.to_h.map do |cluster_id, classrooms|
classes = classrooms.select do |app_type, class_configs|
app_type == 'jupyter'
end.map do |_app_type, class_configs|
class_configs.map do |name, class_config|
{
name: name,
size: size_to_num(class_config.fetch('size', 'small')),
hours: class_config.fetch('hours', 1).to_i,
cluster_fs: class_config.fetch('cluster_fs', 'pitzer'),
module_type: class_config.fetch('module_type', 'default'),
account: class_config.fetch('project', nil),
cluster: cluster_id
}
end.select do |class_config|
acct = class_config.fetch(:account, nil)
!acct.nil? && groups.include?(acct)
end
end
end.flatten
-%>
---
form:
- cluster
- classroom
- account
- jupyterlab_switch
- size
- hours
- cluster_fs
- module_type
attributes:
cluster:
widget: "hidden_field"
account:
widget: "hidden_field"
cluster_fs:
widget: "hidden_field"
module_type:
widget: "hidden_field"
jupyterlab_switch:
widget: "check_box"
label: "Use JupyterLab instead of Jupyter Notebook?"
help: |
JupyterLab is the next generation of Jupyter, and is completely compatible with existing Jupyter Notebooks.
hours:
widget: "select"
options:
- [
"1.5 hours", "1.5",
]
- [
"3 hours", "3",
<%- classrooms.each do |cr| %>
<%- unless cr[:hours].to_i >= 3 %>
data-option-for-classroom-<%= cr[:name].to_s.gsub('_', '-') %>: false,
<%- end %>
<%- end %>
]
- [
"6 hours", "6",
<%- classrooms.each do |cr| %>
<%- unless cr[:hours].to_i >= 6 %>
data-option-for-classroom-<%= cr[:name].to_s.gsub('_', '-') %>: false,
<%- end %>
<%- end %>
]
help: Instructors can request longer times.
size:
widget: "select"
options:
- [
"small", "small",
]
- [
"medium", "medium",
<%- classrooms.each do |cr| %>
<%- unless cr[:size].to_i >= 1 %>
data-option-for-classroom-<%= cr[:name].to_s.gsub('_', '-') %>: false,
<%- end %>
<%- end %>
]
- [
"large", "large",
<%- classrooms.each do |cr| %>
<%- unless cr[:size].to_i >= 2 %>
data-option-for-classroom-<%= cr[:name].to_s.gsub('_', '-') %>: false,
<%- end %>
<%- end %>
]
- [
"extra-large", "extra-large",
<%- classrooms.each do |cr| %>
<%- unless cr[:size].to_i >= 3 %>
data-option-for-classroom-<%= cr[:name].to_s.gsub('_', '-') %>: false,
<%- end %>
<%- end %>
]
help: |
Larger sizes may not be applicable for your classroom. Instructors can request larger
sizes.
* **small** - less than 1 core & 2 GB of memory.
* **medium** - 2 cores & 8 GB of memory.
* **large** - 4 cores & 16 GB of memory.
* **extra-large** - 8 cores & 32 GB of memory.
classroom:
<%- if classrooms.size >= 1 -%>
widget: select
options:
<%- classrooms.each do |cr| %>
- [
"<%= cr[:name].gsub('_', ' ') %>", "<%= cr[:name] %>",
data-set-account: "<%= cr[:account] %>",
data-set-cluster-fs: "<%= cr[:cluster_fs] %>",
data-set-module-type: "<%= cr[:module_type] %>",
data-set-cluster: "<%= cr[:cluster] %>"
]
<%- end %>
<%- else -%>
widget: 'hidden_field'
value: 'no_classroom'
<%- end -%>