Update CLI and roadmap documentation; clean up code

- Revised CLI documentation to clarify the sequence of operations for the `up` command and updated the status of features.
- Enhanced the roadmap with completed tasks marked as done.
- Removed unused import in clone_ext.py for cleaner code.
- Added assertions in test_bootstrap.py to ensure correct script generation and validate the presence of autocompletion data.
This commit is contained in:
Leonid Pershin
2026-08-21 03:13:31 +03:00
parent 615cf81493
commit c2ca39a4a7
5 changed files with 69 additions and 9 deletions
+59
View File
@@ -0,0 +1,59 @@
from pathlib import Path
from gpu_rent.civitai import pick_primary_file
from gpu_rent.manifests import extract_version_id, repo_dirname, parse_models
from gpu_rent.payload import has_payload, model_push_set
from gpu_rent.remote.clone_ext import is_sha, strip_auth, with_token
def test_extract_version_id():
assert extract_version_id("https://civitai.red/models/1?modelVersionId=9") == 9
assert extract_version_id("https://civitai.com/api/download/models/77") == 77
def test_parse_models_fills_id_from_url(tmp_path: Path):
path = tmp_path / "m.yaml"
path.write_text("lora:\n - url: https://civitai.red/models/1?modelVersionId=42\n", encoding="utf-8")
entries = parse_models(path)
assert entries[0].version_id == 42
def test_repo_dirname():
from gpu_rent.manifests import GitRepo
repo = GitRepo(kind="swarmui", url="https://github.com/org/SwarmUI-Foo.git", ref="main", directory=None)
assert repo_dirname(repo) == "SwarmUI-Foo"
def test_pick_primary_file():
version = {
"files": [
{"name": "a.ckpt", "primary": False},
{"name": "b.safetensors", "primary": True},
]
}
assert pick_primary_file(version)["name"] == "b.safetensors"
def test_payload_pairs_sidecar_skips_orphan(tmp_path: Path):
root = tmp_path / "Models" / "Lora"
root.mkdir(parents=True)
(root / ".gitkeep").write_text("x", encoding="utf-8")
(root / "README.md").write_text("x", encoding="utf-8")
(root / "foo.safetensors").write_bytes(b"weights")
(root / "foo.civitai.json").write_text("{}", encoding="utf-8")
(root / "orphan.json").write_text("{}", encoding="utf-8")
names = {p.name for p in model_push_set(tmp_path / "Models")}
assert names == {"foo.safetensors", "foo.civitai.json"}
empty = tmp_path / "Wildcards"
empty.mkdir()
(empty / ".gitkeep").write_text("", encoding="utf-8")
assert not has_payload(empty)
def test_git_token_injection():
url = "https://github.com/org/Ext.git"
assert "x-access-token:secret@" in with_token(url, "secret")
assert strip_auth(with_token(url, "secret")) == url
assert is_sha("a" * 40)
assert not is_sha("main")