Skip to content

Conversation

@jirhiker
Copy link
Member

@jirhiker jirhiker commented Jan 10, 2026

What

  • Moved legacy transfer scripts for Chemistry SampleInfo, NGWMN views, SurfaceWaterData,
    WaterLevelsContinuous_Pressure_Daily, and WeatherData from transfers/backfill/ into the main transfers/ package and
    renamed their classes to standard *Transferer.
  • Wired these legacy transfers into the main transfer pipeline (transfers/transfer.py) in both parallel and
    sequential flows, with new feature flags to toggle them.
  • Added metrics reporting for the newly-integrated legacy tables in transfers/metrics.py.
  • Updated backfill orchestrator imports to point at the new module locations so the backfill pipeline still runs.
  • Added unit tests for the moved legacy models mirroring the style of tests/test_weather_data_legacy.py.
  • Added an ERD generator script and produced current schema ERD outputs.

Why

  • These legacy datasets are now part of the standard transfer workflows and should live in the same module structure
    as the rest of the transfer logic.
  • Integrating them into transfers/transfer.py ensures consistent orchestration, logging, and metrics.
  • New tests verify legacy schema mappings and CRUD behaviors for the moved models, preventing regressions.
  • ERD output provides an up-to-date view of the schema for review and documentation.

Key Changes

  • Module moves + renames
    • transfers/backfill/chemistry_sampleinfo.py → transfers/chemistry_sampleinfo.py
    • transfers/backfill/ngwmn_views.py → transfers/ngwmn_views.py
    • transfers/backfill/surface_water_data.py → transfers/surface_water_data.py
    • transfers/backfill/waterlevelscontinuous_pressure_daily.py → transfers/waterlevelscontinuous_pressure_daily.py
    • transfers/backfill/weather_data.py → transfers/weather_data.py
    • Class names updated to ChemistrySampleInfoTransferer, NGWMN*Transferer, SurfaceWaterDataTransferer,
      NMAWaterLevelsContinuousPressureDailyTransferer, and WeatherDataTransferer.
  • Transfer orchestration
    • Added transfer flags (default True):
      • TRANSFER_SURFACE_WATER_DATA
      • TRANSFER_CHEMISTRY_SAMPLEINFO
      • TRANSFER_NGWMN_VIEWS
      • TRANSFER_WATERLEVELS_PRESSURE_DAILY

Testing

  • python -m pytest tests/test_chemistry_sampleinfo_legacy.py tests/test_surface_water_data_legacy.py tests/

Notes

  • Running tests requires a local Postgres instance reachable at localhost:54321 with env vars loaded from .env.
  • ERD PNG generation requires Graphviz (dot) installed.
  • Backfill will be used in the future for refactoring not for legacy transfer

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI review requested due to automatic review settings January 11, 2026 05:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates legacy backfill transfer scripts into the main transfer pipeline, removing the separate backfill orchestrator and integrating five legacy datasets (Chemistry SampleInfo, NGWMN views, SurfaceWaterData, WaterLevelsContinuous_Pressure_Daily, and WeatherData) into the standard transfer workflow with new feature flags.

Changes:

  • Moved and renamed legacy transfer modules from transfers/backfill/ to transfers/, updating class names to standard *Transferer convention
  • Integrated legacy transfers into main transfer orchestration with new feature flags (TRANSFER_SURFACE_WATER_DATA, TRANSFER_CHEMISTRY_SAMPLEINFO, TRANSFER_NGWMN_VIEWS, TRANSFER_WATERLEVELS_PRESSURE_DAILY, TRANSFER_WEATHER_DATA)
  • Added comprehensive unit tests for legacy models and ERD generator script

Reviewed changes

Copilot reviewed 21 out of 23 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
transfers/well_transfer.py Refactored JSON blob operations to use new utility functions
transfers/weather_data.py Renamed class from WeatherDataBackfill to WeatherDataTransferer
transfers/waterlevelscontinuous_pressure_daily.py Renamed class to NMAWaterLevelsContinuousPressureDailyTransferer and removed unused import
transfers/util.py Added retry logic for GCS operations and JSON blob helpers
transfers/transfer.py Integrated five legacy transferers with new feature flags in parallel and sequential flows
transfers/surface_water_data.py Renamed class to SurfaceWaterDataTransferer
transfers/ngwmn_views.py Renamed base and derived classes from *Backfill to *Transferer
transfers/metrics.py Added metrics methods for all newly-integrated legacy tables
transfers/chemistry_sampleinfo.py Renamed class to ChemistrySampleInfoTransferer
transfers/backfill/backfill.py Emptied backfill orchestrator steps
tests/test_waterlevelscontinuous_pressure_daily_legacy.py Added CRUD tests for pressure daily legacy model
tests/test_surface_water_data_legacy.py Added CRUD tests for surface water data legacy model
tests/test_ngwmn_views_legacy.py Added CRUD tests for NGWMN view legacy models
tests/test_chemistry_sampleinfo_legacy.py Added CRUD tests for chemistry sample info legacy model
services/util.py Refactored HTTP calls to use new retry helper with backoff
scripts/generate_erd.py Added ERD generator script for SQLAlchemy schema visualization
schema_erd.dot Generated Graphviz DOT file with current schema ERD
run_backfill.sh Added GitHub workflow reference as documentation
pyproject.toml Added empty line (formatting)
.github/workflows/CD_staging.yml Removed backfill step from staging deployment
.github/workflows/CD_production.yml Removed backfill step from production deployment

