davanstrien HF staff commited on
Commit
75883a1
·
verified ·
1 Parent(s): 6c4c663

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +2 -200
index.html CHANGED
@@ -1,14 +1,10 @@
1
- <!DOCTYPE html>
2
  <html>
3
  <head>
4
  <meta charset="utf-8" />
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Leaderboards</title>
7
  <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600&display=swap" rel="stylesheet" />
8
- <!-- Load DuckDB WASM bundles -->
9
- <script src="https://cdn.jsdelivr.net/npm/@duckdb/[email protected]/dist/duckdb-browser-blocking.js"></script>
10
- <script src="https://cdn.jsdelivr.net/npm/@duckdb/[email protected]/dist/duckdb-browser.js"></script>
11
- <!-- Add loading indicator styles -->
12
  <style>
13
  body {
14
  font-family: 'Source Sans Pro', system-ui, -apple-system, sans-serif;
@@ -29,22 +25,6 @@
29
  color: #111827;
30
  }
31
 
32
- .summary {
33
- text-align: center;
34
- margin-bottom: 2rem;
35
- padding: 1rem;
36
- background: white;
37
- border-radius: 12px;
38
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
39
- border: 1px solid #e5e7eb;
40
- }
41
-
42
- .summary p {
43
- font-size: 1.1rem;
44
- color: #374151;
45
- margin: 0;
46
- }
47
-
48
  .grid {
49
  display: flex;
50
  flex-direction: column;
@@ -78,39 +58,6 @@
78
  display: block;
79
  }
80
 
