Skip to content

BDMS 233: transfer updates#261

Closed
jacob-a-brown wants to merge 117 commits into
stagingfrom
bdms-233-transfer-updates
Closed

BDMS 233: transfer updates#261
jacob-a-brown wants to merge 117 commits into
stagingfrom
bdms-233-transfer-updates

Conversation

@jacob-a-brown

Copy link
Copy Markdown
Contributor

Why

This PR addresses the following problem / context:

  • notes need to be transferred to the polymorphic notes table

How

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

  • updated well and location transfer scripts/code to transfer the following note types:
    • well: Other, Water, Construction, Measuring
    • location: Other, Coordinate
  • refactored legacy notes fields to go into the into the polymorphic notes table:
    • thing.well_construction_notes --> note_type = "Construction"
    • location.nma_notes_location -- > note_type = "Other"
    • location.nma_coordinate_notes --> note_type = "Coordinate"
  • update well-notes.py feature test for the refactoring of well_construction_notes to the polymorphic notes table

Notes

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

  • Measuring notes for a thing come from WaterLevels.SiteNotes in NM_Aquifer. The documentation for that field states "Optional notes concerning the nature of the well site or measuring event."
  • This PR utilizes work done for well-additional-information so it should not be merged until PR Bdms 227 transfer updates #257 and PR BDMS-227-231-additional-well-info-transfer-scripts #258 are merged into staging. I am opening a PR, though, to preserve the work done and get feedback when able. That being said, once those two PRs are merged into staging the number of files (and lines) changed will decrease dramatically.
    • I'll re-request reviews once those two PRs are merged.

jacob-a-brown and others added 30 commits November 4, 2025 17:31
…s-227-231-additional-well-info-models

# Conflicts:
#	.pre-commit-config.yaml
#	core/lexicon.json
#	tests/features/environment.py
…abulary fields

- Implemented `AquiferSystem` model for master reference of aquifer systems and hydrogeologic units
- Added table index for aquifer system name
- Included categories and terms for aquifer type and significance level

@jirhiker jirhiker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. I will need to refactor slightly to match the latest transfer branch

Comment thread tests/features/steps/well-additional-information.py Outdated
Comment thread transfers/permissions_transfer.py Outdated
wdf = read_csv("WellData", dtype={"OSEWelltagID": str})
wdf = replace_nans(wdf)

transferred_wells = (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

all the other transfers use filter_to_valid_point_ids for this functionality

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The permissions require the id of the thing record to set the target_id field, which is why the wells are queried in permissions_transfer.py (after the wells have been transferred and assigned ids by the database). Using filter_to_valid_point_ids would get me the correct thing.name for all of the wells, but wouldn't fetch the ids.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When I was figuring out this transfer it made me sense to me to do it this way, but I can move this to well_transfer.py after line 365 - the second after the comment "add things that need well id"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Upon reflection I think it makes more sense to go there. It'll be better organized and easier to follow

@jacob-a-brown jacob-a-brown Nov 26, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I forgot another reason why permission_transfer.py is its own file... The permissions require an associated contact, so they need to be transferred after both the things and contacts are transferred (which is why they can't go into well_transfer.py (which negates the above two comments)

)
for note_type, note_content in location_notes.items():
if not isna(note_content):
location.add_note(note_content, note_type)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Doesn't add_note just create a note object? you still need to add it to the session

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just looked at it and it does - I'll fix to add it to the session

Comment thread transfers/waterlevels_transfer.py Outdated

# WaterLevels.SiteNotes --> notes where note_type = "measuring_notes"
if not pd.isna(row.SiteNotes):
note = thing.add_note(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how is this note going to be associated with this water level measurement?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It won't be associated with water level measurements in Ocotillo, but with wells. The step from well-notes.feature indicates the response should include measuring notes (notes about measuring/visiting the well, on Access form). This is really the only field in the database that explicitly records notes about measures/visits, so it is now being associated with a well and not an observation.

The documentation is: "Optional notes concerning the nature of the well site or measuring event."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have messages out to Ethan and Sianin to clarify "measuring notes" since this field they mention that they want to see and enter data into is not found specifically in NM Aquifer and needs clarification. Looking at some of the values in WaterLevels.SiteNotes, they are definitely observation level, containing info like battery levels, which seems most relevant when associated with a specific time/date of observation.
image
I assume this response field from the old AMP API is the WaterLevels.SiteNotes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's correct - that response comes from WaterLevels.SiteNotes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as @chasetmartin mentioned WaterLevel.SiteNotes is related to observation level notes where time/date info is necessary.

I think the feature is saying return all the observation notes for this well, i.e. all the WaterLevel.SiteNotes. So WaterLevel.SiteNotes needs to be associated with a measurement. The API then collects all these notes and returns them with the other well metadata

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it. I'll then update this transfer, as well as update the feature file/test to reflect this

Comment thread transfers/well_transfer.py Outdated
Comment thread transfers/well_transfer.py Outdated
Comment thread .pre-commit-config.yaml
types: [python] # Specify relevant file types for your tests
pass_filenames: false
always_run: true
# - repo: local

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should not be committing these temporary, dev changes to .pre-commit-config.yaml

@jacob-a-brown jacob-a-brown marked this pull request as draft November 26, 2025 15:11
jacob-a-brown and others added 13 commits November 26, 2025 08:33
instead of a specific permission type, return a list of permission records for all permission types associated with the well.
…s-to-pass-tests

well additional information testing/implementation updates
regex is a more robust way to check for the presence of pump types in construction notes, handling variations in spacing and punctuation.
check to make sure that permissions are set before transferring them
from one entity to another to avoid potential errors.
@jacob-a-brown

Copy link
Copy Markdown
Contributor Author

This PR is out of date. See PR #272

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