From b6e2f0dcae8551b92eab6d4cb1b53e39ac6dcc8b Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 25 Sep 2023 21:43:40 -0400 Subject: [PATCH] Allow copying SPSA inputs/outputs more clearly --- OpenBench/static/style.css | 17 +++++- OpenBench/templatetags/mytags.py | 18 ++++++ Templates/OpenBench/test.html | 90 +++++++++++++++------------- Templates/OpenBench/tune.html | 100 +++++++++++++++++-------------- 4 files changed, 137 insertions(+), 88 deletions(-) diff --git a/OpenBench/static/style.css b/OpenBench/static/style.css index 4cc9fb5..2f9412d 100644 --- a/OpenBench/static/style.css +++ b/OpenBench/static/style.css @@ -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; } diff --git a/OpenBench/templatetags/mytags.py b/OpenBench/templatetags/mytags.py index 767b06b..7749d97 100644 --- a/OpenBench/templatetags/mytags.py +++ b/OpenBench/templatetags/mytags.py @@ -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) diff --git a/Templates/OpenBench/test.html b/Templates/OpenBench/test.html index 8d1c6a4..d6adcae 100644 --- a/Templates/OpenBench/test.html +++ b/Templates/OpenBench/test.html @@ -53,52 +53,56 @@

{{test|git_diff_text}}

- - {% if not test.approved and profile.approver and profile.user.username != test.author %} - Approve - {% elif not test.approved and request.user.is_superuser %} - Approve - {% else %} - Approve - {% endif %} - - - {% if test.finished and profile.approver %} - Restart - {% elif test.finished and profile.user.username == test.author %} - Restart - {% elif test.finished %} - Restart - {% endif %} - - - {% if not test.finished and profile.approver %} - Stop - {% elif not test.finished and profile.user.username == test.author %} - Stop - {% elif not test.finished %} - Stop - {% endif %} - - - {% if profile.approver or profile.user.username == test.author %} - {% if test.deleted %} - Restore +
+ + {% if not test.approved and profile.approver and profile.user.username != test.author %} + Approve + {% elif not test.approved and request.user.is_superuser %} + Approve {% else %} - Delete + Approve {% endif %} - {% else %} - {% if test.deleted %} - Restore - {% else %} - Delete - {% endif %} - {% endif %} - - - - + + {% if test.finished and profile.approver %} + Restart + {% elif test.finished and profile.user.username == test.author %} + Restart + {% elif test.finished %} + Restart + {% endif %} + + + {% if not test.finished and profile.approver %} + Stop + {% elif not test.finished and profile.user.username == test.author %} + Stop + {% elif not test.finished %} + Stop + {% endif %} + + + {% if profile.approver or profile.user.username == test.author %} + {% if test.deleted %} + Restore + {% else %} + Delete + {% endif %} + {% else %} + {% if test.deleted %} + Restore + {% else %} + Delete + {% endif %} + {% endif %} +
+ +
+ + + Copy Stat Block + +
{{test|longStatBlock|linebreaksbr}}
diff --git a/Templates/OpenBench/tune.html b/Templates/OpenBench/tune.html index eb8ac0f..1763a3c 100644 --- a/Templates/OpenBench/tune.html +++ b/Templates/OpenBench/tune.html @@ -48,53 +48,65 @@

{{test|workload_pretty_name}}

- - {% if not test.approved and profile.approver and profile.user.username != test.author %} - Approve - {% elif not test.approved and request.user.is_superuser %} - Approve - {% else %} - Approve - {% endif %} - - - {% if test.finished and profile.approver %} - Restart - {% elif test.finished and profile.user.username == test.author %} - Restart - {% elif test.finished %} - Restart - {% endif %} - - - {% if not test.finished and profile.approver %} - Stop - {% elif not test.finished and profile.user.username == test.author %} - Stop - {% elif not test.finished %} - Stop - {% endif %} - - - {% if profile.approver or profile.user.username == test.author %} - {% if test.deleted %} - Restore +
+ + {% if not test.approved and profile.approver and profile.user.username != test.author %} + Approve + {% elif not test.approved and request.user.is_superuser %} + Approve {% else %} - Delete + Approve {% endif %} - {% else %} - {% if test.deleted %} - Restore - {% else %} - Delete - {% endif %} - {% endif %} - - - - - + + {% if test.finished and profile.approver %} + Restart + {% elif test.finished and profile.user.username == test.author %} + Restart + {% elif test.finished %} + Restart + {% endif %} + + + {% if not test.finished and profile.approver %} + Stop + {% elif not test.finished and profile.user.username == test.author %} + Stop + {% elif not test.finished %} + Stop + {% endif %} + + + {% if profile.approver or profile.user.username == test.author %} + {% if test.deleted %} + Restore + {% else %} + Delete + {% endif %} + {% else %} + {% if test.deleted %} + Restore + {% else %} + Delete + {% endif %} + {% endif %} +
+ +
+ + + + Copy SPSA Inputs + +
+ +
+ + + + Copy SPSA Outputs + +