From 76219524d312ef541d45fbc10fe8f9b1c87aedad Mon Sep 17 00:00:00 2001 From: Vincent Privat Date: Wed, 30 Jul 2025 17:54:52 +0200 Subject: [PATCH 1/2] Make --geometry optional for item-search conformance class --- README.md | 9 +++--- src/stac_api_validator/validations.py | 46 +++++++++++++-------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 078216f..f271ae2 100644 --- a/README.md +++ b/README.md @@ -66,9 +66,10 @@ The conformance class validations to run are selected with the `--conformance` p can be used more than once to specify multiple conformance classes to validate. The `STAC API - Core` conformance class will always be validated, even if not specified. -If `item-search`, `collections`, and/or `features` are specified, the `--collection` and `--geometry` parameters must also -be specified. The `--collection` parameter specifies the name of a collection to use for some of the validations. -The `--geometry` should specify an AOI over which there are between 100 and 20,000 results for the collection (more +If `item-search`, `collections`, and/or `features` are specified, the `--collection` parameter must also +be set. It specifies the name of a collection to use for some of the validations. +The `--geometry` parameter should also be set to perform intersection tests. +It should specify an AOI over which there are between 100 and 20,000 results for the collection (more results means longer time to run). ## Features @@ -127,7 +128,7 @@ Options: Conformance classes item-search, features, and collections require the `--collection` parameter with the id of a collection to run some tests on. -Conformance class `item-search` requires `--geometry` with a GeoJSON geometry that returns some items for +Conformance class `item-search` supports `--geometry` with a GeoJSON geometry that returns some items for the specified collection. Example: diff --git a/src/stac_api_validator/validations.py b/src/stac_api_validator/validations.py index 1c126dd..74431ad 100644 --- a/src/stac_api_validator/validations.py +++ b/src/stac_api_validator/validations.py @@ -531,10 +531,9 @@ def validate_core_landing_page_body( ) return False if geometry is None: - logger.fatal( - " Item Search configured for validation, but `--geometry` parameter not specified" + logger.warning( + " Item Search configured for validation, but `--geometry` parameter not specified. Intersection tests will not be run" ) - return False if "children" in conformance_classes and not any( cc_children_regex.fullmatch(x) for x in conforms_to @@ -677,7 +676,7 @@ def validate_api( conforms_to=conforms_to, warnings=warnings, errors=errors, - geometry=geometry, # type:ignore + geometry=geometry, conformance_classes=ccs_to_validate, r_session=r_session, validate_pagination=validate_pagination, @@ -1108,8 +1107,7 @@ def validate_features( open_assets_urls: bool = True, ) -> None: if not geometry: - errors += f"[{Context.FEATURES}] Geometry parameter required for running Features validations." - return + warnings += f"[{Context.FEATURES}] Geometry parameter required for running Features validations." if not collection: errors += f"[{Context.FEATURES}] Collection parameter required for running Features validations." @@ -1358,7 +1356,7 @@ def validate_item_search( conforms_to: List[str], warnings: Warnings, errors: Errors, - geometry: str, + geometry: Optional[str], conformance_classes: List[str], r_session: Session, validate_pagination: bool, @@ -1430,14 +1428,15 @@ def validate_item_search( validate_item_search_collections( search_url, collections_url, methods, errors, r_session ) - validate_item_search_intersects( - search_url=search_url, - collection=collection, - methods=methods, - errors=errors, - geometry=geometry, - r_session=r_session, - ) + if geometry is not None: + validate_item_search_intersects( + search_url=search_url, + collection=collection, + methods=methods, + errors=errors, + geometry=geometry, + r_session=r_session, + ) if validate_pagination: validate_item_pagination( @@ -2747,7 +2746,7 @@ def validate_item_pagination( root_url: str, search_url: str, collection: Optional[str], - geometry: str, + geometry: Optional[str], methods: Set[Method], errors: Errors, use_pystac_client: bool, @@ -2888,14 +2887,15 @@ def validate_item_pagination( if len(items) > len({item["id"] for item in items}): errors += f"[{context}] POST pagination - duplicate items returned from paginating items" - search = client.search( - method="POST", collections=[collection], intersects=geometry - ) - if len(list(take(20000, search.items_as_dicts()))) == 20000: - errors += ( - f"[{context}] POST pagination - paged through 20,000 results. This could mean the last page " - "of results references itself, or your collection and geometry combination has too many results." + if geometry is not None: + search = client.search( + method="POST", collections=[collection], intersects=geometry ) + if len(list(take(20000, search.items_as_dicts()))) == 20000: + errors += ( + f"[{context}] POST pagination - paged through 20,000 results. This could mean the last page " + "of results references itself, or your collection and geometry combination has too many results." + ) except Exception as e: errors += f"pystac-client threw exception while testing pagination {e}" elif collection is not None: From 1ec460529d97eb8a8bfa644e1d83948d57898fda Mon Sep 17 00:00:00 2001 From: Vincent Privat Date: Thu, 7 Aug 2025 10:18:16 +0200 Subject: [PATCH 2/2] geometry is no longer required for running Features validations --- src/stac_api_validator/validations.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/stac_api_validator/validations.py b/src/stac_api_validator/validations.py index 74431ad..ac0ece9 100644 --- a/src/stac_api_validator/validations.py +++ b/src/stac_api_validator/validations.py @@ -1106,9 +1106,6 @@ def validate_features( validate_pagination: bool, open_assets_urls: bool = True, ) -> None: - if not geometry: - warnings += f"[{Context.FEATURES}] Geometry parameter required for running Features validations." - if not collection: errors += f"[{Context.FEATURES}] Collection parameter required for running Features validations." return