summaryrefslogtreecommitdiff
path: root/fishtest/fishtest/templates/tests_view.mak
blob: ac48e9979915d12a8a2449cb1370e8b648121136 (plain)
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<%inherit file="base.mak"/>
 
<%namespace name="base" file="base.mak"/>
 
%if 'spsa' in run['args']:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="/js/gkr.js"></script>
<script>
var spsa_history_url = '${run_args[0][1]}/spsa_history';
</script>
<script type="text/javascript" src="/js/spsa.js"></script>
%endif
 
<h3>${run['args']['new_tag']} vs ${run['args']['base_tag']} ${base.diff_url(run)}</h3>
 
<div class="row-fluid">
<div style="display:inline-block;">
<%include file="elo_results.mak" args="run=run" />
</div>
</div>
 
<div class="row-fluid">
 
<div class="span8">
  <h4>Details</h4>
 
	<%! import markupsafe %>
 
  <table class="table table-condensed">
  %for arg in run_args:
    %if len(arg[2]) == 0:
      %if arg[0] == 'username' and approver:
        <%
        username = arg[1]
        %>
        <tr><td>${arg[0]}</td><td><a href="/user/${arg[1]}">${arg[1]}</a></td></tr>
      %else:
        <tr><td>${arg[0]}</td><td>${str(markupsafe.Markup(arg[1])).replace('\n', '<br>') | n}</td></tr>
      %endif
    %else:
    <tr><td>${arg[0]}</td><td><a href="${arg[2]}" target="_blank">${arg[1]}</a></td></tr>
    %endif
  %endfor
  <tr><td>raw statistics</td><td>
  <a href=/tests/stats/${run['_id']}>/tests/stats/${run['_id']}</a>
  </td></tr>
  </table>
</div>
 
<div class="span4">
  <h4>Actions</h4>
%if not run['finished']:
  <form action="/tests/stop" method="POST" style="display:inline">
    <input type="hidden" name="run-id" value="${run['_id']}">
    <button type="submit" class="btn btn-danger">
      Stop
    </button>
  </form>
%if not run.get('approved', False):
  <span>
    <form action="/tests/approve" method="POST" style="display:inline">
      <input type="hidden" name="run-id" value="${run['_id']}">
      <button type="submit" id="approve-btn" class="btn btn-success">
        Approve
      </button>
    </form>
  </span>
%endif
%else:
  <form action="/tests/purge" method="POST" style="display:inline">
    <input type="hidden" name="run-id" value="${run['_id']}">
    <button type="submit" class="btn btn-danger">
      Purge
    </button>
  </form>
%endif
  <a href="/tests/run?id=${run['_id']}">
    <button class="btn">Reschedule</button>
  </a>
 
%if not run['finished'] and not run.get('approved', False):
  <br/>
  <br/>
  <div id="master-diff" class="alert">
    Comparing base branch with master...
  </div>
  <a href="https://github.com/official-stockfish/Stockfish/compare/master...${run['args']['resolved_base'][:7]}" target="_blank">Master diff</a>
%endif
 
  <hr>
 
  <form class="form" action="/tests/modify" method="POST">
    <label class="control-label">Number of games:</label>
    <input name="num-games" value="${run['args']['num_games']}">
 
    <label class="control-label">Adjust priority (higher is more urgent):</label>
    <input name="priority" value="${run['args']['priority']}">
 
    <label class="control-label">Adjust throughput%:</label>
    <input name="throughput" value="${run['args'].get('throughput', 1000)}">
 
    <input type="hidden" name="run" value="${run['_id']}" />
    <button type="submit" class="btn btn-primary">Modify</button>
  </form>
 
  %if 'spsa' not in run['args']:
  <hr>
 
  <h4>Stats</h4>
  <table class="table table-condensed">
    <tr><td>chi^2</td><td>${'%.2f' % (chi2['chi2'])}</td></tr>
    <tr><td>dof</td><td>${chi2['dof']}</td></tr>
    <tr><td>p-value</td><td>${'%.2f' % (chi2['p'] * 100)}%</td></tr>
  </table>
  %endif
 
  <hr>
 
  <h4>Time</h4>
  <table class="table table-condensed">
    <tr><td>start time</td><td>${run['start_time'].strftime("%Y-%m-%d %H:%M:%S")}</td></tr>
    <tr><td>last updated</td><td>${run['last_updated'].strftime("%Y-%m-%d %H:%M:%S")}</td></tr>
  </table>
</div>
 
</div>
 
%if 'spsa' in run['args']:
<div id="div_spsa_preload" style="background-image:url('/img/preload.gif'); width: 256px; height: 32px; display: none;">
<div style="height: 100%; width: 100%; text-align:center; padding-top: 5px;">
Loading graph...
</div></div>
<div id="div_spsa_error" style="display: none; border: 1px solid red; color: red; width: 400px; "></div>
<div id="chart_toolbar" style="display: none;">
Gaussian Kernel Smoother&nbsp;&nbsp;<div class="btn-group"><button id="btn_smooth_plus" class="btn">&nbsp;&nbsp;&nbsp;+&nbsp;&nbsp;&nbsp;</button>
<button id="btn_smooth_minus" class="btn">&nbsp;&nbsp;&nbsp;−&nbsp;&nbsp;&nbsp;</button>
</div>
<div class="btn-group">
<button id="btn_view_individual" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
    View Individual Parameter<span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu" id="dropdown_individual"></ul>
