Skip to content

Improve /api/<table> schema display and surface table-description knowls (#4811, #4812)#22

Open
roed-math wants to merge 2 commits into
mainfrom
ai/t18-api-schema-knowls
Open

Improve /api/<table> schema display and surface table-description knowls (#4811, #4812)#22
roed-math wants to merge 2 commits into
mainfrom
ai/t18-api-schema-knowls

Conversation

@roed-math

Copy link
Copy Markdown
Owner

The per-table API pages (/api/<table>) get two related improvements. For LMFDB#4812, the schema table gains an Example column populated from a random row (db.<table>.random(projection=2)), with values quoted/truncated at 100 chars and [binary data] shown for bytea columns; the schema holder regains a shared schema-holder class and is now capped with max-height: 500px; overflow-y: auto in style.css instead of the dead height: 300px block left behind by an earlier div-class rename — so small tables no longer render an oversized fixed-height scroll box while large tables still scroll. For LMFDB#4811, the tables.<name> description knowl is surfaced via KNOWL_INC above the schema (read-only for everyone, with an edit link for logged-in knowl editors) instead of being appended to the page title in parentheses. Datapages share the same schema template but pass no example data, so they are unchanged apart from the holder styling; two new tests in test_api.py cover both the API-page Example column and the datapage's absence of it. Note this branch will conflict lightly at merge time with the other open API PRs (ranges/null and raw-format) since they also edit api.py/collection.html/test_api.py in nearby-but-distinct regions. Addresses LMFDB#4811 and LMFDB#4812.

🤖 Generated with Claude Code

…wls (LMFDB#4811, LMFDB#4812)

LMFDB#4812: give the schema table an Example column populated from a random
row (db.<table>.random(projection=2)), with values truncated at 100
chars, string reprs quoted, and "[binary data]" for bytea columns. The
holder div regains a shared `schema-holder` class and style.css caps it
with `max-height: 500px; overflow-y: auto` (via max-height so small
tables no longer get an oversized fixed-height scroll box) instead of the
dead `height: 300px` block, which no longer matched after the div class
was renamed. The duplicate `id="schema-table"` becomes a class.

LMFDB#4811: stop appending the table description to the page title and instead
surface the `tables.<name>` knowl via KNOWL_INC in collection.html
(read-only content for everyone, edit link for logged-in knowl editors).

Verified: sage -python -m pytest lmfdb/api/test_api.py (8 passed, incl.
two new tests); pyflakes clean on api.py and test_api.py; test-client
render of nf_fields, ec_curvedata, mf_hecke_traces, lat_lattices,
gps_groups and char_dirichlet shows a populated Example column, the
description knowl above the schema, and a title without the parenthetical;
datapages still render with no Example column; /style.css serves 200.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…DB#4812)

The /api/<table> schema Example column was sampled with
coll.random(projection=2).  Switch to projection=3, the same full
mask (id + all search + all extra columns) the datapage query already
uses, so the Example column is sampled consistently and every row shown
in the schema table can be populated.

Strengthen test_api_schema_display: instead of only asserting that
schema-example cells exist, assert that the Example cell for the
never-null search column nf_fields.degree carries an actual value, so a
future change that blanks search-column examples is caught.

Verified: sage -python -m pytest lmfdb/api/test_api.py -> 8 passed;
pyflakes clean; test-client renders of /api/nf_fields,
/api/ec_curvedata and /api/maass_newforms show nonblank Example cells
for search columns (degree, conductor, conrey_index) and the extra
column (maass_newforms.coefficients).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@roed-math

Copy link
Copy Markdown
Owner Author

Addressed the external review's P2 finding (Example column projection): commit eae9585 changes the sample to random(projection=3) and strengthens the test to assert a known search-column Example (nf_fields.degree) is nonblank.

Honest note on the diagnosis: against the pinned psycodict (roed314/psycodict 0.1.13), projection=2 already returns search+extra columns, so search-column Examples were not actually blank — the reviewer's mechanism did not reproduce here. The 2→3 change is still the right mask (it matches the datapage query and is robust to psycodict variants where 2 means extra-only), and the new nonblank assertion guards the behavior either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants