feat(scheduler): register drift metric calculators with MetricsDirectory#185
feat(scheduler): register drift metric calculators with MetricsDirectory#185SudipSinha wants to merge 4 commits into
Conversation
|
Warning Review limit reached
More reviews will be available in 33 minutes and 26 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The Prometheus scheduler found scheduled drift metric requests but had no calculator to compute them, logging "No calculator found for metric CompareMeans" every 5 seconds indefinitely. Add calculator functions for CompareMeans, KSTest, and JensenShannon that fetch reference data via get_dataframe_by_tag and return MetricValueCarrier with per-feature values. Make _calculate_metric async to support async calculators. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Sudip Sinha <Sudip.Sinha@RedHat.com>
88e6575 to
f962c59
Compare
|
PR image build and manifest generation completed successfully! 📦 PR image: 🗂️ CI manifests |
…ted names Three Prometheus sub-problems: A) Deprecated schedule_meanshift overwrites metric_name to CompareMeans, so the Prometheus gauge is trustyai_comparemeans instead of trustyai_meanshift. Fix: set metric_name to DEPRECATED_METRIC_NAME before delegating, and only set METRIC_NAME if not already set. B) METRIC_NAME constants used mixed case (KSTest, CompareMeans) but Java uses uppercase (KSTEST, COMPAREMEANS). The integration test checks metric_name.upper(), causing case mismatch. Fix: uppercase all METRIC_NAME constants. C) KSTestStreaming calculator is missing — noted for PR #99 branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Sudip Sinha <Sudip.Sinha@RedHat.com>
Deprecated list and delete endpoints delegated to canonical versions that query scheduler by METRIC_NAME, but requests were stored under DEPRECATED_METRIC_NAME. Parameterize list/delete functions to accept metric_name, pass DEPRECATED_METRIC_NAME from deprecated wrappers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Sudip Sinha <Sudip.Sinha@RedHat.com>
3084ada to
ef7b9a7
Compare
…ted names Deprecated endpoints store requests under DEPRECATED_METRIC_NAME but the calculator was only registered under METRIC_NAME. The scheduler couldn't find a calculator for "MEANSHIFT" requests. Register under both names so deprecated scheduled metrics compute correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Sudip Sinha <Sudip.Sinha@RedHat.com>
Summary
All 8 Prometheus metric tests timeout because drift metric calculators are never registered with
MetricsDirectory. The scheduler finds scheduled requests but logs "No calculator found for metric CompareMeans" every 5 seconds indefinitely.Root cause
The
MetricsDirectoryrequires each metric to register a calculator function at module load time. Only fairness metrics (SPD, DIR) and Batch Mean registered calculators. None of the drift metrics did.The fix
Add async calculator functions and module-level registration for three drift metrics:
calculate_compare_means_metricusingCompareMeans.ttest_indcalculate_kstest_metricusingKolmogorovSmirnov.kstestcalculate_jensenshannon_metricusingJensenShannon.jensenshannonEach calculator:
batch(current data from scheduler) andrequest(withreference_tag,fit_columns)data_source.get_dataframe_by_tag(model_id, reference_tag)MetricValueCarrier(named_values)for Prometheus publishingSince drift calculators need async
get_dataframe_by_tag,_calculate_metricin the scheduler is now async. It detects whether a calculator returns a coroutine and awaits it if so — sync calculators (SPD, DIR) still work unchanged.Files changed
src/endpoints/metrics/drift/compare_means.pysrc/endpoints/metrics/drift/kolmogorov_smirnov.pysrc/endpoints/metrics/drift/jensen_shannon.pysrc/service/prometheus/prometheus_scheduler.py_calculate_metricasync, addasyncioimporttests/endpoints/metrics/drift/test_drift_calculators.pyTest plan
MetricValueCarrierreturns per-feature named valuestest_derives_columns_from_batchverifies emptyfit_columnsfalls back to batch columnsruff checkclean (no noqa needed)ruff formatcleanpyrefly checkcleanGET /q/metricsshows drift metric gauge values after scheduled computationNote
The streaming KS test (
KSTestStreaming) and MMD calculators need the same treatment on their respective feature branches (PRs #99 and #149).🤖 Generated with Claude Code