Skip to content

Add explicit TNM elevation product discovery - #397

Merged
matth-love merged 1 commit into
mainfrom
feat/tnm-product-discovery
Sep 14, 2026
Merged

matth-love merged 1 commit into
mainfrom
feat/tnm-product-discovery

Conversation

@camante

@camante camante commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

This separates the TNM discovery changes from #385, following Matt's suggestion to keep footprint reading and source selection in hooks and Globato.

The new products option lets you ask for specific elevation products, such as 1m/1_3as. Each returned file is labeled with its product, alongside the source ID, dates, metadata links, and project directory when available. Files with the same name from different URLs get separate download paths.

If a product request fails or returns incomplete results, discovery stops and removes the entries collected during that run. This helps prevent a failed request from looking like an area has no higher-resolution data. Existing datasets queries remain available.

This PR does not read footprints or choose between overlapping sources. WESM project matching and the resolution hierarchy come next in Globato. No new dependencies are needed.

Tests

The repository tests passed, along with type checks and package checks. Pre-commit checks also passed.

The tests cover product selection, source metadata, files with matching names, pagination, and failed or incomplete requests. They use saved API-style responses rather than live USGS requests.

Source masks and spatial metadata still varied between unchanged-base runs, consistent with the Globato issue we discussed.

Newport exercises the existing workflow; the repository tests exercise the new product option. The dem-devel evidence contains the results and tested commits.
evidence_bundle.zip


🔍 Docs preview: https://fetchez--397.org.readthedocs.build/en/397/

@camante
camante requested a review from matth-love September 13, 2026 12:18

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 love this; adding docs for each module is a new goal. Then we can edit the module table to link to the specific module doc page!

Comment thread src/fetchez/modules/tnm.py Outdated
if products is not None:
if datasets is not None:
raise ValueError("Use either products or datasets, not both")
selected = products.split("/") if isinstance(products, str) else products

@matth-love matth-love Sep 13, 2026

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.

products is initialized above as Optional[str] = None but here we're supporting the option of it being a list else products list. So it might be nice to do something like products: Sequence[str] | str | None = None as the initialization so that we can input a list of values instead of just the string "/" format. Even better would be to use the existing fetchez.utils.parse_arg_to_list function here:

from fetchez.utils import parse_arg_to_list

self.products = set([x.lower() for x in parse_arg_to_list(products, str)])

and that would handle a list of string as well as the / separated string. and cast the outputs as expected. e.g.:

>>> set([x.lower() for x in parse_arg_to_list("5m/1m/5m", str)])
['5m', '1m']
>>> set([x.lower() for x in parse_arg_to_list(["5m", "1m", "5m"], str)])
['5m', '1m']

Though up to you really, just make sure the initialization of products can support lists as well; this will likely get flagged when we make mypy stricter.

@camante
camante force-pushed the feat/tnm-product-discovery branch from 7d16022 to d822a54 Compare September 14, 2026 01:12
@camante

camante commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator Author

@matth-love Updated products parsing to use the existing parse_arg_to_list utility. It now supports slash-separated strings and sequences while preserving requested order and ordered de-duplication.

Focused TNM tests passed (33), the full Fetchez suite passed (184 passed, 2 skipped), and all pre-commit checks passed.

@camante
camante marked this pull request as ready for review September 14, 2026 01:17
@matth-love
matth-love merged commit 2dde541 into main Sep 14, 2026
4 checks passed
@matth-love
matth-love deleted the feat/tnm-product-discovery branch September 14, 2026 16:42
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