Prune stale editor and Wayland surface area
Stop shipping code that implied Aman supported a two-pass editor, external API cleanup, or a Wayland scaffold when the runtime only exercises single-pass local cleanup on X11.\n\nCollapse aiprocess to the active single-pass Llama contract, delete desktop_wayland and the empty wayland extra, and make model_eval reject pass1_/pass2_ tuning keys while keeping pass1_ms/pass2_ms as report compatibility fields.\n\nRemove the unused pillow dependency, switch to SPDX-style license metadata, and clean setuptools build state before packaging so deleted modules do not leak into wheels. Update the methodology and repo guidance docs, and add focused tests for desktop adapter selection, stale param rejection, and portable wheel contents.\n\nValidate with uv lock, python3 -m unittest discover -s tests -p 'test_*.py', python3 -m py_compile src/*.py tests/*.py, and python3 -m build --wheel --sdist --no-isolation.
This commit is contained in:
parent
dd2813340b
commit
94ead25737
12 changed files with 98 additions and 811 deletions
|
|
@ -1,5 +1,3 @@
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
|
@ -14,7 +12,6 @@ if str(SRC) not in sys.path:
|
|||
|
||||
import aiprocess
|
||||
from aiprocess import (
|
||||
ExternalApiProcessor,
|
||||
LlamaProcessor,
|
||||
_assert_expected_model_checksum,
|
||||
_build_request_payload,
|
||||
|
|
@ -363,57 +360,5 @@ class EnsureModelTests(unittest.TestCase):
|
|||
self.assertIn("checksum mismatch", result.message)
|
||||
|
||||
|
||||
class ExternalApiProcessorTests(unittest.TestCase):
|
||||
def test_requires_api_key_env_var(self):
|
||||
with patch.dict(os.environ, {}, clear=True):
|
||||
with self.assertRaisesRegex(RuntimeError, "missing external api key"):
|
||||
ExternalApiProcessor(
|
||||
provider="openai",
|
||||
base_url="https://api.openai.com/v1",
|
||||
model="gpt-4o-mini",
|
||||
api_key_env_var="AMAN_EXTERNAL_API_KEY",
|
||||
timeout_ms=1000,
|
||||
max_retries=0,
|
||||
)
|
||||
|
||||
def test_process_uses_chat_completion_endpoint(self):
|
||||
response_payload = {
|
||||
"choices": [{"message": {"content": '{"cleaned_text":"clean"}'}}],
|
||||
}
|
||||
response_body = json.dumps(response_payload).encode("utf-8")
|
||||
with patch.dict(os.environ, {"AMAN_EXTERNAL_API_KEY": "test-key"}, clear=True), patch(
|
||||
"aiprocess.urllib.request.urlopen",
|
||||
return_value=_Response(response_body),
|
||||
) as urlopen:
|
||||
processor = ExternalApiProcessor(
|
||||
provider="openai",
|
||||
base_url="https://api.openai.com/v1",
|
||||
model="gpt-4o-mini",
|
||||
api_key_env_var="AMAN_EXTERNAL_API_KEY",
|
||||
timeout_ms=1000,
|
||||
max_retries=0,
|
||||
)
|
||||
out = processor.process("raw text", dictionary_context="Docker")
|
||||
|
||||
self.assertEqual(out, "clean")
|
||||
request = urlopen.call_args[0][0]
|
||||
self.assertTrue(request.full_url.endswith("/chat/completions"))
|
||||
|
||||
def test_warmup_is_a_noop(self):
|
||||
with patch.dict(os.environ, {"AMAN_EXTERNAL_API_KEY": "test-key"}, clear=True):
|
||||
processor = ExternalApiProcessor(
|
||||
provider="openai",
|
||||
base_url="https://api.openai.com/v1",
|
||||
model="gpt-4o-mini",
|
||||
api_key_env_var="AMAN_EXTERNAL_API_KEY",
|
||||
timeout_ms=1000,
|
||||
max_retries=0,
|
||||
)
|
||||
with patch("aiprocess.urllib.request.urlopen") as urlopen:
|
||||
processor.warmup(profile="fast")
|
||||
|
||||
urlopen.assert_not_called()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
42
tests/test_desktop.py
Normal file
42
tests/test_desktop.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import os
|
||||
import sys
|
||||
import types
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SRC = ROOT / "src"
|
||||
if str(SRC) not in sys.path:
|
||||
sys.path.insert(0, str(SRC))
|
||||
|
||||
import desktop
|
||||
|
||||
|
||||
class _FakeX11Adapter:
|
||||
pass
|
||||
|
||||
|
||||
class DesktopTests(unittest.TestCase):
|
||||
def test_get_desktop_adapter_loads_x11_adapter(self):
|
||||
fake_module = types.SimpleNamespace(X11Adapter=_FakeX11Adapter)
|
||||
|
||||
with patch.dict(sys.modules, {"desktop_x11": fake_module}), patch.dict(
|
||||
os.environ,
|
||||
{"XDG_SESSION_TYPE": "x11"},
|
||||
clear=True,
|
||||
):
|
||||
adapter = desktop.get_desktop_adapter()
|
||||
|
||||
self.assertIsInstance(adapter, _FakeX11Adapter)
|
||||
|
||||
def test_get_desktop_adapter_rejects_wayland_session(self):
|
||||
with patch.dict(os.environ, {"XDG_SESSION_TYPE": "wayland"}, clear=True):
|
||||
with self.assertRaises(SystemExit) as ctx:
|
||||
desktop.get_desktop_adapter()
|
||||
|
||||
self.assertIn("Wayland is not supported yet", str(ctx.exception))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
@ -105,6 +105,33 @@ class ModelEvalTests(unittest.TestCase):
|
|||
summary = model_eval.format_model_eval_summary(report)
|
||||
self.assertIn("model eval summary", summary)
|
||||
|
||||
def test_load_eval_matrix_rejects_stale_pass_prefixed_param_keys(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
model_file = Path(td) / "fake.gguf"
|
||||
model_file.write_text("fake", encoding="utf-8")
|
||||
matrix = Path(td) / "matrix.json"
|
||||
matrix.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"warmup_runs": 0,
|
||||
"measured_runs": 1,
|
||||
"timeout_sec": 30,
|
||||
"baseline_model": {
|
||||
"name": "base",
|
||||
"provider": "local_llama",
|
||||
"model_path": str(model_file),
|
||||
"profile": "default",
|
||||
"param_grid": {"pass1_temperature": [0.0]},
|
||||
},
|
||||
"candidate_models": [],
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
with self.assertRaisesRegex(RuntimeError, "unsupported param_grid key 'pass1_temperature'"):
|
||||
model_eval.load_eval_matrix(matrix)
|
||||
|
||||
def test_load_heuristic_dataset_validates_required_fields(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
dataset = Path(td) / "heuristics.jsonl"
|
||||
|
|
|
|||
|
|
@ -178,11 +178,13 @@ class PortableBundleTests(unittest.TestCase):
|
|||
tmp_path = Path(tmp)
|
||||
dist_dir = tmp_path / "dist"
|
||||
build_dir = tmp_path / "build"
|
||||
stale_build_module = build_dir / "lib" / "desktop_wayland.py"
|
||||
test_wheelhouse = tmp_path / "wheelhouse"
|
||||
for tag in portable.SUPPORTED_PYTHON_TAGS:
|
||||
target_dir = test_wheelhouse / tag
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
_write_file(target_dir / f"{tag}-placeholder.whl", "placeholder\n")
|
||||
_write_file(stale_build_module, "stale = True\n")
|
||||
env = os.environ.copy()
|
||||
env["DIST_DIR"] = str(dist_dir)
|
||||
env["BUILD_DIR"] = str(build_dir)
|
||||
|
|
@ -202,8 +204,16 @@ class PortableBundleTests(unittest.TestCase):
|
|||
version = _project_version()
|
||||
tarball = dist_dir / f"aman-x11-linux-{version}.tar.gz"
|
||||
checksum = dist_dir / f"aman-x11-linux-{version}.tar.gz.sha256"
|
||||
wheel_path = dist_dir / f"aman-{version}-py3-none-any.whl"
|
||||
self.assertTrue(tarball.exists())
|
||||
self.assertTrue(checksum.exists())
|
||||
self.assertTrue(wheel_path.exists())
|
||||
with zipfile.ZipFile(wheel_path) as archive:
|
||||
wheel_names = set(archive.namelist())
|
||||
metadata_path = f"aman-{version}.dist-info/METADATA"
|
||||
metadata = archive.read(metadata_path).decode("utf-8")
|
||||
self.assertNotIn("desktop_wayland.py", wheel_names)
|
||||
self.assertNotIn("Requires-Dist: pillow", metadata)
|
||||
with tarfile.open(tarball, "r:gz") as archive:
|
||||
names = set(archive.getnames())
|
||||
prefix = f"aman-x11-linux-{version}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue