davanstrien HF Staff commited on
Commit
3b09353
·
verified ·
1 Parent(s): 6121f46

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +35 -80
index.html CHANGED
@@ -5,7 +5,7 @@
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
- <script src="https://cdnjs.cloudflare.com/ajax/libs/duckdb/0.10.1/duckdb.min.js"></script>
9
  <style>
10
  body {
11
  font-family: 'Source Sans Pro', system-ui, -apple-system, sans-serif;
@@ -42,48 +42,7 @@
42
  margin: 0;
43
  }
44
 
45
- .grid {
46
- display: flex;
47
- flex-direction: column;
48
- gap: 2rem;
49
- }
50
-
51
- .card {
52
- background: white;
53
- border-radius: 12px;
54
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
55
- padding: 1.5rem;
56
- border: 1px solid #e5e7eb;
57
- }
58
-
59
- .card-title {
60
- font-size: 1.25rem;
61
- font-weight: 600;
62
- margin-bottom: 1rem;
63
- color: #111827;
64
- }
65
-
66
- .iframe-container {
67
- border-radius: 8px;
68
- overflow: hidden;
69
- background: #fff;
70
- }
71
-
72
- iframe {
73
- border: none;
74
- width: 100%;
75
- display: block;
76
- }
77
-
78
- @media (max-width: 768px) {
79
- body {
80
- padding: 1rem;
81
- }
82
-
83
- .card {
84
- padding: 1rem;
85
- }
86
- }
87
  </style>
88
  </head>
89
  <body>
@@ -96,57 +55,53 @@
96
  <p>Loading total annotations...</p>
97
  </div>
98
 
99
- <div class="grid">
100
- <div class="card">
101
- <div class="card-title">User Leaderboard</div>
102
- <div class="iframe-container">
103
- <iframe
104
- src="https://huggingface.co/datasets/davanstrien/progress/embed/sql-console/NbscKj4"
105
- frameborder="0"
106
- height="560px">
107
- </iframe>
108
- </div>
109
- </div>
110
-
111
- <div class="card">
112
- <div class="card-title">Language Leaderboard</div>
113
- <div class="iframe-container">
114
- <iframe
115
- src="https://huggingface.co/datasets/davanstrien/progress/embed/sql-console/5Bhx9Ck"
116
- frameborder="0"
117
- height="560px">
118
- </iframe>
119
- </div>
120
- </div>
121
- </div>
122
  </div>
123
 
124
  <script>
125
  async function initDuckDB() {
126
- const JSDELIVR_BUNDLES = "https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm/dist";
127
- const DUCKDB_BUNDLES = {
128
- mvp: {
129
- mainModule: JSDELIVR_BUNDLES + "/duckdb-mvp.wasm",
130
- mainWorker: JSDELIVR_BUNDLES + "/duckdb-browser-mvp.worker.js",
131
- },
132
- };
133
-
134
- const db = await duckdb.createWorker(DUCKDB_BUNDLES);
135
-
136
  try {
137
- const result = await db.query(`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  SELECT SUM(submitted) as total_annotations
139
- FROM 'hf://datasets/davanstrien/progress@~parquet/train/*.parquet'
140
  `);
141
 
142
- const totalAnnotations = result[0].total_annotations;
143
  document.getElementById('total-annotations').innerHTML =
144
  `<p>Total annotations submitted: <strong>${totalAnnotations.toLocaleString()}</strong></p>`;
145
 
 
 
 
146
  } catch (error) {
147
  console.error('Error:', error);
148
  document.getElementById('total-annotations').innerHTML =
149
- '<p>Error loading total annotations</p>';
150
  }
151
  }
152
 
 
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
+ <script src="https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.29.0/dist/duckdb-browser.js"></script>
9
  <style>
10
  body {
11
  font-family: 'Source Sans Pro', system-ui, -apple-system, sans-serif;
 
42
  margin: 0;
43
  }
44
 
45
+ /* Rest of the styles remain the same */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  </style>
47
  </head>
48
  <body>
 
55
  <p>Loading total annotations...</p>
56
  </div>
57
 
58
+ <!-- Rest of the HTML remains the same -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  </div>
60
 
61
  <script>
62
  async function initDuckDB() {
 
 
 
 
 
 
 
 
 
 
63
  try {
64
+ // Get the bundle from JSDelivr
65
+ const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
66
+
67
+ // Select a bundle based on browser checks
68
+ const bundle = await duckdb.selectBundle(JSDELIVR_BUNDLES);
69
+
70
+ // Create a worker URL
71
+ const worker_url = URL.createObjectURL(
72
+ new Blob([`importScripts("${bundle.mainWorker}");`], {type: 'text/javascript'})
73
+ );
74
+
75
+ // Initialize the database
76
+ const worker = new Worker(worker_url);
77
+ const logger = new duckdb.ConsoleLogger();
78
+ const db = new duckdb.AsyncDuckDB(logger, worker);
79
+ await db.instantiate(bundle.mainModule, bundle.pthreadWorker);
80
+ URL.revokeObjectURL(worker_url);
81
+
82
+ // Create a connection
83
+ const conn = await db.connect();
84
+
85
+ // Load the httpfs extension for remote file access
86
+ await conn.query(`INSTALL httpfs; LOAD httpfs;`);
87
+
88
+ // Query total annotations
89
+ const result = await conn.query(`
90
  SELECT SUM(submitted) as total_annotations
91
+ FROM 'https://huggingface.co/datasets/davanstrien/progress/resolve/main/train/train.parquet'
92
  `);
93
 
94
+ const totalAnnotations = result.get(0).total_annotations;
95
  document.getElementById('total-annotations').innerHTML =
96
  `<p>Total annotations submitted: <strong>${totalAnnotations.toLocaleString()}</strong></p>`;
97
 
98
+ // Close the connection
99
+ await conn.close();
100
+
101
  } catch (error) {
102
  console.error('Error:', error);
103
  document.getElementById('total-annotations').innerHTML =
104
+ `<p>Error loading total annotations: ${error.message}</p>`;
105
  }
106
  }
107