Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N
There was a problem hiding this comment.
Code Review
This pull request removes the direct application of metric configurations to the global metrics_registry within the MetricPipeline constructor and add_metrics method, ensuring configurations remain local to each pipeline instance. It also adds a comprehensive test suite to verify this isolation. The review feedback correctly identifies that asserting on the list order of pivoted Polars DataFrames can lead to flaky tests, and suggests sorting the results by the perturbation column before performing assertions.
| assert configured.get_results()["discrimination_score_l1"].to_list() == [0.5, 1.0] | ||
| assert default.get_results()["discrimination_score_l1"].to_list() == [1.0, 1.0] |
There was a problem hiding this comment.
The row order of a pivoted Polars DataFrame (returned by get_results()) is not guaranteed to be stable or deterministic across different Polars versions or platforms. Relying on the exact list order (e.g., to_list() == [0.5, 1.0]) can lead to fragile or flaky tests. Consider sorting the DataFrame by the perturbation column before asserting to ensure a deterministic order.
| assert configured.get_results()["discrimination_score_l1"].to_list() == [0.5, 1.0] | |
| assert default.get_results()["discrimination_score_l1"].to_list() == [1.0, 1.0] | |
| configured_results = configured.get_results().sort("perturbation") | |
| default_results = default.get_results().sort("perturbation") | |
| assert configured_results["discrimination_score_l1"].to_list() == [0.5, 1.0] | |
| assert default_results["discrimination_score_l1"].to_list() == [1.0, 1.0] |
| assert before["discrimination_score_l1"].to_list() == [1.0, 1.0] | ||
| assert configured["discrimination_score_l1"].to_list() == [0.5, 1.0] |
There was a problem hiding this comment.
The row order of a pivoted Polars DataFrame is not guaranteed to be stable or deterministic across different Polars versions or platforms. Relying on the exact list order (e.g., to_list() == [0.5, 1.0]) can lead to fragile or flaky tests. Consider sorting the DataFrame by the perturbation column before asserting to ensure a deterministic order.
| assert before["discrimination_score_l1"].to_list() == [1.0, 1.0] | |
| assert configured["discrimination_score_l1"].to_list() == [0.5, 1.0] | |
| assert before.sort("perturbation")["discrimination_score_l1"].to_list() == [1.0, 1.0] | |
| assert configured.sort("perturbation")["discrimination_score_l1"].to_list() == [0.5, 1.0] |
There's a bug in
MetricPipeline.__init__: it andadd_metricswrite pipeline configurations into the shared metric registry, changing defaults for other pipelines and evaluator calls.In the regression fixture, A's
discrimination_score_l1is 1.0 by default and 0.5 withexclude_target_gene=False. After the override, another default evaluation returns 0.5 instead of 1.0. Configuring another pipeline also changes a default pipeline created beforehand.This removes both registry writes. The existing runtime override path applies each pipeline's configuration when computing metrics.
Test:
test_pipeline_configs_are_localandtest_evaluator_does_not_retain_previous_call_configintests/test_pipeline_config.pyfail on main and pass here. Full suite: 55 passed; Ruff formatting and CLI help pass.ty checkretains the same seven baseline diagnostics.🤖 Generated with Claude Code
https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N