refactor: split gpschecks.py into a subpackage (#197) - #267
Open
iabaako wants to merge 1 commit into
Open
Conversation
Splits the 2,238-line checks/gpschecks.py into models/compute/ settings_ui/report_ui submodules, mirroring the enumerator and backchecks splits. __init__.py stays empty per convention; output_view_template.py now imports gpschecks_report directly from datasure.checks.gpschecks.report_ui. Also eliminates three intra-file duplicates found while splitting: _get_gps_column_settings/_save_gps_column_settings replace a repeated duckdb load/save pair (6 call sites), _identity_optional_fields dedupes 5 call sites building (col, col) tooltip field pairs, and _filter_available_columns/_render_table_with_csv_download replace a repeated filter-then-display-then-download block. No behavior change. Tests mirrored into tests/checks/gpschecks/ with no logic changes; 113/113 tests pass, coverage improved from 95.18% to 95.36%. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
7 tasks
| MAPBOX_STYLE = "mapbox://styles/mapbox/light-v9" | ||
|
|
||
| # Distinct color palette (RGBA) for categorical coloring on maps | ||
| _CATEGORY_COLORS: list[list[int]] = [ |
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/gpschecks.py(2,238 lines) into a subpackage,src/datasure/checks/gpschecks/:models.py— module constants (TAB_NAME,MAPBOX_STYLE,_CATEGORY_COLORS); no local Pydantic models were needed sinceGPSSettings/GPSColumnConfig/related enums already live indatasure.modelscompute.py— pure GPS-parsing/outlier-detection functions (no Streamlit calls)settings_ui.py—gpschecks_report_settingsand its config-UI helpersreport_ui.py—gpschecks_reportand its report-rendering UI, including the GPS column-configuration CRUD group (which, like the equivalent group in the backchecks split, turned out to be called only from the report entry point, not settings) and the Plotly/pydeck chart-rendering functions (kept here rather thancompute.pysince they callst.pydeck_chart/st.secretsdirectly, not just build-and-return a chart object)__init__.py— left empty, matching every other package in this repoAlso eliminates three intra-file duplicates found while splitting:
_get_gps_column_settings/_save_gps_column_settingsreplace an identicalduckdb_get_table/duckdb_save_tablepair repeated across 6 call sites_identity_optional_fieldsdedupes 5 call sites that built(col, col)tooltip/display field pairs_filter_available_columns/_render_table_with_csv_downloadreplace a repeated "filter to available columns → display → CSV download" blockTests are mirrored into
tests/checks/gpschecks/{conftest,test_models,test_compute,test_settings_ui,test_report_ui}.py, replacing the 2,757-linetests/checks/test_gpschecks.py.This is the third of four planned splits tracked by #197 (enumerator in #265, backchecks in #266, outliers still pending), stacked on top of
refactor/197-split-backchecks-modulesince that PR is still open.Why is this change needed? 🤔
Per #197:
gpschecks.pymixed GPS parsing/outlier-detection computation with two distinct Streamlit UI flows (settings vs. report) in one 2,238-line file.How was this implemented? 🛠️
Pure mechanical reorganization — no logic changes, aside from the three 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 importgpschecks_reportdirectly fromdatasure.checks.gpschecks.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/gpschecks --cov=datasure.checks.gpschecks --cov-report=term-missing -q— 113/113 tests pass (exact match to the pre-split count), coverage improved from 95.18% to 95.36%uv run python -m pytest -q -m "not slow"— full suite passes, same pre-existing skipsScreenshots (if applicable) 📷
N/A — no UI or behavior changes.
Checklist ✅
🤖 Generated with Claude Code