Spaces:
Running
Running
Download site/progress.js from HuggingFaceSwarms/PyBot: direct link, hf CLI and curl.
- Browser
- Download file 2.98 kB
-
https://huggingface.co/spaces/HuggingFaceSwarms/PyBot/resolve/8a83db9786c5d45f49d08e8b0d9f7513aca28eef/site/progress.js
- Command line
-
hf download hf://spaces/HuggingFaceSwarms/PyBot@8a83db9786c5d45f49d08e8b0d9f7513aca28eef/site/progress.js
-
curl -L -o progress.js https://huggingface.co/spaces/HuggingFaceSwarms/PyBot/resolve/8a83db9786c5d45f49d08e8b0d9f7513aca28eef/site/progress.js
2.98 kB
| async function drawProgress() { | |
| const status = document.getElementById("progress-status"); | |
| try { | |
| const response = await fetch("api/progress", {cache: "no-store"}); | |
| if (!response.ok) throw new Error("Progress data unavailable"); | |
| const data = await response.json(); | |
| const points = data.points; | |
| const extent = [points[0].revision, points[points.length - 1].revision]; | |
| const traces = [{ | |
| type: "scatter", mode: "lines", name: "PyBot", | |
| x: points.map(p => p.revision), y: points.map(p => p.score), | |
| customdata: points.map(p => p.commit), | |
| line: {color: "#eb6834", width: 2}, | |
| hovertemplate: "PyBot · revision %{x:,}<br>Win rate: %{y:.2f}%<br>Commit %{customdata}<extra></extra>" | |
| }, { | |
| type: "scatter", mode: "lines", name: "Lines of code", yaxis: "y2", | |
| x: points.map(p => p.revision), y: points.map(p => p.lines_of_code), | |
| customdata: points.map(p => p.commit), | |
| line: {color: "#287a9b", width: 2}, | |
| hovertemplate: "Revision %{x:,}<br>Lines of code: %{y:,}<br>Python source in bot/ (including blanks and comments)<br>Commit %{customdata}<extra></extra>" | |
| }, ...data.baselines.map((baseline, index) => ({ | |
| type: "scatter", mode: "lines", | |
| name: baseline.name, | |
| x: extent, y: [baseline.score, baseline.score], | |
| line: {color: ["#999999", "#555555", "#000000"][index], width: 1.5, | |
| dash: ["dot", "dash", "dashdot"][index]}, | |
| hovertemplate: `${baseline.name}<br>Win rate: %{y:.2f}%<extra></extra>` | |
| }))]; | |
| await Plotly.newPlot("progress-chart", traces, { | |
| margin: {l: 60, r: 72, t: 30, b: 60}, | |
| paper_bgcolor: "#ffffff", plot_bgcolor: "#ffffff", | |
| font: {family: "'Letter Gothic', monospace", size: 12, color: "#000000"}, | |
| xaxis: {title: {text: "PyBot commit", standoff: 12}, | |
| range: extent, gridcolor: "#eeeeee", zeroline: false, automargin: true}, | |
| yaxis: {title: {text: "Win rate (%)", standoff: 10}, rangemode: "tozero", | |
| color: "#eb6834", | |
| gridcolor: "#eeeeee", zerolinecolor: "#dddddd", automargin: true}, | |
| yaxis2: {title: {text: "Lines of code", standoff: 10}, overlaying: "y", side: "right", | |
| rangemode: "tozero", color: "#287a9b", tickformat: "~s", | |
| showgrid: false, zeroline: false, automargin: true}, | |
| showlegend: false, | |
| annotations: data.baselines.map(baseline => ({ | |
| text: baseline.name, x: 1, xref: "paper", y: baseline.score, yref: "y", | |
| xanchor: "right", yanchor: "bottom", yshift: 4, showarrow: false, | |
| font: {size: 11, color: "#000000"}, bgcolor: "#ffffff", borderpad: 2 | |
| })), | |
| hoverlabel: {bgcolor: "#ffffff", bordercolor: "#000000"} | |
| }, {responsive: true, displayModeBar: false, displaylogo: false}); | |
| status.hidden = true; | |
| } catch (error) { | |
| document.getElementById("progress-chart").hidden = true; | |
| status.textContent = "The progress chart is currently unavailable."; | |
| } | |
| } | |
| drawProgress(); | |