[PR #10] [MERGED] Fix/tree #12

Closed
opened 2026-04-10 16:03:41 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/KohakuBlueleaf/KohakuHub/pull/10
Author: @MigoXV
Created: 2/4/2026
Status: Merged
Merged: 2/8/2026
Merged by: @KohakuBlueleaf

Base: mainHead: fix/tree


📝 Commits (2)

  • f41728f fix(api): update path handling in file and directory conversion functions
  • 59a8a16 feat(lakefs): add resolve_revision function to handle branch names and commit hashes

📊 Changes

4 files changed (+69 additions, -34 deletions)

View changed files

📝 docs/api/tree.md (+1 -1)
📝 src/kohakuhub/api/files.py (+6 -20)
📝 src/kohakuhub/api/repo/routers/tree.py (+10 -13)
📝 src/kohakuhub/utils/lakefs.py (+52 -0)

📄 Description

Pull Request

What changed?

Why?

Fixes #

Testing

  • Tested locally
    This pull request refactors how file and directory paths are handled in the repository tree API, ensuring compatibility with HuggingFace's expected format. It also improves revision resolution to support both branch names and commit hashes, and simplifies related code by removing unnecessary parameters.

API compatibility and path handling:

  • Updated the meaning of the path field in both documentation and code to always be relative to the repository root, matching HuggingFace's expectations. Removed logic for stripping a prefix from paths. [1] [2] [3] [4] [5] [6]

Revision resolution improvements:

  • Added a new resolve_revision async utility that can resolve both branch names and commit hashes to a commit ID and its info, improving compatibility with clients that use either type of revision identifier.
  • Refactored the get_revision endpoint to use resolve_revision, streamlining error handling and supporting both revision types. [1] [2]

Code cleanup:

  • Removed unused parameters and imports related to prefix handling and error checking, simplifying function signatures and improving maintainability. [1] [2] [3] [4]
  • Tested in Docker (if relevant)

Checklist

  • Code follows project style (see CONTRIBUTING.md)
  • Updated docs if needed (README, API.md, CLI.md, etc.)
  • No breaking changes (or documented them)
  • Tested my changes

Screenshots


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/KohakuBlueleaf/KohakuHub/pull/10 **Author:** [@MigoXV](https://github.com/MigoXV) **Created:** 2/4/2026 **Status:** ✅ Merged **Merged:** 2/8/2026 **Merged by:** [@KohakuBlueleaf](https://github.com/KohakuBlueleaf) **Base:** `main` ← **Head:** `fix/tree` --- ### 📝 Commits (2) - [`f41728f`](https://github.com/KohakuBlueleaf/KohakuHub/commit/f41728fa602642d3b7f9ae98b1d3a3f15553b003) fix(api): update path handling in file and directory conversion functions - [`59a8a16`](https://github.com/KohakuBlueleaf/KohakuHub/commit/59a8a1646d621ebbce28f3bbcba988d8049b9e7e) feat(lakefs): add resolve_revision function to handle branch names and commit hashes ### 📊 Changes **4 files changed** (+69 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `docs/api/tree.md` (+1 -1) 📝 `src/kohakuhub/api/files.py` (+6 -20) 📝 `src/kohakuhub/api/repo/routers/tree.py` (+10 -13) 📝 `src/kohakuhub/utils/lakefs.py` (+52 -0) </details> ### 📄 Description # Pull Request ## What changed? <!-- Describe your changes --> ## Why? <!-- Why are you making this change? Link related issues --> Fixes # ## Testing <!-- How did you test this? --> - [ ] Tested locally This pull request refactors how file and directory paths are handled in the repository tree API, ensuring compatibility with HuggingFace's expected format. It also improves revision resolution to support both branch names and commit hashes, and simplifies related code by removing unnecessary parameters. **API compatibility and path handling:** * Updated the meaning of the `path` field in both documentation and code to always be relative to the repository root, matching HuggingFace's expectations. Removed logic for stripping a prefix from paths. [[1]](diffhunk://#diff-d5c5a32bfe216c3bd16a23377006c7e9917d50ad2aa16db807c23813a8d3abfeL68-R68) [[2]](diffhunk://#diff-f96ed58b1e082e02e1eaef0851a0946f390afa79d7abb7ac1d2ab4cc23e67574L133-R147) [[3]](diffhunk://#diff-f96ed58b1e082e02e1eaef0851a0946f390afa79d7abb7ac1d2ab4cc23e67574L161-R160) [[4]](diffhunk://#diff-f96ed58b1e082e02e1eaef0851a0946f390afa79d7abb7ac1d2ab4cc23e67574L182-R194) [[5]](diffhunk://#diff-f96ed58b1e082e02e1eaef0851a0946f390afa79d7abb7ac1d2ab4cc23e67574L207-R205) [[6]](diffhunk://#diff-f96ed58b1e082e02e1eaef0851a0946f390afa79d7abb7ac1d2ab4cc23e67574L293-R302) **Revision resolution improvements:** * Added a new `resolve_revision` async utility that can resolve both branch names and commit hashes to a commit ID and its info, improving compatibility with clients that use either type of revision identifier. * Refactored the `get_revision` endpoint to use `resolve_revision`, streamlining error handling and supporting both revision types. [[1]](diffhunk://#diff-3e99b8486b8e5663996bfbe280e38bb3a26f53d3369f15f732093ecc6a5b8046L31-R31) [[2]](diffhunk://#diff-3e99b8486b8e5663996bfbe280e38bb3a26f53d3369f15f732093ecc6a5b8046L311-R316) **Code cleanup:** * Removed unused parameters and imports related to prefix handling and error checking, simplifying function signatures and improving maintainability. [[1]](diffhunk://#diff-3e99b8486b8e5663996bfbe280e38bb3a26f53d3369f15f732093ecc6a5b8046L44) [[2]](diffhunk://#diff-f96ed58b1e082e02e1eaef0851a0946f390afa79d7abb7ac1d2ab4cc23e67574L133-R147) [[3]](diffhunk://#diff-f96ed58b1e082e02e1eaef0851a0946f390afa79d7abb7ac1d2ab4cc23e67574L182-R194) [[4]](diffhunk://#diff-f96ed58b1e082e02e1eaef0851a0946f390afa79d7abb7ac1d2ab4cc23e67574L293-R302) - [ ] Tested in Docker (if relevant) ## Checklist - [ ] Code follows project style (see CONTRIBUTING.md) - [ ] Updated docs if needed (README, API.md, CLI.md, etc.) - [ ] No breaking changes (or documented them) - [ ] Tested my changes ## Screenshots <!-- If UI changes, add before/after screenshots --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-10 16:03:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/KohakuHub#12