refactor: split outliers.py into a subpackage (#197) - #268
Open
iabaako wants to merge 1 commit into
Open
Conversation
Splits the 2,864-line checks/outliers.py into models/compute/ settings_ui/report_ui submodules, mirroring the enumerator, backchecks, and gpschecks splits. __init__.py stays empty per convention; output_view_template.py now imports outliers_report directly from datasure.checks.outliers.report_ui. The full column-config CRUD group (add/update/delete/validate/ format-error/settings-table) turned out to be called only from outliers_report, not outliers_report_settings, despite settings-sounding names - moved to report_ui.py, same pattern as the prior two splits. Also eliminates two intra-file duplicates found while splitting: _validate_constraint_settings/_validate_outlier_settings share a new _validate_settings generic Pydantic-validate-and-report helper, and _render_constraint_violations_table/_render_outlier_table share a new _render_display_columns_expander. No behavior change. Tests mirrored into tests/checks/outliers/ with no logic changes; 228/228 tests pass (including the preserved Rust-panic skip), coverage improved from 97.44% to 97.47%. This completes all four splits planned in #197. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
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.



Pull Request Summary 🚀
What does this PR do? 📝
Splits
src/datasure/checks/outliers.py(2,864 lines) into a subpackage,src/datasure/checks/outliers/:models.py— enums, Pydantic settings/result models,TAB_NAMEcompute.py— pure outlier/constraint computation functions and chart builders (no Streamlit calls)settings_ui.py— justoutliers_report_settingsreport_ui.py—outliers_report, its report-rendering helpers, and the full column-configuration CRUD group (add/update/delete/validate/format-error/settings-table), which turned out to be called only fromoutliers_report, notoutliers_report_settings, despite settings-sounding names — same pattern found in the two prior splits__init__.py— left empty, matching every other package in this repoAlso eliminates two intra-file duplicates found while splitting:
_validate_constraint_settings/_validate_outlier_settingsshared an identical try/except/format/return shape → extracted a generic_validate_settings(settings, model_cls, format_error)helper_render_constraint_violations_table/_render_outlier_tableshared a near-identical "show more columns" expander/multiselect/save block → extracted_render_display_columns_expander(...)Tests are mirrored into
tests/checks/outliers/{conftest,test_models,test_compute,test_settings_ui,test_report_ui}.py, replacing the 3,528-linetests/checks/test_outliers.py, including the one pre-existing skip (test_stack_empty_dataframe, "Empty DataFrame causes Rust panic in Polars/Streamlit caching") preserved verbatim.This is the fourth and last of the four splits tracked by #197 (enumerator in #265, backchecks in #266, gpschecks in #267), stacked on top of
refactor/197-split-gpschecks-modulesince that PR is still open.Why is this change needed? 🤔
Per #197:
outliers.pymixed statistical/constraint computation with two distinct Streamlit UI flows (settings vs. report) in one 2,864-line file — the last of the four modules flagged as hard to navigate and review.How was this implemented? 🛠️
Pure mechanical reorganization — no logic changes, aside from the two documented deduplications above (verified to produce identical output via the existing test suite). Grepped the full
src/tree to confirm onlyoutput_view_template.pyimports from this module externally, and updated it to importoutliers_reportdirectly fromdatasure.checks.outliers.report_ui. The generated, gitignoredoutput_view_1.pywas left untouched, per this repo's convention of never editing generated output views directly.How to test or reproduce ? 🧪
uv run python -m pytest tests/checks/outliers --cov=datasure.checks.outliers --cov-report=term-missing -q— 228/228 tests pass (exact match to the pre-split count, including the preserved skip), coverage improved from 97.44% to 97.47%uv run python -m pytest -q -m "not slow"— full suite passes, same 7 pre-existing skips in the same placesScreenshots (if applicable) 📷
N/A — no UI or behavior changes.
Checklist ✅
🤖 Generated with Claude Code