Skip to content

BDMS-470: Migrate Stratigraphy#393

Merged
jirhiker merged 14 commits into
stagingfrom
BDMS-470-Migrate-Stratigraphy
Jan 16, 2026
Merged

BDMS-470: Migrate Stratigraphy#393
jirhiker merged 14 commits into
stagingfrom
BDMS-470-Migrate-Stratigraphy

Conversation

@jirhiker

Copy link
Copy Markdown
Member

Why

This PR addresses the following problem / context:

  • Staging lacks a first-class legacy stratigraphy table, so Stratigraphy.csv rows aren’t preserved outside the association transfer.
  • Without a dedicated transfer + tests, stratigraphy CSV ingestion can regress silently.
  • Alembic/test/transfer flows don’t share a single schema reset path for stratigraphy legacy data.

How

Implementation summary - the following was changed / added / removed:

  • Added Alembic revision 1d2c3b4a5e67_create_nma_stratigraphy_table.py plus the Stratigraphy model (NMA_Stratigraphy table) and wired Thing’s relationship so legacy intervals can be queried off wells.
  • Built transfers/stratigraphy_legacy.py with a batch upsert pipeline, hooked it into the main transfer worker (guarded by TRANSFER_NMA_STRATIGRAPHY), and exposed metrics for the new table.
  • Created tests/test_stratigraphy_legacy.py to cover the model FK linkage and the transfer’s CSV ingestion path end to end.

Notes

Any special considerations, workarounds, or follow-up work to note?

  • Run the new transfer after wells load so PointID→Thing resolutions succeed.
  • The Alembic revision must be applied before running transfers/tests to ensure NMA_Stratigraphy exists.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

@jirhiker jirhiker changed the title feat: add NMA_Stratigraphy table and transfer functionality BDMS-470: Migrate Stratigraphy Jan 16, 2026

Copilot AI 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.

Pull request overview

This PR adds support for ingesting legacy stratigraphy data from Stratigraphy.csv into a dedicated NMA_Stratigraphy table. Previously, stratigraphy rows weren't preserved as first-class records outside of association transfers.

Changes:

  • Added NMA_Stratigraphy table model with relationship to Thing
  • Implemented batch upsert transfer pipeline for Stratigraphy.csv with environment flag control
  • Added tests covering model relationships and end-to-end CSV ingestion

Reviewed changes

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

Show a summary per file
File Description
alembic/versions/1d2c3b4a5e67_create_nma_stratigraphy_table.py Creates NMA_Stratigraphy table schema with indexes and foreign key to Thing
db/nma_legacy.py Defines Stratigraphy model with columns for lithology log data
db/thing.py Adds stratigraphy_logs relationship to Thing model
transfers/stratigraphy_legacy.py Implements StratigraphyLegacyTransferer with CSV parsing and batch upsert logic
transfers/transfer.py Integrates stratigraphy legacy transfer into parallel and sequential execution paths
transfers/metrics.py Adds nma_stratigraphy_metrics method for tracking transfer results
tests/test_stratigraphy_legacy.py Tests model relationships and transfer functionality

Comment thread alembic/versions/1d2c3b4a5e67_create_nma_stratigraphy_table.py Outdated
Comment thread transfers/stratigraphy_legacy.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 16, 2026 04:52

Copilot AI 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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 16, 2026 04:53

Copilot AI 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.

Pull request overview

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

if isinstance(value, str):
trimmed = value.strip()
return trimmed or None
return str(value)

Copilot AI Jan 16, 2026

Copy link

Choose a reason for hiding this comment

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

The _string_value method converts non-string, non-None values to strings, which may silently coerce unexpected types. Consider adding validation or logging when converting non-string values to help catch data quality issues in the CSV.

Suggested change
return str(value)
# Log when coercing non-string values to string to help catch data-quality issues.
logger.warning(
"Coercing non-string value to string in StratigraphyLegacyTransferer._string_value: "
"value=%r (type=%s)",
value,
type(value).__name__,
)
try:
coerced = str(value)
except Exception:
logger.exception(
"Failed to coerce value to string in StratigraphyLegacyTransferer._string_value: "
"value=%r (type=%s)",
value,
type(value).__name__,
)
return None
trimmed = coerced.strip()
return trimmed or None

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings January 16, 2026 05:04

Copilot AI 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.

Pull request overview

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

Comment thread transfers/stratigraphy_legacy.py Outdated
jirhiker and others added 2 commits January 15, 2026 22:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 16, 2026 16:57

Copilot AI 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.

Pull request overview

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

Comment thread tests/test_geospatial.py Outdated
jirhiker and others added 2 commits January 16, 2026 09:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 16, 2026 16:59

Copilot AI 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.

Pull request overview

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

Comment thread transfers/stratigraphy_legacy.py Outdated
Comment thread transfers/stratigraphy_legacy.py
Comment thread tests/conftest.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 16, 2026 18:58

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

Comment thread transfers/transfer.py
Copilot AI review requested due to automatic review settings January 16, 2026 23:11

Copilot AI 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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

@jirhiker jirhiker merged commit 38af393 into staging Jan 16, 2026
6 checks passed
@TylerAdamMartinez TylerAdamMartinez deleted the BDMS-470-Migrate-Stratigraphy branch February 26, 2026 18:25
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.

3 participants