-
Notifications
You must be signed in to change notification settings - Fork 4
BDMS-520-1-1-Cleanup-2.0 #444
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e4d45fb
feat: add nma_data_quality to Observation model and update related fu…
jirhiker 3bb4e10
Formatting changes
jirhiker 471a9ad
feat: add timezone handling for DateMeasured in WaterLevelTransferer
jirhiker 4739aa4
Formatting changes
jirhiker d632b62
feat: enhance datetime handling in WaterLevelTransferer and related t…
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
46 changes: 46 additions & 0 deletions
46
alembic/versions/e123456789ab_add_observation_data_quality.py
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,46 @@ | ||
| """add nma_data_quality to observation | ||
|
|
||
| Revision ID: e123456789ab | ||
| Revises: b12e3919077e | ||
| Create Date: 2026-02-05 12:00:00.000000 | ||
|
|
||
| """ | ||
|
|
||
| from typing import Sequence, Union | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = "e123456789ab" | ||
| down_revision: Union[str, Sequence[str], None] = "b12e3919077e" | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| """Upgrade schema.""" | ||
| op.add_column( | ||
| "observation", | ||
| sa.Column( | ||
| "nma_data_quality", | ||
| sa.String(length=100), | ||
| sa.ForeignKey("lexicon_term.term", onupdate="CASCADE"), | ||
| nullable=True, | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "observation_version", | ||
| sa.Column( | ||
| "nma_data_quality", | ||
| sa.String(length=100), | ||
| sa.ForeignKey("lexicon_term.term", onupdate="CASCADE"), | ||
| nullable=True, | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| """Downgrade schema.""" | ||
| op.drop_column("observation_version", "nma_data_quality") | ||
| op.drop_column("observation", "nma_data_quality") |
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
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,24 @@ | ||
| import numpy as np | ||
| import pandas as pd | ||
|
|
||
| from transfers.sensor_transfer import _coerce_wi_mic_gain | ||
|
|
||
|
|
||
| def test_coerce_wi_mic_gain_numeric(): | ||
| assert _coerce_wi_mic_gain(1) is True | ||
| assert _coerce_wi_mic_gain(0) is False | ||
| assert _coerce_wi_mic_gain(1.0) is True | ||
|
|
||
|
|
||
| def test_coerce_wi_mic_gain_strings(): | ||
| assert _coerce_wi_mic_gain("1") is True | ||
| assert _coerce_wi_mic_gain("0") is False | ||
| assert _coerce_wi_mic_gain(" true ") is True | ||
| assert _coerce_wi_mic_gain("False") is False | ||
|
|
||
|
|
||
| def test_coerce_wi_mic_gain_handles_none_like(): | ||
| assert _coerce_wi_mic_gain(None) is None | ||
| assert _coerce_wi_mic_gain(" ") is None | ||
| assert _coerce_wi_mic_gain(pd.NA) is None | ||
| assert _coerce_wi_mic_gain(np.nan) is None |
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |||||
| # =============================================================================== | ||||||
| import json | ||||||
| import uuid | ||||||
| from datetime import datetime | ||||||
| from datetime import datetime, timezone, timedelta | ||||||
|
|
||||||
| import pandas as pd | ||||||
| from sqlalchemy.orm import Session | ||||||
|
|
@@ -197,6 +197,17 @@ def _make_observation( | |||||
| else: | ||||||
| value = row.DepthToWater | ||||||
|
|
||||||
| data_quality = None | ||||||
| dq_raw = getattr(row, "DataQuality", None) | ||||||
| if dq_raw and pd.notna(dq_raw): | ||||||
| dq_code = str(dq_raw).strip() | ||||||
| try: | ||||||
| data_quality = lexicon_mapper.map_value(f"LU_DataQuality:{dq_code}") | ||||||
| except KeyError: | ||||||
| logger.warning( | ||||||
| f"{SPACE_6}Unknown DataQuality code '{dq_code}' for WaterLevels record {row.GlobalID}" | ||||||
| ) | ||||||
|
|
||||||
| # TODO: after sensors have been added to the database update sensor_id (or sensor) for waterlevels that come from db sensors (like e probes?) | ||||||
|
||||||
| # TODO: after sensors have been added to the database update sensor_id (or sensor) for waterlevels that come from db sensors (like e probes?) | |
| # TODO: after sensors have been added to the database update sensor_id (or sensor) for waterlevels that come from DB sensors (like e probes?) |
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.