Skip to content

Commit 472ade7

Browse files
Make --geometry optional for item-search conformance class (#683)
* Make --geometry optional for item-search conformance class * geometry is no longer required for running Features validations --------- Co-authored-by: Pete Gadomski <[email protected]>
1 parent dfc7c21 commit 472ade7

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ The conformance class validations to run are selected with the `--conformance` p
6666
can be used more than once to specify multiple conformance classes to validate. The `STAC API - Core` conformance
6767
class will always be validated, even if not specified.
6868

69-
If `item-search`, `collections`, and/or `features` are specified, the `--collection` and `--geometry` parameters must also
70-
be specified. The `--collection` parameter specifies the name of a collection to use for some of the validations.
71-
The `--geometry` should specify an AOI over which there are between 100 and 20,000 results for the collection (more
69+
If `item-search`, `collections`, and/or `features` are specified, the `--collection` parameter must also
70+
be set. It specifies the name of a collection to use for some of the validations.
71+
The `--geometry` parameter should also be set to perform intersection tests.
72+
It should specify an AOI over which there are between 100 and 20,000 results for the collection (more
7273
results means longer time to run).
7374

7475
## Features
@@ -127,7 +128,7 @@ Options:
127128
Conformance classes item-search, features, and collections require the `--collection` parameter with the id of a
128129
collection to run some tests on.
129130

130-
Conformance class `item-search` requires `--geometry` with a GeoJSON geometry that returns some items for
131+
Conformance class `item-search` supports `--geometry` with a GeoJSON geometry that returns some items for
131132
the specified collection.
132133

133134
Example:

src/stac_api_validator/validations.py

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,9 @@ def validate_core_landing_page_body(
537537
)
538538
return False
539539
if geometry is None:
540-
logger.fatal(
541-
" Item Search configured for validation, but `--geometry` parameter not specified"
540+
logger.warning(
541+
" Item Search configured for validation, but `--geometry` parameter not specified. Intersection tests will not be run"
542542
)
543-
return False
544543

545544
if "children" in conformance_classes and not any(
546545
cc_children_regex.fullmatch(x) for x in conforms_to
@@ -697,7 +696,7 @@ def validate_api(
697696
conforms_to=conforms_to,
698697
warnings=warnings,
699698
errors=errors,
700-
geometry=geometry, # type:ignore
699+
geometry=geometry,
701700
conformance_classes=ccs_to_validate,
702701
r_session=r_session,
703702
validate_pagination=validate_pagination,
@@ -1130,10 +1129,6 @@ def validate_features(
11301129
open_assets_urls: bool = True,
11311130
stac_check_config: Optional[str] = None,
11321131
) -> None:
1133-
if not geometry:
1134-
errors += f"[{Context.FEATURES}] Geometry parameter required for running Features validations."
1135-
return
1136-
11371132
if not collection:
11381133
errors += f"[{Context.FEATURES}] Collection parameter required for running Features validations."
11391134
return
@@ -1383,7 +1378,7 @@ def validate_item_search(
13831378
conforms_to: List[str],
13841379
warnings: Warnings,
13851380
errors: Errors,
1386-
geometry: str,
1381+
geometry: Optional[str],
13871382
conformance_classes: List[str],
13881383
r_session: Session,
13891384
validate_pagination: bool,
@@ -1455,14 +1450,15 @@ def validate_item_search(
14551450
validate_item_search_collections(
14561451
search_url, collections_url, methods, errors, r_session
14571452
)
1458-
validate_item_search_intersects(
1459-
search_url=search_url,
1460-
collection=collection,
1461-
methods=methods,
1462-
errors=errors,
1463-
geometry=geometry,
1464-
r_session=r_session,
1465-
)
1453+
if geometry is not None:
1454+
validate_item_search_intersects(
1455+
search_url=search_url,
1456+
collection=collection,
1457+
methods=methods,
1458+
errors=errors,
1459+
geometry=geometry,
1460+
r_session=r_session,
1461+
)
14661462

14671463
if validate_pagination:
14681464
validate_item_pagination(
@@ -2772,7 +2768,7 @@ def validate_item_pagination(
27722768
root_url: str,
27732769
search_url: str,
27742770
collection: Optional[str],
2775-
geometry: str,
2771+
geometry: Optional[str],
27762772
methods: Set[Method],
27772773
errors: Errors,
27782774
use_pystac_client: bool,
@@ -2913,14 +2909,15 @@ def validate_item_pagination(
29132909
if len(items) > len({item["id"] for item in items}):
29142910
errors += f"[{context}] POST pagination - duplicate items returned from paginating items"
29152911

2916-
search = client.search(
2917-
method="POST", collections=[collection], intersects=geometry
2918-
)
2919-
if len(list(take(20000, search.items_as_dicts()))) == 20000:
2920-
errors += (
2921-
f"[{context}] POST pagination - paged through 20,000 results. This could mean the last page "
2922-
"of results references itself, or your collection and geometry combination has too many results."
2912+
if geometry is not None:
2913+
search = client.search(
2914+
method="POST", collections=[collection], intersects=geometry
29232915
)
2916+
if len(list(take(20000, search.items_as_dicts()))) == 20000:
2917+
errors += (
2918+
f"[{context}] POST pagination - paged through 20,000 results. This could mean the last page "
2919+
"of results references itself, or your collection and geometry combination has too many results."
2920+
)
29242921
except Exception as e:
29252922
errors += f"pystac-client threw exception while testing pagination {e}"
29262923
elif collection is not None:

0 commit comments

Comments
 (0)