Replace assistent-personas overlay seed with assistent-extensions SFTP and an assistent: section in extensions.yaml so personalities install like other extensions without private URLs in the public repo. Co-authored-by: Cursor <cursoragent@cursor.com>
106 lines
3.3 KiB
Python
106 lines
3.3 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from gpu_rent.errors import ConfigError
|
|
from gpu_rent.manifests import (
|
|
parse_extensions,
|
|
parse_models,
|
|
remote_root_for,
|
|
repo_matches_runtime,
|
|
)
|
|
|
|
|
|
def test_models_skips_version_zero(tmp_path: Path):
|
|
path = tmp_path / "models.yaml"
|
|
path.write_text(
|
|
"checkpoint:\n - version_id: 0\n - version_id: 123\n - url: https://civitai.red/models/1?modelVersionId=9\n",
|
|
encoding="utf-8",
|
|
)
|
|
entries = parse_models(path)
|
|
assert len(entries) == 2
|
|
assert entries[0].version_id == 123
|
|
assert entries[1].url.endswith("9")
|
|
|
|
|
|
def test_extensions_empty_file(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text("swarmui: []\ncomfy: []\n", encoding="utf-8")
|
|
assert parse_extensions(path) == []
|
|
|
|
|
|
def test_extensions_repo(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text(
|
|
"swarmui:\n - url: https://github.com/org/Ext.git\n ref: main\n dir: Ext\n",
|
|
encoding="utf-8",
|
|
)
|
|
repos = parse_extensions(path)
|
|
assert repos[0].kind == "swarmui"
|
|
assert repos[0].directory == "Ext"
|
|
assert repos[0].requires == "none"
|
|
|
|
|
|
def test_extensions_requires_ollama(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text(
|
|
"swarmui:\n"
|
|
" - url: https://gitea.example/swarm-assistent.git\n"
|
|
" ref: main\n"
|
|
" dir: swarm-assistent\n"
|
|
" requires: ollama\n"
|
|
" - url: https://github.com/org/Always.git\n"
|
|
" ref: main\n",
|
|
encoding="utf-8",
|
|
)
|
|
repos = parse_extensions(path)
|
|
assert repos[0].requires == "ollama"
|
|
assert repos[1].requires == "none"
|
|
assert repo_matches_runtime(repos[0], "ollama")
|
|
assert not repo_matches_runtime(repos[0], "none")
|
|
assert repo_matches_runtime(repos[1], "none")
|
|
assert repo_matches_runtime(repos[1], "ollama")
|
|
|
|
|
|
def test_extensions_requires_any_llm(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text(
|
|
"swarmui:\n - url: https://example/x.git\n requires: any-llm\n",
|
|
encoding="utf-8",
|
|
)
|
|
repo = parse_extensions(path)[0]
|
|
assert repo.requires == "any-llm"
|
|
assert repo_matches_runtime(repo, "ollama")
|
|
assert not repo_matches_runtime(repo, "none")
|
|
|
|
|
|
def test_extensions_requires_invalid(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text(
|
|
"swarmui:\n - url: https://example/x.git\n requires: docker\n",
|
|
encoding="utf-8",
|
|
)
|
|
with pytest.raises(ConfigError, match="requires"):
|
|
parse_extensions(path)
|
|
|
|
|
|
def test_extensions_assistent_kind(tmp_path: Path):
|
|
path = tmp_path / "extensions.yaml"
|
|
path.write_text(
|
|
"assistent:\n"
|
|
" - url: https://example.com/org/sample-pack.git\n"
|
|
" ref: main\n"
|
|
" dir: sample-pack\n"
|
|
" requires: ollama\n",
|
|
encoding="utf-8",
|
|
)
|
|
repos = parse_extensions(path)
|
|
assert len(repos) == 1
|
|
assert repos[0].kind == "assistent"
|
|
assert repos[0].directory == "sample-pack"
|
|
assert remote_root_for(repos[0]) == (
|
|
"/mnt/swarm_data/Assistent/extensions/sample-pack"
|
|
)
|
|
assert repo_matches_runtime(repos[0], "ollama")
|
|
assert not repo_matches_runtime(repos[0], "none")
|