BDMS-115 Sensor model updates#189
Merged
Merged
Conversation
Documentation about the Sensor model was lacking. This commit updates the `Sensor` model documentation and provides clarity on the purpose and function of the table.
Refinements to the schema design have necessitated the addition and removal of fields in the Sensor model. - Added `comment` parameter to capture field descriptions. - Added new 'nma_pk_equipment`,'`sensor_type`, `sensor_status`, `pcn_number`, `owner_agency`, and `notes` fields. - Removed `datetime_installed`, `datetime_removed`, and `recording_interval` fields. These fields are now stored in the Deployment model.
A new `sensor_type` category was necessary to store valid `sensor_type` values.
The lexicon needs a new `sensor_status` category, but category named `status` already exists.It is unclear what kind of status it refers to. This commit changes the category `status` to `well_status` and adds a new category `sensor_status` and related valid values.
The test files needed to be updated to reflect the field changes made in the `Sensor` model. This commit updates the `test_sensor.py` file.
The test files needed to be updated to reflect the field changes made in the `Sensor` model. This commit updates the `conftest.py` file.
# Conflicts: # core/lexicon.json
The GET `get_sensors` endpoint was using outdated logic with a non-existent `observed_property` filter. This commit updates the `get_sensors` endpoint by replacing `observed_property` with `parameter_id`.
The Sensor pydantic schemas needed to be updated to match the modifications made to the Schema database model. This commit adds the `sensor_type`, `pcn_number`, `owner_agency`, and `sensor_status` fields. This commit removes the `datetime_installed`, `datetime_removed` and `recording_interval` fields.
There were specific tests focused on validating installation and removal dates, but the `datetime_installed` and `datetime_removed` fields no longer exist in the Sensor model. This commit comments out the tests attempting to validate the `datetime_installed` and `datetime_removed` fields.
Tests were failing because the PATCH endpoint was commented out of the ``/sensor` router. This commit re-enables the PATCH endpoint, but comments out the validation on the `datetime_removed` adn `datetime_installed` fields, since they are no longer associated with the Sensor model.
…/DataIntegrationGroup/NMSampleLocations into kas-sensor-model-update-20251008
Codecov Report❌ Patch coverage is
|
jirhiker
approved these changes
Oct 17, 2025
jirhiker
left a comment
Member
There was a problem hiding this comment.
looks good. excited to merge this with the transducer pr
Comment on lines
+75
to
+77
| sensor_status: Mapped[str] = lexicon_term( | ||
| nullable=True, | ||
| comment="A controlled vocabulary field to indicate the current status of the equipment (e.g., 'In Service', 'In Repair', 'Retired', 'Lost', etc).", |
Contributor
There was a problem hiding this comment.
Is this something that goes in the StatusHistory table?
Comment on lines
+134
to
+135
| thing_id: int = None, # Optional filter for thing_id. Filter by the Thing where equipment is deployed | ||
| parameter_id: int = None, # Filter by the parameter the sensor/equipment measures |
Contributor
There was a problem hiding this comment.
Since these query parameters are now present in this endpoint we should make tests to ensure they work as expected and to safeguard future development.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
This PR addresses the following problem / context:
This PR introduces enhancements and fixes across multiple modules related to sensor management and data validation. These changes enhance the system's ability to manage sensor deployments and validate data in support of groundwater monitoring workflows.
Sensormodel to serve as the central asset inventory for all physical hardware used for data collection.Deploymentmodel to better track sensor installations and their relationships withThingentities.How
Implementation summary - the following was changed / added / removed:
model- Equipment model/makeserial_no- Serial numberpcn_number- Property control numberowner_agency- Owning organizationsensor_status- Current status (In Service, In Repair, etc.)notes- General notes fieldCreateSensor,UpdateSensor, andSensorResponseschemas inschemas/sensor.py.Deploymentmodel indb/deployment.pyto include detailed attributes likehanging_cable_lengthandhanging_point_description.tests/conftest.pyfor testing sensor and deployment relationships.datetime_installedanddatetime_removedin theSensormodel.Notes
Any special considerations, workarounds, or follow-up work to note?
Pressure transducer,Acoustic sounder, andBarometer