mirror of
https://github.com/KohakuBlueleaf/KohakuHub.git
synced 2026-05-05 20:07:37 -05:00
[PR #16] [MERGED] Sync dev/narugo1992: HF compat hardening, client-side preview, dev+test infra, classified-error UX #16
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/KohakuBlueleaf/KohakuHub/pull/16
Author: @narugo1992
Created: 4/26/2026
Status: ✅ Merged
Merged: 4/26/2026
Merged by: @KohakuBlueleaf
Base:
main← Head:dev/narugo1992📝 Commits (10+)
704cd67add action: delete ghost repo before create new repo51a544efix delete function in crud4c6dba6Add local development bootstrap and deterministic demo fixturesb5a6ab5Add new-tab support to repo card titles77786dfAdd new-tab support to commit links and breadcrumbse53f48bMerge pull request #2 from deepghs/dev/click98c0e02Add session-scoped repo sort preferences and timezone-aware timestamps7b29dbfMerge pull request #3 from deepghs/dev/order42b7f3fRaise LFS keep versions UI limit to 999982ea9d9Merge pull request #4 from deepghs/chore/lfs-keep-versions-max-9999📊 Changes
292 files changed (+51635 additions, -2204 deletions)
View changed files
➕
.coveragerc(+21 -0)➕
.env.dev.example(+51 -0)➕
.github/workflows/fullstack-tests.yml(+205 -0)📝
.gitignore(+12 -0)➕
Makefile(+150 -0)➕
codecov.yml(+11 -0)📝
config-example.toml(+2 -1)📝
docker-compose.example.yml(+4 -0)➕
docs/development/local-dev.md(+329 -0)📝
pyproject.toml(+4 -1)📝
pytest.ini(+11 -2)➕
scripts/dev/down_infra.sh(+26 -0)➕
scripts/dev/generate_preview_test_fixtures.py(+79 -0)➕
scripts/dev/init_lakefs.py(+152 -0)➕
scripts/dev/reset.py(+175 -0)➕
scripts/dev/reset_local_data.sh(+68 -0)➕
scripts/dev/reset_local_data_direct.py(+39 -0)➕
scripts/dev/run_backend.sh(+76 -0)➕
scripts/dev/seed_demo_data.py(+3291 -0)➕
scripts/dev/seed_shared.py(+3 -0)...and 80 more files
📄 Description
Overview
This PR proposes upstreaming the work that has accumulated on
deepghs/KohakuHub@dev/narugo1992. It supersedes the earlier exploratory PRs KohakuBlueleaf/KohakuHub#14 and KohakuBlueleaf/KohakuHub#15, which were closed as drafts while the work consolidated.The branch has been split into focused PRs in the deepghs fork (each reviewed, tested, and merged in isolation). This PR is therefore a single sync that bundles those already-reviewed pieces rather than a giant unreviewed dump.
fullstack-tests.yml)The work clusters into seven independently-reviewable themes, listed below from highest to lowest blast radius. Every change is gated by tests; the new CI job
frontend-backend-unit-testsruns the matrix on each push.🧭 Theme map
huggingface_hubmatrixhuggingface_hub, plus a deep coverage matrixErrorState(gated / not-found / unavailable / private) across file-facing surfacesdocs/development/local-dev.md_lakefs/dummymarkers on create; reorder delete toLakeFS-then-S3to avoid orphan-storage 302→403🧪 Test infrastructure & CI
The biggest single contribution by file count. Before this branch the repo had no automated test suite; now there is a service-backed backend harness, a fast in-process harness, frontend Vitest suites for both UIs, and a CI workflow that runs them against a real Postgres/MinIO/LakeFS stack.
test/conftest.py,test/kohakuhub/support/(bootstrap, seed, fakes, live server, mock HF server, service state), per-moduletest_*.pyandtest_*_unit.pytest/kohaku-hub-ui/andtest/kohaku-hub-admin/: stores, pages, utils, components, MSW setup, fixtureshuggingface_hub0.20.3 / 0.30.2 / 0.36.2 / 1.0.1 / 1.6.0 / latest, on Python 3.10 / 3.11 / 3.12.github/workflows/fullstack-tests.yml(backend + frontend + admin frontend), Codecov upload made non-fatal.coveragerc,codecov.yml; backend defaults to 80% with per-range overrides throughMakefilemake test-backend RANGE_DIR=...backend_per_testmarker for tests that need a fresh slate, no.envloading inside tests🤝 HuggingFace Hub compatibility
A cluster of compat bugs were reported by triaging real
huggingface_hubcalls against KohakuHub. Each was filed as an issue in the deepghs fork, fixed, and covered by tests in the matrix above.is_orgfieldtomllibimporttomlifallbackinternal_base_urlasync, used syncNameErroron inaccessible reposhf_hub_downloadFileMetadataError:/resolve302 lackedX-Repo-Commit/Cache-ControlBeyond bug fixes, the branch adds:
src/kohakuhub/api/repo/routers/tree.pyhuggingface_hub: HEAD semantics, real-client tests, HF seeded as a global fallback inmake seed-demosrc/kohakuhub/api/fallback/,scripts/dev/seed_demo_data.pynot_implementedAPI surface (telemetry, etc.) returning the right HF shape rather than 500src/kohakuhub/api/not_implemented.pysrc/kohaku-hub-ui/src/pages/[type]s/...gated/not-found/unavailablerather than collapsing everything to 404 (deepghs#29)src/kohakuhub/api/fallback/operations.py,utils.py🔍 Pure-client metadata preview (deepghs#27 → deepghs#28)
Adds a file-preview dialog that runs entirely in the browser: no backend reads, no precomputation, no metadata cache. Targets parity with HF's preview UX for safetensors and parquet specifically.
.safetensorsutils/safetensors.{js,test}+FilePreviewDialog.vue.parquetutils/parquet.{js,test}+FilePreviewDialog.vueutils/file_preview.{js,test}Tests live in
test/kohaku-hub-ui/utils/test_safetensors.test.js(708 lines) andtest_parquet.test.js— including binary fixtures undertest/kohaku-hub-ui/fixtures/previews/.🚦 Classified-error UX (deepghs#30, closes deepghs#31)
Standardises a single
<ErrorState>component used wherever a file or repo could be unreachable. Replaces ad-hoc toasts that masked real causes (gated repo, 404, upstream down, private without auth).ErrorStatewith retry / sign-in / request-access affordanceErrorStateErrorState<a>anchors so middle-click / Cmd-click open in new tab (deepghs#32)utils/http_errors.{js,test}(390 lines of tests) carries the classifier so every surface uses the same rules.🛠 Repo viewer & UX polish
A sequence of small, low-risk UX improvements, each landed as its own deepghs PR:
🧰 Local development bootstrap
The repo previously assumed a hand-rolled Docker stack. The branch adds a turnkey dev workflow:
make init-env.env.dev.example→.env.devif missingmake installpip install+ frontendnpm installfor both UIsmake infra-upmake seed-demomake reset-and-seedmake backendmake ui/make adminmake test-backend/make test-ui/make test-ui-adminMakefile,.env.dev.example,docker-compose.example.ymlscripts/dev/up_infra.sh,down_infra.sh,init_lakefs.py,seed_demo_data.py(3,291 lines),verify_seed_data.py,reset.py,reset_local_data.shdocs/development/local-dev.md(329-line guide)🚑 302→403 orphan-state fix (deepghs#33)
The most recent piece. A pair of related production failures were producing a 302 redirect that resolved to a 403 on subsequent reads:
storage namespace already in usepointing at our own_lakefs/dummy; user could never recreateBoth are covered by regression tests (
test/kohakuhub/api/repo/routers/test_crud_unit.py) that fail on the prior code and pass after the fix — including guardrail tests that the heal path refuses to clean a namespace containing any user object.✅ How to validate locally
CI runs the same matrix on every push.
🧷 Open issues acknowledged but not resolved here
These are deliberately deferred and tracked as open issues in the deepghs fork:
/api/telemetry/— protocol notes captured, decision to defer until HF stabilises the contractexcept Exception(168 sites) — multi-month cleanup, not a single PR🧾 Test plan
huggingface_hub0.20.3 / 0.30.2 / 0.36.2 / 1.0.1 / 1.6.0 / latesthuggingface_hubcreate_repo→upload_file→hf_hub_downloadround trip against a freshmake infra-up && make seed-demostack🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.