-
Notifications
You must be signed in to change notification settings - Fork 4
Transfer refactor for future reusability improvements #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
638c8bd
refactor: pass metrics object to transfer functions for improved data…
jirhiker 1c09367
refactor: enhance sensor transfer process with recording interval est…
jirhiker 2e8ea24
Merge branch 'staging' into transfer
jirhiker cee74b4
refactor: improve error handling and logging in sensor transfer and d…
jirhiker cb8c81f
refactor: remove commented-out code for deployment date checks in wat…
jirhiker bd9a295
refactor: streamline transfer function calls by consolidating flags u…
jirhiker 0283aee
refactor: implement SensorTransferer class for improved sensor data h…
jirhiker 9432f88
Unify read csv approaches
kbighorse 5db6964
Formatting changes
kbighorse fe6f50c
Un-ignore features; add features for location and well dates
kbighorse 738c1ef
Remove features we won't keep
kbighorse 9532632
Formatting changes
kbighorse ac04b26
Add features that describe post-migration behaviors
kbighorse 6169c3e
refactor: enhance water level transfer functions by introducing sourc…
jirhiker 952c5db
Rename `inventoried_on` to `legacy_start_date` since it won't continu…
kbighorse dbfc8ef
Add new fields to unit tests
kbighorse 5d51954
Create test_transfer_legacy_dates.py
kbighorse 8beca4e
Merge branch 'timestamp_proposal' of https://github.com/DataIntegrati…
kbighorse 687fb4a
Support changes in unit tests for thing and transfer script
kbighorse 6552bc0
Implement changes in db and schemas
kbighorse 08fb221
Implement changes in transfer scripts
kbighorse 47aad3f
Address measuring point bug
kbighorse 546b701
Formatting changes
kbighorse 0ceee93
refactor: enhance asset transfer process by implementing AssetTransfe…
jirhiker 078493c
refactor: replace transfer_water_levels function with WaterLevelTrans…
jirhiker 09c7127
refactor: enhance water levels transfer process by introducing WaterL…
jirhiker 76b1d3b
refactor: enhance water levels transfer process by introducing WaterL…
jirhiker b6e5039
refactor: simplify transfer_all function by removing unnecessary para…
jirhiker c77411d
refactor: implement ContactTransfer class for improved contact data h…
jirhiker 7339290
Merge branch 'staging' into timestamp_proposal
kbighorse ec79655
refactor: rename filter_by_welldata_datasource_and_project to get_tra…
jirhiker 6c08a25
refactor: add type hints to functions in util.py for improved code cl…
jirhiker 89e8994
feat: implement aquifer and geologic formation models with transfer f…
jirhiker b68900e
refactor: enhance transfer process by adding aquifer system and geolo…
jirhiker dd2188a
Merge branch 'staging' into transfer
jirhiker 308a7ca
fix: enable database rebuild and update measuring point history to in…
jirhiker ab5a600
refactor: remove unnecessary return statements and logging for clarit…
jirhiker 5ade1b2
refactor: optimize date handling in deployment search logic for impro…
jirhiker 306dabc
Formatting changes
kbighorse d8167a7
Resolve test failures
kbighorse de1e5cb
Update column name in BDD tests
kbighorse 0397891
Merge branch 'timestamp_proposal' of https://github.com/DataIntegrati…
kbighorse a9293bb
Formatting changes
kbighorse dc7a31b
Remove `well_completed_on`
kbighorse f011226
Formatting changes
kbighorse f021c4b
Replace `legacy_` prefix with `nma_`
kbighorse 2e33f83
Remove legacy fields from `UpdateLocation` schema
kbighorse aef077b
Formatting changes
kbighorse 960e6e2
Merge branch 'timestamp_proposal' of https://github.com/DataIntegrati…
kbighorse 6258e7d
DRY up the mock lexicon mapper into a fixture
kbighorse d3c5401
Merge branch 'timestamp_proposal' of https://github.com/DataIntegrati…
kbighorse fd4562a
Replace legacy python timestamp call with current implementation
kbighorse 5b1a07d
Preserve timezone in comparison
kbighorse b92a986
Make features more human-readable
kbighorse 94addc7
Formatting changes
kbighorse 0b4d77d
Simulate CSV rows more effiiently
kbighorse 2d12844
Replace `legacy_` in method names
kbighorse d9fe6f0
Merge branch 'timestamp_proposal' of https://github.com/DataIntegrati…
kbighorse 8c96e72
Increase code test coverage
kbighorse 48f503d
Enforce timezone info on `created_at`
kbighorse 43a8c5f
Ignore test coverage artifacts
kbighorse 0272990
Delete .coverage
kbighorse f0e730c
Remove noisy EOF
kbighorse 070fcba
Simplify error message
kbighorse f3e9587
Remove unnecessary conditionals
kbighorse 56694a3
feat: update sensor type handling to support multiple sensor types in…
jirhiker 1101e2e
feat: refactor well transfer logic to use bulk save for improved perf…
jirhiker be3a11d
refactor: rename regex pattern for pump types and simplify extraction…
jirhiker 4b6d8f2
feat: add organization mapping functionality and update contact trans…
jirhiker 1bb06ba
feat: add organization mapping functionality and update contact trans…
jirhiker 7ba4f1e
Merge branch 'timestamp_proposal' into transfer
jirhiker 6502032
feat: add DiverLink and Diver Cable to sensor mapping
jirhiker d8a1678
feat: remove Farr Cattle Company from organization lexicon
jirhiker b267405
feat: remove Lamy MDWCA from organization lexicon
jirhiker 147db27
feat: remove Santa Fe Downs from organization lexicon
jirhiker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| """ | ||
| SQLAlchemy model for the AquiferSystem table. | ||
|
|
||
| This is a master reference table for aquifer systems and hydrogeologic units. | ||
| """ | ||
|
|
||
| from typing import List, TYPE_CHECKING | ||
|
|
||
| from sqlalchemy import Text, Index | ||
| from sqlalchemy.orm import relationship, Mapped, mapped_column | ||
| from sqlalchemy.ext.associationproxy import association_proxy, AssociationProxy | ||
| from geoalchemy2 import Geometry | ||
|
|
||
| from db.base import Base, AutoBaseMixin, ReleaseMixin | ||
| from db.lexicon import lexicon_term | ||
|
|
||
| from constants import SRID_WGS84 | ||
|
|
||
| if TYPE_CHECKING: | ||
| from db.thing import WellScreen, ThingAquiferAssociation, Thing | ||
| from db.aquifer_type import AquiferType | ||
|
|
||
|
|
||
| class AquiferSystem(Base, AutoBaseMixin, ReleaseMixin): | ||
| __versioned__ = {} | ||
|
|
||
| name: Mapped[str] = mapped_column( | ||
| nullable=False, | ||
| unique=True, | ||
| comment="The full, human-readable name of the aquifer system (e.g., 'Ogallala Aquifer').", | ||
| ) | ||
| description: Mapped[str] = mapped_column( | ||
| Text, | ||
| nullable=True, | ||
| comment="A detailed description of the aquifer system, its characteristics, and its significance.", | ||
| ) | ||
| # Lexicon terms were retrieved from NMAquifer's 'LU_AquiferType' table. | ||
| primary_aquifer_type: Mapped[str] = lexicon_term( | ||
| nullable=False, | ||
| comment="A controlled vocabulary field to classify the aquifer system as a whole (e.g., 'Unconfined', 'Confined', 'Perched').", | ||
| ) | ||
| geographic_scale: Mapped[str] = lexicon_term( | ||
| nullable=True, | ||
| comment="A controlled vocabulary field to classify the aquifer's geographic scale (e.g., 'Major', 'Regional', 'Local').", | ||
| ) | ||
| boundary: Mapped[Geometry] = mapped_column( | ||
| Geometry(geometry_type="MULTIPOLYGON", srid=SRID_WGS84, spatial_index=True), | ||
| nullable=True, | ||
| comment="A spatial representation of the aquifer system's boundary.", | ||
| ) | ||
| # Hierarchical relationship fields (may be implemented in future iterations) | ||
| # Example: High Plains Aquifer (parent) contains Ogallala Aquifer (child) | ||
| # parent_id = Column(Integer, ForeignKey('aquifer_system.id')) | ||
| # parent = relationship('AquiferSystem', remote_side=[id], backref='subsystems') | ||
|
|
||
| # --- Relationships --- | ||
| # One-To-Many: An AquiferSystem can be associated with many wells (Things) via the ThingAquiferAssociation join table. | ||
| thing_associations: Mapped[List["ThingAquiferAssociation"]] = relationship( | ||
| "ThingAquiferAssociation", | ||
| back_populates="aquifer_system", | ||
| cascade="all, delete-orphan", | ||
| passive_deletes=True, | ||
| ) | ||
|
|
||
| # One-To-Many: An AquiferSystem can be the target for many individual WellScreens. | ||
| well_screens: Mapped[List["WellScreen"]] = relationship( | ||
| "WellScreen", | ||
| back_populates="aquifer_system", | ||
| cascade="all, delete-orphan", | ||
| passive_deletes=True, | ||
| ) | ||
|
|
||
| # --- Association Proxies --- | ||
| # Proxy to directly access Things (wells) associated with this AquiferSystem. | ||
| things: AssociationProxy[List["Thing"]] = association_proxy( | ||
| "thing_associations", "thing" | ||
| ) | ||
| # Proxy to directly access all AquiferTypes associated with this AquiferSystem. | ||
| aquifer_types: AssociationProxy[List["AquiferType"]] = association_proxy( | ||
| "thing_associations", "aquifer_types" | ||
| ) | ||
|
|
||
| # --- Table Arguments --- | ||
| __table_args__ = (Index("ix_aquifersystem_name", "name"),) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| """ | ||
| SQLAlchemy model for the AquiferType table. | ||
|
|
||
| This table stores the specific aquifer characteristics/types associated with | ||
| a Thing-AquiferSystem relationship. It allows capturing that a single aquifer | ||
| can have multiple characteristics simultaneously. | ||
|
|
||
| Example: | ||
| A well in the "Ogallala" aquifer might tap portions that are both | ||
| "Fractured" AND "Confined". This would create: | ||
| - One AquiferSystem: "Ogallala" | ||
| - One ThingAquiferAssociation: linking well to Ogallala | ||
| - Two AquiferType records: "Fractured" and "Confined" | ||
| """ | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from sqlalchemy import ForeignKey | ||
| from sqlalchemy.orm import relationship, Mapped, mapped_column | ||
|
|
||
| from db.base import Base, AutoBaseMixin, ReleaseMixin, lexicon_term | ||
|
|
||
| if TYPE_CHECKING: | ||
| from db.thing_aquifer_association import ThingAquiferAssociation | ||
|
|
||
|
|
||
| class AquiferType(Base, AutoBaseMixin, ReleaseMixin): | ||
| """ | ||
| Represents the specific aquifer types/characteristics for a | ||
| Thing-AquiferSystem association. | ||
|
|
||
| This allows modeling the fact that: | ||
| - A single aquifer can have multiple characteristics | ||
| - Different wells may tap different characteristics of the same aquifer | ||
| - Characteristics are attributes of the relationship, not the aquifer itself | ||
|
|
||
| Fields from WellData CSV: | ||
| - AquiferType: May contain multiple codes (e.g., "FC" = Fractured + Confined) | ||
| - Each code becomes a separate AquiferType record | ||
| """ | ||
|
|
||
| # --- Columns --- | ||
| thing_aquifer_association_id: Mapped[int] = mapped_column( | ||
| ForeignKey("thing_aquifer_association.id", ondelete="CASCADE"), | ||
| nullable=False, | ||
| comment="Links to the Thing-Aquifer association this type describes.", | ||
| ) | ||
| aquifer_type: Mapped[str] = lexicon_term( | ||
| nullable=False, | ||
| comment="Controlled vocabulary for aquifer hydrologic properties. " | ||
| "Examples: 'Unconfined', 'Confined', 'Perched', 'Fractured', 'Unconsolidated'.", | ||
| ) | ||
|
|
||
| # --- Relationships --- | ||
| # Many-to-One: Multiple aquifer types can belong to one association | ||
| thing_aquifer_association: Mapped["ThingAquiferAssociation"] = relationship( | ||
| "ThingAquiferAssociation", back_populates="aquifer_types" | ||
| ) |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| """ | ||
| SQLAlchemy model for the GeologicFormation table. | ||
|
|
||
| This table is a master reference table for geologic formations. Its purpose is to store definitions and descriptions | ||
| of various geologic formations that can be referenced by other tables in the database. | ||
| """ | ||
|
|
||
| from typing import List, TYPE_CHECKING | ||
|
|
||
| from sqlalchemy import Text, Index | ||
| from sqlalchemy.orm import relationship, Mapped, mapped_column | ||
| from sqlalchemy.ext.associationproxy import association_proxy, AssociationProxy | ||
| from geoalchemy2 import Geometry | ||
|
|
||
| from db.base import Base, AutoBaseMixin, ReleaseMixin | ||
| from db.lexicon import lexicon_term | ||
|
|
||
| from constants import SRID_WGS84 | ||
|
|
||
| if TYPE_CHECKING: | ||
| from db.thing import Thing, WellScreen | ||
| from db.thing_geologic_formation_association import ( | ||
| ThingGeologicFormationAssociation, | ||
| ) | ||
|
|
||
|
|
||
| class GeologicFormation(Base, AutoBaseMixin, ReleaseMixin): | ||
| __versioned__ = {} | ||
|
|
||
| # TODO: Let the API map formation codes to names using a formations.json file that can be periodically updated | ||
| # from the authoritative source (.e.g USGS). A placeholder `formations.json` file had been added to the `core` | ||
| # directory. | ||
| # name: Mapped[str] = mapped_column( | ||
| # nullable=False, | ||
| # unique=True, | ||
| # comment="The full, human-readable name of the geologic formation (e.g., 'Navajo Sandstone').", | ||
| # ) | ||
| formation_code: Mapped[str] = lexicon_term( | ||
| nullable=True, | ||
| unique=True, | ||
| comment="A short code or abbreviation for the geologic formation (e.g., '120ELRT').", | ||
| ) | ||
| description: Mapped[str] = mapped_column( | ||
| Text, | ||
| nullable=True, | ||
| comment="A detailed description of the geologic formation, its characteristics, and its significance.", | ||
| ) | ||
| # TODO: Implement controlled vocabularies for `lithology` using NMAquifer's 'LU_Lithology' table. | ||
| # This should be implemented after AMMP reviews and cleans up their formation terms and codes. | ||
| lithology: Mapped[str] = lexicon_term( | ||
| nullable=True, | ||
| comment="A controlled vocabulary for the primary, dominant rock type" | ||
| "(e.g., 'Tuff', 'Sandstone', 'Alluvium', 'Shale').", | ||
| ) | ||
| boundary: Mapped[Geometry] = mapped_column( | ||
| Geometry(geometry_type="MULTIPOLYGON", srid=SRID_WGS84, spatial_index=True), | ||
| nullable=True, | ||
| comment="A spatial representation of the geologic formation's extent.", | ||
| ) | ||
|
|
||
| # --- Relationships --- | ||
| # One-To-Many (Association Object): A GeologicFormation can be associated with many Things (e.g., wells) via the | ||
| # ThingGeologicFormationAssociation join table. | ||
| thing_associations: Mapped[List["ThingGeologicFormationAssociation"]] = ( | ||
| relationship( | ||
| "ThingGeologicFormationAssociation", | ||
| back_populates="geologic_formation", | ||
| cascade="all, delete-orphan", | ||
| passive_deletes=True, | ||
| ) | ||
| ) | ||
| # One-To-Many: A GeologicFormation can have many physical WellScreens installed in it. | ||
| well_screens: Mapped[List["WellScreen"]] = relationship( | ||
| "WellScreen", back_populates="geologic_formation", passive_deletes=True | ||
| ) | ||
|
|
||
| # --- Association Proxies --- | ||
| # Provides direct access to Things (wells) that penetrate this formation. | ||
| things: AssociationProxy["Thing"] = association_proxy("thing_associations", "thing") | ||
|
|
||
| # --- Table Arguments --- | ||
| __table_args__ = (Index("ix_geologicformation_formation_code", "formation_code"),) |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.