Files
hermes-agent/tests/skills/test_optional_skill_scripts.py
Teknium 9347107cdb chore(skills): drop optional skills that official sources now cover
Removes 15 optional skills:
- huggingface-hub, trl-fine-tuning: Hugging Face's own hf-cli,
  trl-training and huggingface-llm-trainer skills ship through the
  default huggingface/skills tap, and the Hugging Face MCP is in the
  MCP catalog.
- whisper, stable-diffusion, llava, clip, audiocraft: core already
  covers them (local faster-whisper STT, image_generate, vision_analyze,
  the official ElevenLabs music and sound-effects plugins).
- pinecone, pinecone-research, qdrant, weights-and-biases: each vendor
  maintains its own skills repo; wandb/skills, qdrant/skills and
  pinecone-io/skills become default, trusted taps so the topic still
  shows up in `hermes skills browse`.
- guidance, outlines, instructor, huggingface-tokenizers: library
  cheat-sheets untouched since import; provider APIs do structured
  output natively and models write this code unaided.
2026-10-28 21:24:43 -07:00

67 lines
3.0 KiB
Python

"""Execute optional research helpers offline; upstream/SDK doubles are boundary spies.
This covers importability and client routing, not the paid evolution loop. Document policy belongs to test_skill_document_contracts.
"""
import pickle
from pathlib import Path
import runpy
import sys
from types import ModuleType, SimpleNamespace
from unittest.mock import Mock
import pytest
RESEARCH = Path(__file__).resolve().parents[2] / "optional-skills/research"
@pytest.mark.parametrize("relative", [
"scripts/parrot_openrouter.py", "templates/custom_problem_template.py",
])
def test_evolver_provider_routing(relative, monkeypatch):
# The upstream package is optional/AGPL; only its imported types are needed
# to load these scripts and exercise their own provider client functions.
class UpstreamType:
def __class_getitem__(cls, _):
return cls
for module, names in {
"cli_common": "build_hyperparameter_config_from_args register_hyperparameter_args parse_learning_log_view_type",
"evolve_problem_loop": "EvolveProblemLoop",
"learning_log": "LearningLogEntry",
"problem": "EvaluationFailureCase EvaluationResult Evaluator Mutator Organism Problem",
}.items():
stub = ModuleType(f"darwinian_evolver.{module}")
for name in names.split():
setattr(stub, name, UpstreamType)
monkeypatch.setitem(sys.modules, stub.__name__, stub)
import openai
constructor = Mock()
monkeypatch.setattr(openai, "OpenAI", constructor)
monkeypatch.setenv("OPENROUTER_API_KEY", "test-only-key")
monkeypatch.setenv("EVOLVER_MODEL", "test/provider-model")
script = runpy.run_path(str(RESEARCH / "darwinian-evolver" / relative))
create = constructor.return_value.chat.completions.create
create.return_value = SimpleNamespace(choices=[SimpleNamespace(message=SimpleNamespace(content="reply"))])
assert script["_prompt_llm"]("question") == "reply"
constructor.assert_called_once_with(api_key="test-only-key", base_url="https://openrouter.ai/api/v1")
assert create.call_args.kwargs["model"] == "test/provider-model"
assert create.call_args.kwargs["messages"] == [{"role": "user", "content": "question"}]
monkeypatch.delenv("OPENROUTER_API_KEY")
with pytest.raises(SystemExit, match="OPENROUTER_API_KEY"):
script["_client"]()
assert constructor.call_count == 1
def test_snapshot_requires_trust_before_unpickling(tmp_path, monkeypatch, capsys):
snapshot = tmp_path / "snapshot.pkl"
snapshot.write_bytes(pickle.dumps({"population_snapshot": pickle.dumps({"organisms": []})}))
script = RESEARCH / "darwinian-evolver/scripts/show_snapshot.py"
main = runpy.run_path(str(script))["main"]
monkeypatch.setattr(sys, "argv", [str(script), str(snapshot)])
with pytest.raises(SystemExit, match="refusing to unpickle"):
main()
monkeypatch.setattr(sys, "argv", [str(script), str(snapshot), "--i-trust-this-file"])
assert main() == 0
assert "# organisms: 0" in capsys.readouterr().out