-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update python docs * feat: update ci
- Loading branch information
Showing
14 changed files
with
284 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# heystac | ||
|
||
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/gadomski/heystac/ci.yaml?style=for-the-badge)](https://github.com/gadomski/heystac/actions/workflows/ci.yaml) | ||
|
||
A command-line utility (CLI) for rating and crawling [STAC](https://stacspec.org/) catalogs. | ||
**heystac** generates the ratings for <https://www.gadom.ski/heystac/>. | ||
|
||
## Usage | ||
|
||
```shell | ||
python -m pip install heystac | ||
heystac --help | ||
``` | ||
|
||
To [rate](#rate) a STAC catalog, collection, or item: | ||
|
||
```shell | ||
$ heystac rate https://landsatlook.usgs.gov/stac-server/collections/landsat-c2l2-st/items/LC09_L2SP_090091_20241118_20241119_02_T2_ST | ||
5.0 ★★★★★ | ||
``` | ||
|
||
Any issues will be printed to standard output: | ||
|
||
```shell | ||
|
||
$ heystac rate https://landsatlook.usgs.gov/stac-server/collections/landsat-c2l2-st | ||
1.7 ★★ | ||
|
||
High importance issues | ||
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ||
| Rule id | Message | | ||
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ||
| validate-core | Validation failed for Collection with ID landsat-c2l2-st against schema at https://schemas.stacspec.org/v1.0.0/collection-spec/json-schema/collection.json | | ||
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ||
``` | ||
|
||
To run [json-schema](https://json-schema.org/) validation on a STAC value: | ||
|
||
```shell | ||
$ heystac validate https://landsatlook.usgs.gov/stac-server/collections/landsat-c2l2-st 2>&1 | tail -n7 | ||
Failed validating 'pattern' in schema['allOf'][0]['properties']['license']: | ||
{'title': 'Collection License Name', | ||
'type': 'string', | ||
'pattern': '^[\\w\\-\\.\\+]+$'} | ||
|
||
On instance['license']: | ||
'https://d9-wret.s3.us-west-2.amazonaws.com/assets/palladium/production/s3fs-public/atoms/files/Landsat_Data_Policy.pdf' | ||
``` | ||
|
||
To [crawl](#crawl) a catalog and save the crawl to a directory: | ||
|
||
```shell | ||
heystac crawl https://landsatlook.usgs.gov/stac-server usgs-landsat | ||
``` | ||
|
||
## Definitions | ||
|
||
We've made some opinionated decisions about behavior in this CLI. | ||
|
||
### Rate | ||
|
||
A `Rating` is generated by applying a set of `Rules` to a STAC value. | ||
This produces one `Check` per rule. | ||
Each `Check` has a score between zero and one: | ||
|
||
- `0`: the STAC value failed the check | ||
- `1`: the STAC value passed the check | ||
- Something between `0` and `1`: the STAC value partially failed the check, e.g. if the check was for valid links and some links were valid and some were not | ||
|
||
Each rule also has an `Importance`: | ||
|
||
- `high` | ||
- `medium` | ||
- `low` | ||
|
||
**heystac** applies a configurable weight to each check based on its importance to produce a `score` for the STAC value. | ||
That score is converted to `stars` by the following formula: `5 * score / total`, where `total` is the maximum possible score. | ||
|
||
### Crawl | ||
|
||
When **heystac** crawls a STAC API, it gets every collection and one item from each collection. | ||
The catalog is saved to the local filesystem in the following layout: | ||
|
||
- `catalog.json` | ||
- `collection-a/collection.json` | ||
- `collection-a/item-from-collection-a.json` | ||
- `collection-b/collection.json` | ||
- `collection-b/item-from-collection-b.json` | ||
|
||
The item file names are generated from the item ID, with all `/` characters replaced by `_`. | ||
|
||
## Configuration | ||
|
||
**heystac** comes with a default configuration that should work for most use-cases. | ||
If you want to customize anything, such as the importance weights or the rule descriptions, save the default configuration to a file called `heystac.toml`: | ||
|
||
```shell | ||
heystac config > heystac.tomml | ||
``` | ||
|
||
You can then edit that file to your heart's content. | ||
By default, the CLI will read `heystac.toml` in your current working directory. | ||
To specify a config file in another location: | ||
|
||
```shell | ||
heystac --config a/nother/path/config.toml | ||
``` | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
[project] | ||
name = "heystac" | ||
version = "0.0.0" | ||
description = "Command-line interface (CLI) for heystac" | ||
readme = "README.md" | ||
authors = [{ name = "Pete Gadomski", email = "[email protected]" }] | ||
version = "0.0.1" | ||
description = "Command-line interface (CLI) to rate and crawl STAC" | ||
keywords = ["stac"] | ||
readme = "README-python.md" | ||
license = { file = "LICENSE.txt" } | ||
requires-python = ">=3.12" | ||
dependencies = [ | ||
"click>=8.1.7", | ||
|
@@ -14,6 +17,15 @@ dependencies = [ | |
"shapely>=2.0.6", | ||
"tabulate>=0.9.0", | ||
"tqdm>=4.67.0", | ||
"toml>=0.10.2", | ||
] | ||
classifiers = [ | ||
"Topic :: Scientific/Engineering :: GIS", | ||
"Natural Language :: English", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: 3.13", | ||
] | ||
|
||
[project.scripts] | ||
|
@@ -30,6 +42,7 @@ dev = [ | |
"ruff>=0.7.3", | ||
"types-requests>=2.32.0.20241016", | ||
"types-tabulate>=0.9.0.20240106", | ||
"types-toml>=0.10.8.20240310", | ||
"types-tqdm>=4.66.0.20240417", | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
yarn build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
. ./.husky/pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
yarn install | ||
uv sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
yarn dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
uv run pytest | ||
# yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.