jirhiker and others added 2 commits January 11, 2026 07:21
…ensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 11, 2026 14:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 1 comment.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 11, 2026 14:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 1 comment.

Copy link
Collaborator

@chasetmartin chasetmartin left a comment

Choose a reason for hiding this comment

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

Looks good to me given my previous knowledge of the transfer process, I do have one comment about removing the unused run_backfill.sh file if it is not relevant.

Copilot AI review requested due to automatic review settings January 12, 2026 21:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 26 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings January 13, 2026 02:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 47 out of 49 changed files in this pull request and generated 4 comments.

Copilot AI review requested due to automatic review settings January 13, 2026 16:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 49 out of 52 changed files in this pull request and generated 6 comments.

jirhiker and others added 3 commits January 13, 2026 09:38
# Conflicts:
#	db/nma_legacy.py
#	transfers/chemistry_sampleinfo.py
#	transfers/metrics.py
#	transfers/transfer.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 13, 2026 18:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 51 out of 54 changed files in this pull request and generated 6 comments.

Copilot AI review requested due to automatic review settings January 13, 2026 19:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 52 out of 55 changed files in this pull request and generated 8 comments.

z = convert_ngvd29_to_navd88(
z, transformed_point.x, transformed_point.y
)
if z is None:
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The nested if-else structure for handling NGVD29 conversion failures is difficult to follow. Consider extracting the fallback logic into a helper function (e.g., _try_datum_conversion_with_fallback) that takes the original z value, point coordinates, and elevations cache, returning the final z value and whether EPQS was used. This would make the main make_location function more readable and the fallback logic easier to test independently.

Copilot uses AI. Check for mistakes.
)
stmt = insert_stmt.values(chunk).on_conflict_do_update(
index_elements=["OBJECTID"],
index_elements=["SamplePtID"],
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

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

The upsert uses index_elements=["SamplePtID"] for conflict resolution, but the excluded update includes both SamplePtID and OBJECTID. Since SamplePtID is now the primary key and is used for conflict detection, updating it in the SET clause is redundant. Consider removing SamplePtID from the SET clause to avoid unnecessary operations.

Copilot uses AI. Check for mistakes.
…ensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 13, 2026 21:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 52 out of 55 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

transfers/chemistry_sampleinfo.py:1

  • The thing_id field in ChemistrySampleInfo is added to the upsert set clause, which could update an existing record to point to a different Thing. This breaks the relationship integrity as SamplePointID is unique and should always map to the same Thing. Remove thing_id from the upsert set_ clause to prevent accidental relationship changes.
# ===============================================================================

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 13, 2026 22:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 52 out of 55 changed files in this pull request and generated 2 comments.

Copy link
Contributor

@jacob-a-brown jacob-a-brown left a comment

Choose a reason for hiding this comment

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

Overall I think it looks good! I have some minor comments scattered throughout. Most of my comments are about Starlette-Admin, so I've compiled them below.

Comments on Starlette-Admin

  1. I don't think that Starlette-Admin has a separate list view and form view. Looking at its current implementation I think that you can get rid of all of the attributes in the "List View" sections and then keep the following:
  • fields
  • sortable_fields
  • fields_default_sort
  • searchable_fields
  • page_size
  • page_size_options
  • exclude_fields_from_create
  • exclude_fields_from_edit

You can also define export types as desired (if you want all views to have the same export types the export_type attribute can be defined in OcotilloModelView). For example:

rom starlette_admin import BaseField
from starlette_admin import ExportType
from admin.views.base import OcotilloModelView

class ExampleModelAdmin(OcotilloModelView):

    fields = [...]
    sortable_fields = [...]
    fields_default_sort = [...]
    searchable_fields = [...]
    page_size = ...
    page_size_options = [...]
    exclude_fields_from_create = [...]
    exclude_fields_from_edit = [...]
    export_type = [ExportType.CSV, ExportType.EXCEL]
  1. There may be some discrepancies between what is enumerated in list_fields and fields. These should be resolved and then put in the intended order in the fields attribute (e.g. putting sample_pt_id first for ChemistrySampleInfo since that's the PK)
  2. Unfortunately there isn't a way to list out all of the labels in a dictionary or similar object. To have labels, each field in the fields list needs to be defined as a BaseField or a particular field type (like IntegerField or StringField, but I think that'd be overkill) and then each label needs to be defined one-at-a-time. The same goes for help text. For example:
from starlette_admin import BaseField
from admin.views.base import OcotilloModelView

class ExampleModelAdmin(OcotilloModelView):

    fields = [
        BaseField("field_one", label="FieldOne", help_text="Help for FieldOne"),
        BaseField("field_two", label="FieldTwo", help_text="Help for FieldTwo")
    ]

@jirhiker jirhiker merged commit 15a1677 into staging Jan 13, 2026
6 checks passed
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.

4 participants