Skip to content
Open
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
1 change: 1 addition & 0 deletions OpenBench/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class Network(Model):
engine = CharField(max_length=64)
author = CharField(max_length=64)
created = DateTimeField(auto_now_add=True)
scale_nps = IntegerField(default=0)

def __str__(self):
return '[{}] {} ({})'.format(self.engine, self.name, self.sha256)
Expand Down
27 changes: 24 additions & 3 deletions OpenBench/static/create_workload.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var repos = JSON.parse(document.getElementById('json-repos' ).textContent);
function create_network_options(field_id, engine) {

var has_default = false;
var default_value = "";
var network_options = document.getElementById(field_id);

// Delete all existing Networks
Expand All @@ -25,6 +26,9 @@ function create_network_options(field_id, engine) {
network_options.add(opt)

has_default = has_default || network.default;
if (network.default) {
default_value = network.sha256;
}
}

{ // Add a None option and set it to default if there was not one yet
Expand All @@ -34,6 +38,9 @@ function create_network_options(field_id, engine) {
opt.selected = !has_default;
network_options.add(opt);
}
if (has_default) {
change_network(default_value, field_id.replace('_network', ''));
}
}

function create_preset_buttons(engine, workload_type) {
Expand Down Expand Up @@ -223,6 +230,9 @@ function apply_preset(preset, workload_type) {

function change_engine(engine, target, workload_type) {

set_option('scale_nps', config.engines[engine].nps);
set_option('scale_method', workload_type == 'TUNE' ? 'DEV' : 'BASE');

set_engine(engine, target);

if (target == 'dev')
Expand All @@ -231,12 +241,23 @@ function change_engine(engine, target, workload_type) {
if (target == 'dev' && (workload_type == 'TEST' || workload_type == 'DATAGEN'))
set_engine(engine, 'base');

set_option('scale_nps', config.engines[engine].nps);
set_option('scale_method', workload_type == 'TUNE' ? 'DEV' : 'BASE');

apply_preset('STC', workload_type);
}

function change_network(network, target) {
var scale_method = document.getElementById('scale_method').value;
var expected_target = scale_method == 'DEV' ? 'dev' : 'base';
if (target != expected_target) {
return;
}
var scale_nps = document.getElementById('scale_nps');
for (const net of networks) {
if (net.sha256 === network && net.scale_nps > 0) {
scale_nps.value = net.scale_nps;
}
}
}

function set_test_type() {

// When swapping from SPRT -> FIXED, we disable test_bounds and test_confidence
Expand Down
5 changes: 5 additions & 0 deletions OpenBench/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def network_edit(request, engine, network):
return OpenBench.views.render(request, 'network.html', { 'network' : network })

new_name = request.POST['name']
new_scale_nps = request.POST['scale_nps']
new_default = request.POST['default'] == 'TRUE'
new_was_default = request.POST['was_default'] == 'TRUE'

Expand All @@ -377,6 +378,9 @@ def network_edit(request, engine, network):
if not re.match(r'^[a-zA-Z0-9_.-]+$', new_name):
return OpenBench.views.redirect(request, '/networks/', error='Valid characters are [a-zA-Z0-9_.-]')

if not re.match(r'^\d+$', new_scale_nps):
return OpenBench.views.redirect(request, '/networks/%s/EDIT/%s' % (network.engine, network.sha256), error='NPS Scale must be a non-negative integer')

# Ensure all changes are made, or no changes are made
with transaction.atomic():

Expand All @@ -391,6 +395,7 @@ def network_edit(request, engine, network):

# Update the actual Network. Ensure was_default is set if default is
network.name = new_name
network.scale_nps = int(new_scale_nps)
network.default = new_default
network.was_default = new_default or new_was_default
network.save()
Expand Down
2 changes: 2 additions & 0 deletions OpenBench/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,12 @@ def api_networks(request, engine):

default = {
'sha' : network.sha256, 'name' : network.name,
'scale_nps' : network.scale_nps,
'author' : network.author, 'created' : str(network.created) }

networks = [
{ 'sha' : network.sha256, 'name' : network.name,
'scale_nps' : network.scale_nps,
'author' : network.author, 'created' : str(network.created) }
for network in Network.objects.filter(engine=engine) ]

Expand Down
6 changes: 4 additions & 2 deletions Templates/OpenBench/create_workload.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ <h3> {{dev_title_text}} Settings </h3>
<label for="dev_bench" > {{dev_text}} Bench </label> <input value="1" id="dev_bench" name="dev_bench">
</div>
<div class="row">
<label for="dev_network" > {{dev_text}} Network </label> <select id="dev_network" name="dev_network"></select>
<label for="dev_network" > {{dev_text}} Network </label>
<select id="dev_network" name="dev_network" onchange="change_network(value, 'dev')"></select>
</div>
<div class="row">
<label for="dev_options"> {{dev_text}} Options </label> <input id="dev_options" name="dev_options">
Expand All @@ -89,7 +90,8 @@ <h3> Base Settings </h3>
<label for="base_bench"> Base Bench </label> <input value="1" id="base_bench" name="base_bench">
</div>
<div class="row">
<label for="base_network"> Base Network </label> <select id="base_network" name="base_network"></select>
<label for="base_network"> Base Network </label>
<select id="base_network" name="base_network" onchange="change_network(value, 'base');"></select>
</div>
<div class="row">
<label for="base_options"> Base Options </label> <input id="base_options" name="base_options">
Expand Down
5 changes: 5 additions & 0 deletions Templates/OpenBench/network.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<input id="name" name="name" value="{{network.name}}">
</div>

<div class="row">
<label for="scale_nps"> NPS Scale </label>
<input id="scale_nps" name="scale_nps" value="{{network.scale_nps}}">
</div>

<div class="row">
<label for="default"> Default </label>
<select id="default" name="default">
Comment on lines +40 to 44
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly added scale_nps row is immediately followed by the Default <select>, but that <select> block is not closed correctly later in the template (it ends with <select> instead of </select>). This can lead to malformed DOM and unreliable form behavior; update the closing tag to </select> (and do the same for the was_default select below).

Copilot uses AI. Check for mistakes.
Expand Down
2 changes: 2 additions & 0 deletions Templates/OpenBench/networks.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<th class="cursor" onclick="sort_networks(['engine'])">Engine</th>
<th class="cursor" onclick="sort_networks(['author'])">Author</th>
<th class="cursor" onclick="sort_networks(['name'])">Name</th>
<th class="cursor" onclick="sort_networks(['scale_nps'])">NPS Scale</th>
<th class="cursor" onclick="sort_networks(['sha256'])")>Hash</th>
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Hash column header has a malformed onclick attribute (onclick="sort_networks(['sha256'])")), which makes the HTML invalid and can break sorting. Remove the extra ") so the handler is a valid attribute value.

Suggested change
<th class="cursor" onclick="sort_networks(['sha256'])")>Hash</th>
<th class="cursor" onclick="sort_networks(['sha256'])">Hash</th>

Copilot uses AI. Check for mistakes.
<th></th>
<th></th>
Expand All @@ -47,6 +48,7 @@
<td><a href="/networks/{{network.engine}}/">{{network.engine}}</a></td>
<td>{{network.author|capfirst}}</td>
<td><a href="/networks/{{network.engine}}/DOWNLOAD/{{network.sha256}}">{{network.name}}</a></td>
<td>{{network.scale_nps}}</td>
<td>{{network.sha256}}</td>

<td>
Expand Down