81
- /* Loading indicator styles */
82
- .loading {
83
- display: inline-block;
84
- width: 20px;
85
- height: 20px;
86
- border: 3px solid rgba(0,0,0,.1);
87
- border-radius: 50%;
88
- border-top-color: #3b82f6;
89
- animation: spin 1s ease-in-out infinite;
90
- margin-right: 10px;
91
- vertical-align: middle;
92
- }
93
-
94
- @keyframes spin {
95
- to { transform: rotate(360deg); }
96
- }
97
-
98
- .error {
99
- color: #dc2626;
100
- padding: 1rem;
101
- background: #fee2e2;
102
- border-radius: 8px;
103
- margin: 1rem 0;
104
- }
105
-
106
- .success {
107
- color: #059669;
108
- padding: 1rem;
109
- background: #d1fae5;
110
- border-radius: 8px;
111
- margin: 1rem 0;
112
- }
113
-
114
  @media (max-width: 768px) {
115
  body {
116
  padding: 1rem;
@@ -127,11 +74,6 @@
127
  <header class="header">
128
  <h1>Leaderboards</h1>
129
  </header>
130
-
131
- <div class="summary" id="total-annotations">
132
- <div class="loading"></div>
133
- <span>Loading total annotations...</span>
134
- </div>
135
 
136
  <div class="grid">
137
  <div class="card">
@@ -157,145 +99,5 @@
157
  </div>
158
  </div>
159
  </div>
160
-
161
- <script type="module">
162
- // Import DuckDB
163
- import * as duckdb from 'https://cdn.jsdelivr.net/npm/@duckdb/[email protected]/+esm'
164
-
165
- class DuckDBLoader {
166
- constructor() {
167
- this.db = null;
168
- this.conn = null;
169
- }
170
-
171
- async initialize() {
172
- try {
173
- // Get the bundle from JSDelivr
174
- const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
175
-
176
- // Select a bundle based on browser checks
177
- const bundle = await duckdb.selectBundle(JSDELIVR_BUNDLES);
178
-
179
- // Create a worker URL
180
- const worker_url = URL.createObjectURL(
181
- new Blob([`importScripts("${bundle.mainWorker}");`], {type: 'text/javascript'})
182
- );
183
-
184
- // Initialize the database
185
- const worker = new Worker(worker_url);
186
- const logger = new duckdb.ConsoleLogger();
187
- this.db = new duckdb.AsyncDuckDB(logger, worker);
188
-
189
- // Instantiate with error handling
190
- try {
191
- await this.db.instantiate(bundle.mainModule, bundle.pthreadWorker);
192
- } catch (error) {
193
- throw new Error(`DuckDB instantiation failed: ${error.message}`);
194
- }
195
-
196
- URL.revokeObjectURL(worker_url);
197
-
198
- // Create connection
199
- this.conn = await this.db.connect();
200
-
201
- // Initialize extensions
202
- await this.initializeExtensions();
203
-
204
- return true;
205
- } catch (error) {
206
- this.handleError('Initialization failed', error);
207
- return false;
208
- }
209
- }
210
-
211
- async initializeExtensions() {
212
- try {
213
- await this.conn.query(`INSTALL httpfs;`);
214
- await this.conn.query(`LOAD httpfs;`);
215
- } catch (error) {
216
- throw new Error(`Failed to initialize extensions: ${error.message}`);
217
- }
218
- }
219
-
220
- async queryTotalAnnotations() {
221
- try {
222
- const result = await this.conn.query(`
223
- SELECT SUM(submitted) as total_annotations
224
- FROM 'https://huggingface.co/datasets/davanstrien/progress/resolve/main/train/train.parquet'
225
- `);
226
-
227
- if (!result || !result.get || result.length === 0) {
228
- throw new Error('Query returned no results');
229
- }
230
-
231
- const totalAnnotations = result.get(0).total_annotations;
232
- if (totalAnnotations === null || totalAnnotations === undefined) {
233
- throw new Error('No annotation count found in result');
234
- }
235
-
236
- return totalAnnotations;
237
- } catch (error) {
238
- throw new Error(`Failed to query annotations: ${error.message}`);
239
- }
240
- }
241
-
242
- handleError(context, error) {
243
- console.error(context, error);
244
- const errorMessage = error.message || 'Unknown error occurred';
245
- const errorDetails = error instanceof WebAssembly.Exception ?
246
- '(WebAssembly Exception)' : '';
247
-
248
- document.getElementById('total-annotations').innerHTML = `
249
- <div class="error">
250
- Error: ${context}: ${errorMessage} ${errorDetails}
251
- </div>
252
- `;
253
- }
254
-
255
- async cleanup() {
256
- if (this.conn) {
257
- await this.conn.close();
258
- }
259
- if (this.db) {
260
- await this.db.terminate();
261
- }
262
- }
263
- }
264
-
265
- async function initializeApplication() {
266
- const loader = new DuckDBLoader();
267
-
268
- try {
269
- // Initialize DuckDB
270
- const initialized = await loader.initialize();
271
- if (!initialized) {
272
- return;
273
- }
274
-
275
- // Query total annotations
276
- const totalAnnotations = await loader.queryTotalAnnotations();
277
-
278
- // Update UI with success
279
- document.getElementById('total-annotations').innerHTML = `
280
- <div class="success">
281
- Total annotations submitted: <strong>${totalAnnotations.toLocaleString()}</strong>
282
- </div>
283
- `;
284
-
285
- } catch (error) {
286
- loader.handleError('Failed to load annotations', error);
287
- } finally {
288
- // Cleanup resources
289
- await loader.cleanup();
290
- }
291
- }
292
-
293
- // Start the application when the DOM is ready
294
- if (document.readyState === 'loading') {
295
- document.addEventListener('DOMContentLoaded', initializeApplication);
296
- } else {
297
- initializeApplication();
298
- }
299
- </script>
300
  </body>
301
  </html>
 
1
+ <!doctype html>
2
  <html>
3
  <head>
4
  <meta charset="utf-8" />
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>SQL Console Demos</title>
7
  <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600&display=swap" rel="stylesheet" />
 
 
 
 
8
  <style>
9
  body {
10
  font-family: 'Source Sans Pro', system-ui, -apple-system, sans-serif;
 
25
  color: #111827;
26
  }
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  .grid {
29
  display: flex;
30
  flex-direction: column;
 
58
  display: block;
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  @media (max-width: 768px) {
62
  body {
63
  padding: 1rem;
 
74
  <header class="header">
75
  <h1>Leaderboards</h1>
76
  </header>
 
 
 
 
 
77
 
78
  <div class="grid">
79
  <div class="card">
 
99
  </div>
100
  </div>
101
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  </body>
103
  </html>