Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.3.2 #228

Merged
merged 9 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:

Expand Down
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)

## [Unreleased]

## [v3.3.2] - 2023-11-17

### Added

- Docstrings https://github.com/stac-utils/stac-validator/pull/224
- Docstrings ([#224](https://github.com/stac-utils/stac-validator/pull/224))

### Changed

- Development dependencies removed from runtime dependency list
([#228](https://github.com/stac-utils/stac-check/pull/109))
- Remove jsonschema RefResolver ([#228](https://github.com/stac-utils/stac-check/pull/109))

## [v3.3.1] - 2022-12-16

Expand Down Expand Up @@ -183,7 +191,8 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
- 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.
- Logging. Various additions were made here depending on the options selected. This was done to help assist people to update their STAC collections.

[Unreleased]: <https://github.com/sparkgeo/stac-validator/compare/v3.3.1..main>
[Unreleased]: <https://github.com/sparkgeo/stac-validator/compare/v3.3.2..main>
[v3.3.2]: <https://github.com/sparkgeo/stac-validator/compare/v3.3.1..v3.3.2>
[v3.3.1]: <https://github.com/sparkgeo/stac-validator/compare/v3.3.0..v3.3.1>
[v3.3.0]: <https://github.com/sparkgeo/stac-validator/compare/v3.2.0..v3.3.0>
[v3.2.0]: <https://github.com/sparkgeo/stac-validator/compare/v3.1.0..v3.2.0>
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ Installation from Repo
pip install .
```

or (for development)
or for local development

```bash
pip install --editable .["test"]
pip install -e '.[dev]'
```


The [Makefile](./Makefile) has convenience commands if Make is installed.

```bash
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ black
pytest
pytest-mypy
pre-commit
types-jsonschema
16 changes: 8 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

from setuptools import setup

__version__ = "3.3.1"
__version__ = "3.3.2"

with open("README.md", "r") as fh:
long_description = fh.read()

extra_reqs = {
"test": ["pytest"],
}

setup(
name="stac_validator",
version=__version__,
Expand All @@ -29,17 +25,21 @@
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/stac-utils/stac-validator",
download_url="https://github.com/stac-utils/stac-validator/archive/v2.5.0.tar.gz",
install_requires=[
"requests>=2.19.1",
"jsonschema>=3.2.0",
"click>=8.0.0",
"types-setuptools",
],
extras_require={
"dev": [
"pytest",
"types-setuptools",
],
},
packages=["stac_validator"],
entry_points={
"console_scripts": ["stac-validator = stac_validator.stac_validator:main"]
},
python_requires=">=3.7",
python_requires=">=3.8",
tests_require=["pytest"],
)
2 changes: 0 additions & 2 deletions stac_validator/stac_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Any, Dict, List

import click # type: ignore
import pkg_resources

from .validate import StacValidate

Expand Down Expand Up @@ -101,7 +100,6 @@ def item_collection_summary(message: List[Dict[str, Any]]) -> None:
default="",
help="Save full recursive output to log file (local filepath).",
)
@click.version_option(version=pkg_resources.require("stac-validator")[0].version)
def main(
stac_file: str,
item_collection: bool,
Expand Down
15 changes: 8 additions & 7 deletions stac_validator/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import click # type: ignore
import jsonschema # type: ignore
from jsonschema import RefResolver
from jsonschema.validators import validator_for
from requests import exceptions # type: ignore

from .utilities import (
Expand Down Expand Up @@ -216,12 +216,13 @@ def custom_validator(self) -> None:
jsonschema.validate(self.stac_content, schema)
# in case the path to a json schema is local
elif os.path.exists(self.schema):
schema = fetch_and_parse_schema(self.schema)
custom_abspath = os.path.abspath(self.schema)
custom_dir = os.path.dirname(custom_abspath).replace("\\", "/")
custom_uri = f"file:///{custom_dir}/"
resolver = RefResolver(custom_uri, self.schema)
jsonschema.validate(self.stac_content, schema, resolver=resolver)
schema_dict = fetch_and_parse_schema(self.schema)
# determine the appropriate validator class for the schema
ValidatorClass = validator_for(schema_dict)
validator = ValidatorClass(schema_dict)
# validate the content
validator.validate(self.stac_content)

# deal with a relative path in the schema
else:
file_directory = os.path.dirname(os.path.abspath(str(self.stac_file)))
Expand Down
3 changes: 3 additions & 0 deletions tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

"""

import pytest

from stac_validator import stac_validator


Expand All @@ -22,6 +24,7 @@ def test_default_v070():
]


@pytest.mark.skip(reason="staclint eo extension schema invalid")
def test_default_item_local_v080():
stac_file = "tests/test_data/v080/items/sample-full.json"
stac = stac_validator.StacValidate(stac_file)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@

"""

import pytest

from stac_validator import stac_validator


@pytest.mark.skip(reason="staclint eo extension schema invalid")
def test_item_local_v080():
stac_file = "tests/test_data/v080/items/sample-full.json"
stac = stac_validator.StacValidate(stac_file, extensions=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def test_item_v100():
"http://remotedata.io/catalog/20201211_223832_CS2/index.html",
],
"format_invalid": [],
"request_valid": [
"request_valid": [],
"request_invalid": [
"http://remotedata.io/collection.json",
"http://remotedata.io/collection.json",
"http://remotedata.io/collection.json",
"http://remotedata.io/catalog/20201211_223832_CS2/index.html",
],
"request_invalid": [],
},
}
]
Loading