Skip to content

fix(repo): keep the clone of a repo whose branch contains a slash - #1252

Open
goranai wants to merge 2 commits into
bentoml:mainfrom
goranai:fix/repo-update-slash-branch
Open

goranai wants to merge 2 commits into
bentoml:mainfrom
goranai:fix/repo-update-slash-branch

Conversation

@goranai

@goranai goranai commented Nov 14, 2026

Copy link
Copy Markdown

Fixes #1251

openllm repo update deletes the clone of a repo added with a slash branch such as release/1.0. The cleanup loop in cmd_update compares the last 4 path parts with (server, owner, repo, branch). A slash branch is cloned two levels deep, so the 4th level is only the first part of the branch (release) and never matches. The fresh clone is removed right after it is made, and the repo lists no models.

The fix is 3 changed lines in src/openllm/repo.py:

  • repos_in_use now holds repo.path instead of a 4-part tuple.
  • The cleanup keeps a directory if it equals an in-use path or is a parent of one.

Test: this adds tests/test_repo_update.py. The repo had no tests/ directory before, and CI has no pytest step, so delete the file if you do not want it. The test runs the real update command through the Typer app with a fake _clone_repo. It has 4 cases. On main, release/1.0 and a/b/c fail and the other 2 pass. With the fix, all 4 pass. One case checks that a stale unused cache is still removed. bentoml analytics is stubbed in the test, so bentoml is not needed to run it.

I also ran the real CLI end to end with the real bentoml/openllm-models repo, a real git clone and a real slash branch. On main the clone is deleted and 0 models are listed. With the fix 66 models are listed. In 1500 random scenarios, in-use clones deleted: 1979 on main, 0 with the fix.

Known limit: a stale clone that sits next to an in-use slash branch under the same first segment is kept. For example, stale release/1.0 stays while release/2.0 is configured. The cleanup only walks 4 levels. This is leftover disk use only. No in-use clone is deleted. It happened in 12 of the 1500 scenarios.

ruff check, ruff format, mypy --strict and editorconfig-checker pass on the changed files.

Validated with Claude Opus 5.5.

🤖 Generated with Claude Code

goranai and others added 2 commits November 14, 2026 14:48
The cleanup in cmd_update compared the last 4 path parts with
(server, owner, repo, branch). A branch like release/1.0 is cloned two
levels deep, so its clone never matched and was deleted right after
the update. Track the full repo path and keep it and its parents.

Fixes bentoml#1251

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pre-commit.ci runs mypy --strict without pytest installed, so
@pytest.fixture and @pytest.mark.parametrize count as untyped
decorators. Use a plain helper and one test per branch instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

bug: openllm repo update deletes the clone of a repo added with a slash branch

1 participant