Skip to content

Commit b4f4387

Browse files
skearnesclaude
andauthored
Bump ord-schema to 0.7 and sort datasets by submission date (#200)
ord-schema 0.7.0 splits its heavy optional dependencies into extras and adds a denormalized `dataset.submitted_at` column. - Depend on `ord-schema[orm]>=0.7,<0.8` so only the ORM extra (sqlalchemy, psycopg, inflection) is pulled in. This drops huggingface-hub and its transitive deps (hf-xet, fsspec, rich, typer, ...) from the install — 9 fewer packages (92 -> 83) and a smaller image. pygithub, still needed by the editor, remains a direct dependency. - Surface `submitted_at` (a nullable date) in `DatasetInfo` and order the `/datasets` response by it, newest first, with undated datasets last. - Add a "Submitted" column to the browse page so the ordering is visible. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 9134831 commit b4f4387

6 files changed

Lines changed: 30 additions & 144 deletions

File tree

‎app/src/views/browse/MainBrowse.scss‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
padding: 1rem 0;
2222

2323
.table-container {
24-
grid-template-columns: 1fr 1fr 1fr auto;
24+
grid-template-columns: 1fr 1fr 1fr auto auto;
2525
}
2626

2727
.loading {

‎app/src/views/browse/MainBrowse.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface Dataset {
2525
name: string;
2626
description?: string;
2727
num_reactions: number;
28+
submitted_at?: string | null;
2829
}
2930

3031
const MainBrowse: React.FC = () => {
@@ -81,6 +82,7 @@ const MainBrowse: React.FC = () => {
8182
<div className="column label">Name</div>
8283
<div className="column label">Description</div>
8384
<div className="column label">Size</div>
85+
<div className="column label">Submitted</div>
8486
{entities.map(row => (
8587
<React.Fragment key={row.dataset_id}>
8688
<div className="column">
@@ -89,6 +91,7 @@ const MainBrowse: React.FC = () => {
8991
<div className="column">{row.name}</div>
9092
<div className="column">{truncateDescription(row.description)}</div>
9193
<div className="column">{row.num_reactions}</div>
94+
<div className="column">{row.submitted_at ?? '—'}</div>
9295
</React.Fragment>
9396
))}
9497
</div>

‎ord_interface/api/search.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from __future__ import annotations
1818

19+
import datetime
1920
import gzip
2021
import json
2122
import os
@@ -209,14 +210,16 @@ class DatasetInfo(BaseModel):
209210
name: str
210211
description: str | None
211212
num_reactions: int
213+
submitted_at: datetime.date | None
212214

213215

214216
@router.get("/datasets")
215217
async def get_datasets() -> list[DatasetInfo]:
216-
"""Returns info about the current datasets."""
218+
"""Returns info about the current datasets, most recently submitted first."""
217219
async with get_cursor() as cursor:
218220
await cursor.execute(
219-
"SELECT dataset_id, name, description, num_reactions FROM dataset"
221+
"SELECT dataset_id, name, description, num_reactions, submitted_at FROM dataset "
222+
"ORDER BY submitted_at DESC NULLS LAST, dataset_id"
220223
)
221224
return [DatasetInfo(**row) async for row in cursor]
222225

@@ -226,7 +229,7 @@ async def get_dataset(dataset_id: str) -> DatasetInfo:
226229
"""Returns info about a single dataset."""
227230
async with get_cursor() as cursor:
228231
await cursor.execute(
229-
"SELECT dataset_id, name, description, num_reactions FROM dataset WHERE dataset_id = %s",
232+
"SELECT dataset_id, name, description, num_reactions, submitted_at FROM dataset WHERE dataset_id = %s",
230233
(dataset_id,),
231234
)
232235
row = await cursor.fetchone()

‎ord_interface/api/search_test.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ def test_get_datasets(test_client):
9191
response.raise_for_status()
9292
dataset_info = response.json()
9393
assert len(dataset_info) == 3
94+
assert all("submitted_at" in row for row in dataset_info)
95+
# Datasets are ordered by submission date, newest first, with undated
96+
# datasets (submitted_at is None) sorted last.
97+
submitted = [row["submitted_at"] for row in dataset_info]
98+
dated = [value for value in submitted if value is not None]
99+
assert dated == sorted(dated, reverse=True)
100+
assert submitted == dated + [None] * (len(submitted) - len(dated))
94101

95102

96103
def test_get_dataset(test_client):

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies = [
3131
"gunicorn",
3232
"jinja2>=2.0.0",
3333
"numpy>=1.26.4",
34-
"ord-schema>=0.6.32,<0.7",
34+
"ord-schema[orm]>=0.7,<0.8",
3535
"pandas>=1.0.4",
3636
"protobuf>=4.22,<6",
3737
"psycopg[binary,pool]>=3",

0 commit comments

Comments
 (0)