Skip to content

chore(query): drop unused rag extras and the executor's dead template directory - #127

Merged
codeasier merged 2 commits into
mainfrom
chore/issue-121-remove-dead-template-loading
Sep 18, 2026
Merged

codeasier merged 2 commits into
mainfrom
chore/issue-121-remove-dead-template-loading

Conversation

@codeasier

Copy link
Copy Markdown
Owner

📝 Description

Two leftovers that no longer match the implementation:

1. rag optional dependencies are unused. pyproject.toml declared rag = ["chromadb>=0.4.0", "langchain>=0.1.0"], but nothing in src/, tests/, benchmarks/, docs/, or skills/ imports or mentions them. pip install "pt-snap-cli[rag]" pulled two large dependency trees and enabled nothing. The group is removed; dev is now the only extra.

2. QueryExecutor had a template loader that could never load anything. QueryService._get_executor() passed template_dir=.../query/templates, and QueryExecutor._load_templates() globbed *.yaml non-recursively. Every packaged template lives in a category subdirectory (basic/, business/, statistical/), so the glob never matched, _configs stayed empty on the product path, and _find_template() always fell through to the registry — the real loader, which is recursive and infers category from the directory. Two loaders with different semantics for the same files is an invitation to drift, and AGENTS.md only ever described the registry one.

Changes (option A from #121, the minimal one):

  • Remove the template_dir parameter, _template_dir, and _load_templates() from QueryExecutor; QueryService constructs it with the context alone.
  • Keep load_config() / register_template() as the explicit runtime-attachment APIs (they are exercised by tests/query/test_executor.py); runtime-registered templates still take precedence over registry entries of the same name.
  • src/pt_snap_cli/query/AGENTS.md now states that the registry is the sole loader for packaged templates and what _configs holds.
  • Drop the now-unused warnings import.

execute_on_all_devices() and validate_output() are left as-is; #121 only asked for a decision, and they remain covered public API of the executor.

🔗 Related Issue

Fixes #121

🧪 Testing

  • Tests added/updated
  • Manual testing completed

New tests in tests/query/test_executor.py:

  • test_packaged_templates_resolve_through_registry_only — a fresh executor has _configs == {} yet resolves leak_detection and lists it, pinning the registry fallback.
  • test_runtime_registered_template_shadows_registry — register_template() still overrides a registry template of the same name.

Full suite (macOS, Python 3.13.11): 771 passed, 1 xfailed. ruff check . / black --check . clean. tomllib confirms optional-dependencies == ['dev']. End-to-end: pt-snap import of a fixture followed by pt-snap query --template-use memory_peak still returns the peak row through the service path.

✅ Checklist

  • Code follows project guidelines
  • Documentation updated (if applicable)
  • No new warnings introduced
  • Changes tested locally

Snapshot Runtime Provenance

  • Snapshot provenance evaluation completed when snapshot runtime files change
    Snapshot provenance decision: no-update
    Snapshot provenance no-update reason: This PR changes pyproject.toml extras, the query executor/service, query AGENTS.md, and executor tests; no files under src/pt_snap_cli/snapshot/ are touched.

📋 Additional Notes

Merge order relative to #126 (parameter validation) does not matter; the two PRs touch different parts of executor.py/query_service.py and both apply cleanly on main.

… directory

The `rag` optional-dependency group (chromadb, langchain) has no consumer
anywhere in the package, tests, docs, or skills; installing
`pt-snap-cli[rag]` pulled two large dependencies and enabled nothing.

QueryExecutor also carried its own template loader: a non-recursive
`*.yaml` glob over the `template_dir` that QueryService passed in. Every
packaged template lives in a category subdirectory, so that glob never
matched and `_configs` stayed empty on the product path; lookups always
fell through to the registry, which is the real (recursive, category-
inferring) loader. Keeping a second loader with different semantics only
invited drift.

Remove the `template_dir` parameter and `_load_templates()`, construct the
executor with the context alone, and document that the registry is the
sole loader for packaged templates while `load_config()` /
`register_template()` remain the explicit runtime-attachment APIs. Add
tests pinning registry fallback and runtime-override precedence.

Fixes #121
Keep main's v1/v2 callstack layout executor while dropping the dead
non-recursive template_dir loader.
@codeasier
codeasier merged commit cfcff71 into main Sep 18, 2026
6 checks passed
@codeasier
codeasier deleted the chore/issue-121-remove-dead-template-loading branch October 3, 2026 19:18
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.

[FEATURE] 清理未使用的 rag 可选依赖,并统一 QueryExecutor 中永远为空的模板加载路径

1 participant