Skip to content

Keep MetricPipeline configurations out of the shared registry - #249

Open
rpinho wants to merge 1 commit into
ArcInstitute:mainfrom
rpinho:fix-local-metric-config
Open

rpinho wants to merge 1 commit into
ArcInstitute:mainfrom
rpinho:fix-local-metric-config

Conversation

@rpinho

@rpinho rpinho commented Nov 16, 2026

Copy link
Copy Markdown

There's a bug in MetricPipeline.__init__: it and add_metrics write pipeline configurations into the shared metric registry, changing defaults for other pipelines and evaluator calls.

In the regression fixture, A's discrimination_score_l1 is 1.0 by default and 0.5 with exclude_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_local and test_evaluator_does_not_retain_previous_call_config in tests/test_pipeline_config.py fail on main and pass here. Full suite: 55 passed; Ruff formatting and CLI help pass. ty check retains the same seven baseline diagnostics.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +48 to +49
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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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]

Comment on lines +78 to +79
assert before["discrimination_score_l1"].to_list() == [1.0, 1.0]
assert configured["discrimination_score_l1"].to_list() == [0.5, 1.0]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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]

This branch has not been deployed

No deployments
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.

1 participant