Skip to content

Improve error legibility when locations aren't upstream of specified outlets - #34

Merged
laurengulland merged 2 commits into
masterfrom
improve-outlet-point-error
Jul 22, 2026
Merged

Improve error legibility when locations aren't upstream of specified outlets#34
laurengulland merged 2 commits into
masterfrom
improve-outlet-point-error

Conversation

@laurengulland

@laurengulland laurengulland commented Jul 20, 2026

Copy link
Copy Markdown

Two errors that are improved here, so the user gets clear feedback on locations that may be misconfigured:

  1. When a location is outside the area that drains to the user-specified downstream point, the error that's thrown now includes the user-facing site names, not the internal int ids. (Example: OTHER_LOCATION_NAME is not in the watershed that drains to OUTLET_NAME. Please check locations and amend as needed.)
  2. If the user incorrectly specifies which point in a basin is the outlet (i.e. sets a downstream point to drain to an upstream point), we now proactively catch this and throw a clear and descriptive error, with the recommended fix to make. (Example: Delineation found REAL_OUTLET_NAME to be downstream of the basin outlet set by the user (USER_SET_OUTLET_NAME). Please check that this is correct, and if so, update 'outlet_name' for all points in this basin from USER_SET_OUTLET_NAME to REAL_OUTLET_NAME.)

Tested end-to-end by calling the setup wizard with a misconfigured set of sites, and seeing that instead of the pretty incomprehensible errors we got before, these bubbled directly up to the user!

@laurengulland laurengulland self-assigned this Jul 20, 2026
raise Warning(
f"The point with id = {id} is not contained in the watershed of the first point."
raise ValueError(
f"{gages_gdf.loc[id]['name']} is not in the watershed that drains to {gages_gdf.loc[id]['outlet_name']}. Please check locations and amend as needed."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

name and outlet_name are not in the required columns in the delineator package so I think these could fail if this is called differently than how it is from our repo

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

so maybe we can fall back to id and outlet_id ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

oo thank you for catching & suggesting those fall backs!! Sounds very reasonable to me.

@laurengulland
laurengulland merged commit 2079511 into master Jul 22, 2026
1 check passed
@laurengulland
laurengulland deleted the improve-outlet-point-error branch July 22, 2026 00:02
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.

2 participants