</div>
<button id="btn_view_all" class="btn">View All</button>
</div>
<div id="div_spsa_history_plot"></div>
%endif
 
<section id="diff-section" style="display: none">
  <h3>
    Diff contents
    <button id="diff-toggle" class="btn">Show</button>
  </h3>
  <pre id="diff-contents"><code class="diff"></code></pre>
</section>
 
<h3>Tasks ${totals}</h3>
<table class='table table-striped table-condensed'>
 <thead>
  <tr>
   <th>Idx</th>
   <th>Worker</th>
   <th>Info</th>
   <th>Last Updated</th>
   <th>Played</th>
   <th>Wins</th>
   <th>Losses</th>
   <th>Draws</th>
   <th>Crashes</th>
   <th>Time</th>
 
   %if 'spsa' not in run['args']:
   <th>Residual</th>
	 %endif
  </tr>
 </thead>
 <tbody>
  %for idx, task in enumerate(run['tasks'] + run.get('bad_tasks', [])):
  <%
    stats = task.get('stats', {})
    if 'stats' in task:
      total = str(stats['wins'] + stats['losses'] + stats['draws']).zfill(3)
    else:
      continue
 
    if task['active'] and task['pending']:
      active_style = 'info'
    elif task['active'] and not task['pending']:
      active_style = 'error'
    else:
      active_style = ''
  %>
  <tr class="${active_style}">
   <td><a href="/api/pgn/${'%s-%d'%(run['_id'],idx)}.pgn">${idx}</a></td>
   %if 'bad' in task:
     <td style="text-decoration:line-through; background-color:#ffebeb">
   %else:
     <td>
   %endif
   %if approver and 'worker_info' in task and 'username' in task['worker_info']:
     <a href="/user/${task['worker_info']['username']}">${task['worker_key']}</a>
   %else:
     ${task['worker_key']}
   %endif
   </td>
   <td>
   %if 'worker_info' in task:
     ${task['worker_info']['uname']}
   %else:
     Unknown worker
   %endif
   </td>
   <td>${str(task.get('last_updated', '-')).split('.')[0]}</td>
   <td>${total} / ${task['num_games']}</td>
   <td>${stats.get('wins', '-')}</td>
   <td>${stats.get('losses', '-')}</td>
   <td>${stats.get('draws', '-')}</td>
   <td>${stats.get('crashes', '-')}</td>
   <td>${stats.get('time_losses', '-')}</td>
 
   %if 'spsa' not in run['args']:
   <td style="background-color:${task['residual_color']}">${'%.3f' % (task['residual'])}</td>
   %endif
  </tr>
  %endfor
 </tbody>
</table>
 
<script type="text/javascript" src="/js/highlight.diff.min.js"></script>
<script>
  $(function() {
    function fetchDiff(url, callback) {
      $.ajax({
        url: url,
        headers: {
          Accept: "application/vnd.github.v3.diff"
        },
        success: callback
      });
    }
 
    var apiUrlBase = "${base.repo(run)}".replace("//github.com/", "//api.github.com/repos/");
    fetchDiff(
      apiUrlBase + "/compare/${run['args']['resolved_base'][:7]}...${run['args']['resolved_new'][:7]}",
      function(response) {
        var numLines = response.split("\n").length;
        var $toggleBtn = $("#diff-toggle");
        var $diffContents = $("#diff-contents");
	var $diffText = $diffContents.find("code");
	$diffText.text(response);
        $toggleBtn.on("click", function() {
          $diffContents.toggle();
          if ($toggleBtn.text() === "Hide") {
            $toggleBtn.text("Show");
          } else {
            $toggleBtn.text("Hide");
          }
        });
        // Hide large diffs by default
        if (numLines < 50) {
          $diffContents.show();
          $toggleBtn.text("Hide");
        } else {
          $diffContents.hide();
          $toggleBtn.text("Show");
        }
        $("#diff-section").show();
	hljs.highlightBlock($diffText[0]);
      }
    );
 
  %if not run['finished'] and not run.get('approved', False):
    var apiUrlBaseMaster = "https://api.github.com/repos/official-stockfish/Stockfish";
    fetchDiff(
      apiUrlBaseMaster + "/compare/master...${run['args']['resolved_base'][:7]}",
      function(response) {
        var $masterDiff = $("#master-diff");
        if (response.length === 0) {
          $masterDiff.text("Base branch same as Stockfish master").addClass("alert-success");
        } else {
          $masterDiff.text("Base branch not same as Stockfish master").addClass("alert-error");
          $("#approve-btn").removeClass("btn-success").addClass("btn-warning");
        }
      }
    );
  %endif
  });
</script>
<link rel="stylesheet" href="/css/highlight.github.css">