Allow copying SPSA inputs/outputs more clearly

This commit is contained in:
andrew committed 2023-09-25 21:43:40 -04:00
1 parent 358ced1c0e
commit b6e2f0dcae
4 files changed
+137 -88

No files matched your search

+16 -1
View File
@@ -184,15 +184,30 @@ body, html, main{
padding: 10px 12px 6px 12px;
}
#content .anchor-container {
display: flex;
justify-content: space-between;
}
#content .anchor-container > .anchorbutton {
flex: 1;
margin-right: 4px;
}
#content .anchor-container > .anchorbutton:last-child {
margin-right: 0px;
}
#content .anchorbutton {
border-radius: 4px;
padding: 8px 8px 6px;
padding: 8px 0px 6px;
border-color: transparent;
color: var(--color-font1);
display: inline-block;
text-align: center;
transition: background-color 0.3s ease;
font-family: "Courier Prime", serif;
font-size: 13px;
cursor: pointer;
}
+18
View File
@@ -291,6 +291,23 @@ def spsa_original_input(workload):
return '\n'.join(lines)
def spsa_optimal_values(workload):
# Maintain the original order, if there was one
keys = sorted(
workload.spsa['parameters'].keys(),
key=lambda x: workload.spsa['parameters'][x].get('index', -1)
)
lines = []
for name in keys:
param = workload.spsa['parameters'][name]
value = param['value'] if param['float'] else round(param['value'])
lines.append(', '.join([name, str(value)]))
return '\n'.join(lines)
def book_download_link(workload):
return OpenBench.config.OPENBENCH_CONFIG['books'][workload.book_name]['source']
@@ -340,6 +357,7 @@ def git_diff_text(workload, N=24):
register.filter('spsa_param_digest', spsa_param_digest)
register.filter('spsa_original_input', spsa_original_input)
register.filter('spsa_optimal_values', spsa_optimal_values)
register.filter('book_download_link', book_download_link)
register.filter('network_download_link', network_download_link)
+47 -43
View File
@@ -53,52 +53,56 @@
<!-- Dev vs Base [Git Diff Link] -->
<h4><a href="{{test|gitDiffLink}}">{{test|git_diff_text}}</a></h4>
<!-- Approve Button: For Admins, or Cross-approvers -->
{% if not test.approved and profile.approver and profile.user.username != test.author %}
<a class="w-25 mr-2 anchorbutton btn-blue" href="/test/{{test.id}}/APPROVE">Approve</a>
{% elif not test.approved and request.user.is_superuser %}
<a class="w-25 mr-2 anchorbutton btn-blue" href="/test/{{test.id}}/APPROVE">Approve</a>
{% else %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Approve</a>
{% endif %}
<!-- Restart Button: For Approvers or Test Authors of finished tests -->
{% if test.finished and profile.approver %}
<a class="w-25 mr-2 anchorbutton btn-yellow" href="/test/{{test.id}}/RESTART">Restart</a>
{% elif test.finished and profile.user.username == test.author %}
<a class="w-25 mr-2 anchorbutton btn-yellow" href="/test/{{test.id}}/RESTART">Restart</a>
{% elif test.finished %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Restart</a>
{% endif %}
<!-- Stop Button: For Approvers or Test Authors of active tests -->
{% if not test.finished and profile.approver %}
<a class="w-25 mr-2 anchorbutton btn-yellow" href="/test/{{test.id}}/STOP">Stop</a>
{% elif not test.finished and profile.user.username == test.author %}
<a class="w-25 mr-2 anchorbutton btn-yellow" href="/test/{{test.id}}/STOP">Stop</a>
{% elif not test.finished %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Stop</a>
{% endif %}
<!-- Delete/Restore Button: For Approvers or Test Authors -->
{% if profile.approver or profile.user.username == test.author %}
{% if test.deleted %}
<a class="w-25 mr-2 anchorbutton btn-preset" href="/test/{{test.id}}/RESTORE">Restore</a>
<div class="anchor-container">
<!-- Approve Button: For Admins, or Cross-approvers -->
{% if not test.approved and profile.approver and profile.user.username != test.author %}
<a class="anchorbutton btn-blue" href="/test/{{test.id}}/APPROVE">Approve</a>
{% elif not test.approved and request.user.is_superuser %}
<a class="anchorbutton btn-blue" href="/test/{{test.id}}/APPROVE">Approve</a>
{% else %}
<a class="w-25 mr-2 anchorbutton btn-red" href="/test/{{test.id}}/DELETE">Delete</a>
<a class="anchorbutton btn-disabled">Approve</a>
{% endif %}
{% else %}
{% if test.deleted %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Restore</a>
{% else %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Delete</a>
{% endif %}
{% endif %}
<!-- Copy Button: Copy the current results statblock -->
<a class="copy-button" onclick="copy_text('long-statblock', true)">
<i class="fa-regular fa-clone copy-button"></i>
</a>
<!-- Restart Button: For Approvers or Test Authors of finished tests -->
{% if test.finished and profile.approver %}
<a class="anchorbutton btn-yellow" href="/test/{{test.id}}/RESTART">Restart</a>
{% elif test.finished and profile.user.username == test.author %}
<a class="anchorbutton btn-yellow" href="/test/{{test.id}}/RESTART">Restart</a>
{% elif test.finished %}
<a class="anchorbutton btn-disabled">Restart</a>
{% endif %}
<!-- Stop Button: For Approvers or Test Authors of active tests -->
{% if not test.finished and profile.approver %}
<a class="anchorbutton btn-yellow" href="/test/{{test.id}}/STOP">Stop</a>
{% elif not test.finished and profile.user.username == test.author %}
<a class="anchorbutton btn-yellow" href="/test/{{test.id}}/STOP">Stop</a>
{% elif not test.finished %}
<a class="anchorbutton btn-disabled">Stop</a>
{% endif %}
<!-- Delete/Restore Button: For Approvers or Test Authors -->
{% if profile.approver or profile.user.username == test.author %}
{% if test.deleted %}
<a class="anchorbutton btn-preset" href="/test/{{test.id}}/RESTORE">Restore</a>
{% else %}
<a class="anchorbutton btn-red" href="/test/{{test.id}}/DELETE">Delete</a>
{% endif %}
{% else %}
{% if test.deleted %}
<a class="anchorbutton btn-disabled">Restore</a>
{% else %}
<a class="anchorbutton btn-disabled">Delete</a>
{% endif %}
{% endif %}
</div>
<div class="anchor-container">
<!-- Copy Button: Copy the current results statblock -->
<a class="mt-1 anchorbutton btn-blue" onclick="copy_text('long-statblock', true)">
Copy Stat Block
</a>
</div>
<!-- Elo, (SPRT/LRR if SPRT, otherwise CONF), Games -->
<pre class="long-statblock" id="long-statblock">{{test|longStatBlock|linebreaksbr}}</pre>
+56 -44
View File
@@ -48,53 +48,65 @@
<!-- Dev vs Base [Git Diff Link] -->
<h4><a href="{{test|gitDiffLink}}">{{test|workload_pretty_name}}</a></h4>
<!-- Approve Button: For Admins, or Cross-approvers -->
{% if not test.approved and profile.approver and profile.user.username != test.author %}
<a class="w-25 mr-2 anchorbutton btn-blue" href="/tune/{{test.id}}/APPROVE">Approve</a>
{% elif not test.approved and request.user.is_superuser %}
<a class="w-25 mr-2 anchorbutton btn-blue" href="/tune/{{test.id}}/APPROVE">Approve</a>
{% else %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Approve</a>
{% endif %}
<!-- Restart Button: For Approvers or Test Authors of finished tests -->
{% if test.finished and profile.approver %}
<a class="w-25 mr-2 anchorbutton btn-yellow" href="/tune/{{test.id}}/RESTART">Restart</a>
{% elif test.finished and profile.user.username == test.author %}
<a class="w-25 mr-2 anchorbutton btn-yellow" href="/tune/{{test.id}}/RESTART">Restart</a>
{% elif test.finished %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Restart</a>
{% endif %}
<!-- Stop Button: For Approvers or Test Authors of active tests -->
{% if not test.finished and profile.approver %}
<a class="w-25 mr-2 anchorbutton btn-yellow" href="/tune/{{test.id}}/STOP">Stop</a>
{% elif not test.finished and profile.user.username == test.author %}
<a class="w-25 mr-2 anchorbutton btn-yellow" href="/tune/{{test.id}}/STOP">Stop</a>
{% elif not test.finished %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Stop</a>
{% endif %}
<!-- Delete/Restore Button: For Approvers or Test Authors -->
{% if profile.approver or profile.user.username == test.author %}
{% if test.deleted %}
<a class="w-25 mr-2 anchorbutton btn-preset" href="/tune/{{test.id}}/RESTORE">Restore</a>
<div class="anchor-container">
<!-- Approve Button: For Admins, or Cross-approvers -->
{% if not test.approved and profile.approver and profile.user.username != test.author %}
<a class="anchorbutton btn-blue" href="/tune/{{test.id}}/APPROVE">Approve</a>
{% elif not test.approved and request.user.is_superuser %}
<a class="anchorbutton btn-blue" href="/tune/{{test.id}}/APPROVE">Approve</a>
{% else %}
<a class="w-25 mr-2 anchorbutton btn-red" href="/tune/{{test.id}}/DELETE">Delete</a>
<a class="anchorbutton btn-disabled">Approve</a>
{% endif %}
{% else %}
{% if test.deleted %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Restore</a>
{% else %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Delete</a>
{% endif %}
{% endif %}
<!-- Copies Raw SPSA Input from a hidden element -->
<pre id="spsa-input" style="display: none">{{test|spsa_original_input}}</pre>
<a class="copy-button" onclick="copy_text('spsa-input', false)">
<i class="fa-regular fa-clone copy-button"></i>
</a>
<!-- Restart Button: For Approvers or Test Authors of finished tests -->
{% if test.finished and profile.approver %}
<a class="anchorbutton btn-yellow" href="/tune/{{test.id}}/RESTART">Restart</a>
{% elif test.finished and profile.user.username == test.author %}
<a class="anchorbutton btn-yellow" href="/tune/{{test.id}}/RESTART">Restart</a>
{% elif test.finished %}
<a class="anchorbutton btn-disabled">Restart</a>
{% endif %}
<!-- Stop Button: For Approvers or Test Authors of active tests -->
{% if not test.finished and profile.approver %}
<a class="anchorbutton btn-yellow" href="/tune/{{test.id}}/STOP">Stop</a>
{% elif not test.finished and profile.user.username == test.author %}
<a class="anchorbutton btn-yellow" href="/tune/{{test.id}}/STOP">Stop</a>
{% elif not test.finished %}
<a class="anchorbutton btn-disabled">Stop</a>
{% endif %}
<!-- Delete/Restore Button: For Approvers or Test Authors -->
{% if profile.approver or profile.user.username == test.author %}
{% if test.deleted %}
<a class="anchorbutton btn-preset" href="/tune/{{test.id}}/RESTORE">Restore</a>
{% else %}
<a class="anchorbutton btn-red" href="/tune/{{test.id}}/DELETE">Delete</a>
{% endif %}
{% else %}
{% if test.deleted %}
<a class="anchorbutton btn-disabled">Restore</a>
{% else %}
<a class="anchorbutton btn-disabled">Delete</a>
{% endif %}
{% endif %}
</div>
<div class="anchor-container">
<!-- Copies Raw SPSA Input from a hidden element -->
<pre id="spsa-input" style="display: none">{{test|spsa_original_input}}</pre>
<a class="mt-1 anchorbutton btn-blue" onclick="copy_text('spsa-input', false)">
Copy SPSA Inputs
</a>
</div>
<div class="anchor-container">
<!-- Copies SPSA Optimal Values from a hidden element -->
<pre id="spsa-output" style="display: none">{{test|spsa_optimal_values}}</pre>
<a class="mt-1 anchorbutton btn-blue" onclick="copy_text('spsa-output', false)">
Copy SPSA Outputs
</a>
</div>
<!-- Elo, (SPRT/LRR if SPRT, otherwise CONF), Games -->
<!-- For SPSA, # of Params, Iterations, and Games -->