fix(spp_cel_domain): probe the legacy metric service by capability, not model name (#443) - #535
Open
gonzalesedwin1123 wants to merge 3 commits into
Open
gonzalesedwin1123 wants to merge 3 commits into
gonzalesedwin1123 wants to merge 3 commits into
Conversation
…ot model name _exec_metric and the aggregate-metric path took the presence of spp.indicator in the registry to mean the retired spp_indicators evaluation service was installed and called evaluate() on it. OpenSPP2's spp_indicator reuses that model name for an unrelated configuration model, so wherever it is installed every metric() over a variable whose cache was not fresh raised AttributeError inside the executor and the expression compiled to an error instead of the graceful empty result. Both sites now resolve the service through _legacy_metric_service(), which requires a callable evaluate(), and fall back to the SQL fast path otherwise. Refs #443
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 19.0 #535 +/- ##
==========================================
- Coverage 76.91% 75.79% -1.13%
==========================================
Files 704 736 +32
Lines 45774 51541 +5767
==========================================
+ Hits 35205 39063 +3858
- Misses 10569 12478 +1909
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…he no-service path Review round: the probe checks evaluate() and enqueue_refresh_from_domain() on the model class (a field carrying one of those names is a non-callable descriptor and never touches access checks); both no-service branches append a no_service entry to metrics_info so previews can show that metric values were unavailable; the tests use a real recordset as the name-only stand-in, assert the probed model name, and cover the evaluate-only case; changelog states the actual behaviour (empty match set, not an SQL fast path) and the deployer-visible degradation. Refs #443
Member
Author
|
Full-stack evidence: SP-MIS
|
gonzalesedwin1123
marked this pull request as ready for review
September 21, 2026 05:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #443 (weekly ci-full red). First of the per-module PRs; this one is a real production bug, not a test problem.
Problem
spp_cel_domain/models/cel_executor.py_exec_metric(and the aggregate-metric path) checks"spp.indicator" in self.envas a stand-in for "the legacyspp_indicatorsevaluation service is installed" and then callssvc.evaluate(...)/svc.enqueue_refresh_from_domain(...). That service lived in the archived openspp-modules repo. In OpenSPP2,spp_statisticwas renamed tospp_indicator(f4384f0) and itsspp.indicatoris a publishable-indicator configuration model with noevaluate(). No OpenSPP2 commit ever defined either method.So on any database with
spp_indicatorinstalled (the SP-MIS starter viaspp_mis_demo_v2,spp_api_v2_gis,spp_indicator_studio), everymetric()over a cached or external variable whose cache is not fresh raisesAttributeError: 'spp.indicator' object has no attribute 'evaluate'inside the executor.cel_service.compile_expressionswallows it and returnsvalid=False, so the whole expression compiles to an error instead of the documented graceful empty result.Per-module CI never sees it: spp_cel_domain does not depend on spp_indicator, so the "no service" branch runs there. In the weekly SP-MIS ci-full job it shows as
TestCELExecutorCacheLookup.test_metric_lookup_respects_period_key/test_metric_lookup_empty_cache_gracefulfailing withFalse is not trueonresult["valid"].Fix
A
_legacy_metric_service()helper resolves the service by capability (callable(getattr(service, "evaluate", None))) instead of by model name; both call sites use it and take the existing graceful branch when it returnsNone. The misleading "consider installing spp_indicators" warning text is corrected. No behaviour change on databases withoutspp_indicator.spp_cel_domain19.0.2.1.0 → 19.0.2.1.1 + HISTORY fragment. README/index.html left for CI's pinned generator.Evidence
Reproduced locally with
-i spp_cel_domain,spp_indicator --test-tags /spp_cel_domain:TestCELExecutorCacheLookup:2 failed, 0 error(s) of 7 tests(the two tests above)0 failed, 0 error(s) of 7 testsModule suite:
0 failed, 0 error(s) of 651 tests. Newtests/test_legacy_metric_service.py(3 tests) covers the probe in per-module CI: no model → no service; a model withoutevaluate()→ no service; a model withevaluate()→ returned. All pre-commit hooks pass on the changed files. An SP-MIS ci-full run is dispatched on this branch; its failing-test set should lose exactly these two tests against the 2026-09-20 baseline.Not in this PR (tracked in #443 research / follow-ups)
Deleting the other dead legacy probes in the same file (
spp.indicator.value,spp.indicator.registry,spp.indicator.invalidation.buffer), and finishing the ADR-017 TODO so a not-fresh lookup refreshes throughspp.data.cache.managerinstead of returning empty.