Repository navigation
Feat/centralize verification metrics - #949
Conversation
95b408d to
3cd189e
Compare
|
Documentation preview for this pull request is available at: |
0f09ddc to
ba1cdc8
Compare
|
Hi @FScholPer, thanks for centralizing the metrics — the direction makes a lot of sense. One issue though: the version scoping for the Component Requirements pie charts does not work as intended and silently regresses current behaviour. What happens
metrics_key = f"verification_metrics_v{version}"
metrics = CALCULATED_METRICS.get(metrics_key, {})
if not metrics:
metrics = CALCULATED_METRICS.get("verification_metrics", {})But nothing ever writes a "verification_metrics": calculate_verification_metrics(all_needs),i.e. without Effect For a report with The architecture pies are unaffected in outcome — Suggestion — one of the two, not both:
One more thing: Minor: |
…tion - Extend traceability_metrics_schema.json with verification_metrics section defining per-component status and coverage metrics - Add calculate_status_and_coverage_metrics() and calculate_verification_metrics() to compute status distribution and test coverage per component - Add get_component_status_metrics() and get_component_coverage_metrics() filter functions for needpie directives - Integrate verification_metrics into CALCULATED_METRICS global state This provides a single source of truth for verification report metrics, enabling both CI/CD checks and template consumption via sphinx_filters.
- Add version_filter parameter to calculate_status_and_coverage_metrics()
implementing the same valid_from logic as the template's req_in_report_version
- Update calculate_verification_metrics() to accept report_version parameter
- Update filter functions to lookup version-specific metrics via
verification_metrics_v{version} key with fallback to unversioned
- Update template to pass module_version to filter functions
This ensures centralized metrics match the version-scoped behavior of
the original inline needpie filters.
Sphinx-Needs may store single-value links as strings instead of lists. Ensure consistent list handling when checking component membership.
Add a section describing the structure of metrics.json output, including the new verification_metrics section for per-component status and coverage data used by verification reports.
- Add noqa: C901 for complex functions (inherent complexity from version filtering) - Add proper type hints for verification_metrics return type - Apply ruff-format fixes
- Make parse_version, RequirementInReportVersion, and any_req_in_report_version public APIs in score_sphinx_needs_templates - Update sphinx_filters.py to use public req_in_report_version - Fix version scoping in verification report pie charts to properly filter requirements by valid_from when applies_to_module_version is set - Add helper functions to reduce complexity in filter functions - Update tests to use public API instead of vars()[...] access - Add documentation note about duplicate version logic in traceability_metrics Fixes issue where Component Requirements Status/Test Coverage pie charts showed ALL requirements instead of only those in scope for a report version.
8090210 to
e8d1371
Compare
score_metrics imports req_in_report_version from score_sphinx_needs_templates, but this dependency wasn't declared in the BUILD file, causing ModuleNotFoundError in score_metamodel tests.
|
Thanks for the rework in e8d1371 — routing the version scoping through the now-public Architecture pies go empty as soon as a report version is set
valid_from = need.get("valid_from")
if valid_from:
...
linked_feat_reqs = _linked_needs_callable(need["id"], "derived_from")
return any(self(feat_req, report_version) for feat_req in linked_feat_reqs)That rule is correct for requirements, but architecture Needs satisfy neither condition. Per The template passes the version to those pies as well: Effect: for any report with Worth noting that your own earlier Architecture elements have never been version-scoped — neither in the pies nor in the tables — and there is no attribute to scope them by. Simplest fix is to only apply the version for |
The "Test Coverage" pie changes meaning depending on whether a version is setThere are two independent traceability axes in this repo, and the two branches of (a) Verification coverage — (b) Link coverage — Where each one is used today:
So the same pie, with the same title and the same Concrete consequences:
To be explicit about the intent: in this chart we only want the test/verification metric, i.e. axis (a). Link coverage is a separate concern and already has its own visualisation, so it should not leak into the verification report. Switching |
|
I think we need a meeting before we put too much work into the wrong direction that then in the end is wasted. So I wouldn't put too much effort into any one direction now without having a decision internally in Docs-As-Code of how we want to do this. |
So this is exactly the point enrich the metrics.json with verification metrics and move the calculation outside to helpers so that this can be used in both areas |
Add a section describing the structure of metrics.json output, including the new verification_metrics section for per-component status and coverage data used by verification reports.
- Add noqa: C901 for complex functions (inherent complexity from version filtering) - Add proper type hints for verification_metrics return type - Apply ruff-format fixes
- Make parse_version, RequirementInReportVersion, and any_req_in_report_version public APIs in score_sphinx_needs_templates - Update sphinx_filters.py to use public req_in_report_version - Fix version scoping in verification report pie charts to properly filter requirements by valid_from when applies_to_module_version is set - Add helper functions to reduce complexity in filter functions - Update tests to use public API instead of vars()[...] access - Add documentation note about duplicate version logic in traceability_metrics Fixes issue where Component Requirements Status/Test Coverage pie charts showed ALL requirements instead of only those in scope for a report version.
score_metrics imports req_in_report_version from score_sphinx_needs_templates, but this dependency wasn't declared in the BUILD file, causing ModuleNotFoundError in score_metamodel tests.
3620f2f to
747459b
Compare
|
@antonkri can you please check again if it fits now? |
….com/eclipse-score/docs-as-code into feat/centralize-verification-metrics
| status = count_status_filtered( | ||
| needs, component_id, category, version, req_in_report_version |
| :labels: valid, valid_inspected, invalid | ||
| :colors: #f5c518, #37a12d, #ca2828 | ||
| :legend: | ||
| :filter-func: score_metrics.sphinx_filters.get_component_status_metrics("{{ component_id }}", "requirements", "{{ module_version or '' }}") |
The merge of main (a539af8) kept this branch's module_verification_report.need and thereby dropped the ASIL B/QM split merged in #946. Restore main's template; the central metrics stay available but are no longer wired into it. sphinx-needs passes filter-func arguments verbatim after splitting on ",", so the quoted arguments from the template arrived as '"comp__x"' and every pie counted 0. Strip whitespace and quotes. Arguments still must not contain a dot: sphinx-needs resolves the module with rsplit(".", 1) over the whole call, so a version such as v1.0 breaks it. Documented and covered by a test. Also drop the unused version_filter path of calculate_status_and_coverage_metrics, which duplicated req_in_report_version.
The module verification report now takes its status and test-coverage numbers from the shared score_metrics filter functions instead of inline needpie filters, while keeping the ASIL B / QM split from #946. - count_status_filtered / count_coverage_filtered take an optional safety class; get_component_*_metrics accept it as arg4. QM counts valid_inspected as valid, ASIL lists valid_inspected first, matching the existing labels and colours. - The filter functions always count the needs handed in by needpie and no longer read metrics.json, so the report does not depend on it. - sphinx-needs splits the call on its last ".", so the version is passed as v1_0 and decoded back to v1.0. - safety_pie_row gets optional component/category/version arguments that switch the status and coverage pies to these filter functions. The platform report keeps its inline filters. A test renders both variants of safety_pie_row and checks that the filter functions count exactly what the inline filters count, per safety class and with a version scope.
|
Hi @FScholPer, thanks for the rework — the two points from my last review (architecture pies filtered by version, coverage axis) are fixed. 👍 While re-checking I found a few more things and, to keep this moving, pushed two commits on top of your branch. Short reasoning: 481318c – restore the ASIL/QM module report + decode filter-func arguments
553147b – count the module report pies with your central filter functions
Locally: 48 tests green, ruff clean. The platform report still uses inline filters; it could follow later. Happy to adjust if you see it differently. |
Resolve the conflict with #949 in _SafetyPieRow: the module report keeps counting through the score_metrics filter functions, now via score-report-pie, which gains :filter-func: support with needpie's calling convention. The needpie-only :legend: option is dropped.


📌 Description
Centralize metrics calculation as addon to the existing schema and remove inline calculation
🚨 Impact Analysis
✅ Checklist