Skip to content

Commit 4c7c366

Browse files
authored
Merge branch 'main' into recursive-and-max-depth
2 parents 55f015e + c230da6 commit 4c7c366

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ All notable changes to this project will be documented in this file.
44

55
The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## [Unreleased]
8-
7+
## [v2.5.0] - 2022-03-10
98
### Changed
109

1110
- Split the `--recursive` option into a `--recursive` flag and a `--max-depth` option
1211
- Renamed the entry point from `stac_validator` to `stac-validator`
1312

13+
## [v2.4.3] - 2022-03-10
14+
### Changed
15+
16+
- Add schema caching
17+
1418
## [v2.4.2] - 2022-03-02
1519
### Changed
1620

@@ -114,7 +118,7 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
114118
- With the newest version - 1.0.0-beta.2 - items will run through jsonchema validation before the PySTAC validation. The reason for this is that jsonschema will give more informative error messages. This should be addressed better in the future. This is not the case with the --recursive option as time can be a concern here with larger collections.
115119
- Logging. Various additions were made here depending on the options selected. This was done to help assist people to update their STAC collections.
116120

117-
[Unreleased]: <https://github.com/sparkgeo/stac-validator/compare/v2.4.0..main>
121+
[v2.5.0]: <https://github.com/sparkgeo/stac-validator/compare/v2.4.0..main>
118122
[v2.4.0]: <https://github.com/sparkgeo/stac-validator/compare/v2.3.0..v2.4.0>
119123
[v2.3.0]: <https://github.com/sparkgeo/stac-validator/compare/v2.2.0..v2.3.0>
120124
[v2.2.0]: <https://github.com/sparkgeo/stac-validator/compare/v2.1.0..v2.2.0>

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import setup
44

5-
__version__ = "2.4.2"
5+
__version__ = "2.4.3"
66

77
with open("README.md", "r") as fh:
88
long_description = fh.read()
@@ -28,8 +28,8 @@
2828
keywords="STAC validation raster",
2929
long_description=long_description,
3030
long_description_content_type="text/markdown",
31-
url="https://github.com/sparkgeo/stac-validator",
32-
download_url="https://github.com/sparkgeo/stac-validator/archive/v2.3.0.tar.gz",
31+
url="https://github.com/stac-utils/stac-validator",
32+
download_url="https://github.com/stac-utils/stac-validator/archive/v2.4.3.tar.gz",
3333
install_requires=[
3434
"requests>=2.19.1",
3535
"jsonschema>=3.2.0",

stac_validator/utilities.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import functools
12
import json
23
from urllib.parse import urlparse
34
from urllib.request import urlopen
@@ -56,6 +57,11 @@ def fetch_and_parse_file(input_path) -> dict:
5657
return data
5758

5859

60+
@functools.lru_cache(maxsize=48)
61+
def fetch_and_parse_schema(input_path) -> dict:
62+
return fetch_and_parse_file(input_path)
63+
64+
5965
# validate new versions at schemas.stacspec.org
6066
def set_schema_addr(version, stac_type: str):
6167
if version in NEW_VERSIONS:

stac_validator/validate.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from .utilities import (
1313
fetch_and_parse_file,
14+
fetch_and_parse_schema,
1415
get_stac_type,
1516
link_request,
1617
set_schema_addr,
@@ -152,15 +153,15 @@ def extensions_validator(self, stac_type: str) -> dict:
152153
def custom_validator(self):
153154
# in case the path to custom json schema is local
154155
# it may contain relative references
155-
schema = fetch_and_parse_file(self.custom)
156+
schema = fetch_and_parse_schema(self.custom)
156157
if os.path.exists(self.custom):
157158
custom_abspath = os.path.abspath(self.custom)
158159
custom_dir = os.path.dirname(custom_abspath).replace("\\", "/")
159160
custom_uri = f"file:///{custom_dir}/"
160161
resolver = RefResolver(custom_uri, self.custom)
161162
jsonschema.validate(self.stac_content, schema, resolver=resolver)
162163
else:
163-
schema = fetch_and_parse_file(self.custom)
164+
schema = fetch_and_parse_schema(self.custom)
164165
jsonschema.validate(self.stac_content, schema)
165166

166167
def core_validator(self, stac_type: str):
@@ -235,7 +236,7 @@ def recursive_validator(self, stac_type: str):
235236
self.custom = set_schema_addr(self.version, stac_type.lower())
236237
message = self.create_message(stac_type, "recursive")
237238
if self.version == "0.7.0":
238-
schema = fetch_and_parse_file(self.custom)
239+
schema = fetch_and_parse_schema(self.custom)
239240
# this next line prevents this: unknown url type: 'geojson.json' ??
240241
schema["allOf"] = [{}]
241242
jsonschema.validate(self.stac_content, schema)

0 commit comments

Comments
 (0)