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

feat: define separate collections for each product, define GRIB layers with byte ranges in 'grib:layers' asset metadata #6

Merged
merged 49 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e9c11d2
fill out admin details
hrodmn May 23, 2024
c0f8752
explore hrrr data using Herbie
hrodmn May 29, 2024
7de96ae
build the package!
hrodmn May 30, 2024
1779620
add item-assets
hrodmn May 30, 2024
85464a7
don't run CI on Python 3.8
hrodmn May 30, 2024
1e3c5a2
fix ci
hrodmn May 30, 2024
f0d2f7b
fix typo
hrodmn May 30, 2024
90aaafc
activate conda environment
hrodmn May 30, 2024
cbdc3e8
try activating conda a different way
hrodmn May 30, 2024
a092e92
conda init
hrodmn May 30, 2024
2495178
conditionally activate conda
hrodmn May 30, 2024
68b5c77
activate base conda env
hrodmn May 31, 2024
b89866c
fix alaska logic
hrodmn Jun 3, 2024
5ec20d6
try activating conda a different way
hrodmn Jun 3, 2024
62a072d
variable -> product
hrodmn Jun 5, 2024
11b8725
add forecast hour sets and variables
hrodmn Jun 5, 2024
cfd427c
split collections by product/forecast_hour_set
hrodmn Jun 5, 2024
0161eab
update examples
hrodmn Jun 5, 2024
12090c0
overhaul inventory system
hrodmn Jun 6, 2024
a5d7346
add datacube extension to collection
hrodmn Jun 10, 2024
e175f2e
clean up
hrodmn Jun 11, 2024
0367bad
Merge pull request #4 from developmentseed/product-set-collections
hrodmn Jun 11, 2024
92c881c
update example collection.json
hrodmn Jun 11, 2024
1add3a8
update sqlite
hrodmn Jun 11, 2024
99a3776
really include package data
hrodmn Jun 11, 2024
f87d3cc
add some tests for inventory fxns
hrodmn Jun 11, 2024
05a18ec
add Python 3.12 to version matrix
hrodmn Jun 11, 2024
9b3e2ab
update collection descriptions
hrodmn Jun 11, 2024
c4a2877
set up subfile assets
hrodmn Jun 12, 2024
5ac1bee
clean up docs/comments
hrodmn Jun 13, 2024
e5ccbe4
add function for creating items for a date range
hrodmn Jun 13, 2024
de62faf
requests -> httpx
hrodmn Jun 13, 2024
9920bcb
better error handling
hrodmn Jun 13, 2024
01a335d
set up custom asset properties for grib layers
hrodmn Jun 13, 2024
8a1790f
add item assets, forecast_time -> forecast_valid
hrodmn Jun 13, 2024
3300200
add collection-level datacube specification
hrodmn Jun 17, 2024
b20cf37
add folder to gitignore
hrodmn Jun 17, 2024
2bc4a68
delete some scratch files
hrodmn Jun 17, 2024
7d63665
update readme
hrodmn Jun 17, 2024
883e6e7
fix long line
hrodmn Jun 17, 2024
fb1f5ed
add item collection example to readme
hrodmn Jun 17, 2024
ec204d8
make sure items/collections can be written to json
hrodmn Jun 18, 2024
6fb8a65
do not set collection in item
hrodmn Jun 18, 2024
5230ca9
add region to collection id
hrodmn Jun 18, 2024
196c82c
update collection id format in tests
hrodmn Jun 18, 2024
a105e66
refactor into constants/metadata, add parse_href function
hrodmn Jun 20, 2024
621a8d5
update create_item api, refactor idx/inventory functions
hrodmn Jun 20, 2024
ac73b67
update changelog
hrodmn Jun 20, 2024
56ead36
update examples
hrodmn Jun 20, 2024
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/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Steps to reproduce the behavior:

> Ex.
>
> 1. Install stactools-ephemeral
> 1. Install stactools-noaa-hrrr
> 2. Run `scripts/test`
> 3. See error

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
defaults:
run:
shell: bash -l {0}
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,8 @@ dmypy.json

# Cython debug symbols
cython_debug/

scratch
.Trash-0
.virtual_documents

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ number as needed.

- Nothing.

[Unreleased]: <https://github.com/stactools-packages/ephemeral/tree/main/>
[Unreleased]: <https://github.com/stactools-packages/noaa-hrrr/tree/main/>
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
level of experience, education, socioeconomic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This software is licensed under the Apache 2 license, quoted below.

Copyright 2022 COMPANY [COMPANY WEBPAGE URL]
Copyright 2024 Development Seed [https://developmentseed.org/]

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
Expand Down
67 changes: 0 additions & 67 deletions README-template.md

This file was deleted.

123 changes: 100 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,100 @@
# stactools-template

This is a template repo used for creating new packages for `stactools`.

## How to use

1. Clone this template repository as your package name, e.g. `landsat`.
This name should be short, memorable, and a valid Python package name (i.e.
it shouldn't start with a number, etc). It can, however, include a hyphen, in
which case the name for Python imports will be the underscored version, e.g.
`landsat-8` goes to `stactools.landsat_8`. Your name will be used on PyPI to
publish the package in the stactools namespace, e.g. `stactools-landsat`.
2. Change into the top-level directory of your package and run `scripts/rename`.
This will update _most_ of the files in the repository with your new package name.
3. Update `pyproject.toml` with your package description and such.
4. Install with the development requirements (`pip install -e '.[dev]'`).
5. Update the LICENSE with your company's information (or whomever holds the copyright).
6. Edit or replace the existing functions to create stac Items and Collections
for your dataset.
7. Add example Items (and Collections and Catalogs, if included) to an
`examples/` directory.
8. Delete this file, and rename `README-template.md` to `README.md`. Update your
new README to provide information about how to use your package.
# stactools-noaa-hrrr

[![PyPI](https://img.shields.io/pypi/v/stactools-noaa-hrrr?style=for-the-badge)](https://pypi.org/project/stactools-noaa-hrrr/)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/stactools-packages/noaa-hrrr/continuous-integration.yml?style=for-the-badge)

- Name: noaa-hrrr
- Package: `stactools.noaa_hrrr`
- [stactools-noaa-hrrr on PyPI](https://pypi.org/project/stactools-noaa-hrrr/)
- Owner: @hrodmn
- [Dataset homepage](https://rapidrefresh.noaa.gov/hrrr/)
- STAC extensions used:
- [forecast](https://github.com/stac-extensions/forecast)
- [item-assets](https://github.com/stac-extensions/item-assets)
- [datacube](https://github.com/stac-extensions/datacube) (coming soon)
- Extra fields:
- `noaa-hrrr:forecast_cycle_type`: either standard (18-hour) or extended (48-hour)
- `noaa-hrrr:region`: either `conus` or `alaska`
- [Browse the example in human-readable form](https://radiantearth.github.io/stac-browser/#/external/raw.githubusercontent.com/stactools-packages/noaa-hrrr/main/examples/collection.json)
- [Browse a notebook demonstrating the example item and collection](https://github.com/stactools-packages/noaa-hrrr/tree/main/docs/example.ipynb)

A short description of the package and its usage.

## STAC examples

- [Collection](examples/collection.json)
- [Item](examples/item/item.json)

## Installation

Install `stactools-noaa-hrrr` with pip:

```shell
pip install stactools-noaa-hrrr
```

## Command-line usage

To create a collection object:

```shell
stac noaahrrr create-collection {region} {product} {cloud_provider} {destination_file}
```

e.g.

```shell
stac noaahrrr create-collection conus sfc azure example-collection.json
```

To create an item:

```shell
stac noaahrrr create-item {region} {product} {cloud_provider} {reference_datetime} {forecast_hour} {destination_file}
```

e.g.

```shell
stac noaahrrr create-item conus sfc azure 2024-05-01T12 10 example-item.json
```

### Docker

You can launch a jupyterhub server in a docker container with all of the
dependencies installed using these commands:

```shell
docker/build
docker/jupyter
```

Use `stac noaahrrr --help` to see all subcommands and options.

## Contributing

We use [pre-commit](https://pre-commit.com/) to check any changes.
To set up your development environment:

```shell
pip install -e '.[dev]'
pre-commit install
```

To check all files:

```shell
pre-commit run --all-files
```

To run the tests:

```shell
pytest -vv
```

If you've updated the STAC metadata output, update the examples:

```shell
scripts/update-examples
```
22 changes: 10 additions & 12 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,47 @@ RUN conda update conda && \
FROM base as dependencies

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-hrrr
COPY --from=base /opt/conda /opt/conda
COPY pyproject.toml ./
COPY src/stactools/ephemeral/__init__.py src/stactools/ephemeral/
COPY src/stactools/noaa_hrrr/__init__.py src/stactools/noaa_hrrr/
RUN apt-get -y -q update \
&& apt-get -y -q install build-essential \
&& rm -rf /var/lib/apt/lists/
RUN python -m venv /opt/venv
RUN pip install . \
&& ls /opt/venv \
&& rm -r /opt/venv/lib/python3.11/site-packages/stactools/ephemeral

&& ls /opt/venv/lib/ \
&& rm -r /opt/venv/lib/python3.12/site-packages/stactools/noaa_hrrr

FROM dependencies as builder

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-hrrr
COPY --from=base /opt/conda /opt/conda
COPY --from=dependencies /opt/venv /opt/venv
COPY pyproject.toml ./
COPY src ./src
RUN pip install -U pip \
&& pip install .
WORKDIR /
RUN rm -rf /opt/stactools-ephemeral
CMD [ "stac", "ephemeralcmd" ]
RUN rm -rf /opt/stactools-noaa-hrrr
CMD [ "stac", "noaahrrr" ]


FROM dependencies as dev-dependencies

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-hrrr
COPY --from=dependencies /opt/venv /opt/venv
COPY pyproject.toml .
RUN pip install -e '.[dev]' \
&& git init


FROM dev-dependencies as dev-builder

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-hrrr
COPY --from=base /opt/conda /opt/conda
COPY --from=dependencies /opt/venv /opt/venv
COPY . .
CMD [ "stac", "ephemeralcmd" ]
CMD [ "stac", "noaahrrr" ]
4 changes: 2 additions & 2 deletions docker/build
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
usage
else
docker build $PULL \
-t stactools-packages/ephemeral:latest \
-t stactools-packages/noaa-hrrr:latest \
-f docker/Dockerfile \
--target builder \
.
docker build $PULL \
-t stactools-packages/ephemeral:dev \
-t stactools-packages/noaa-hrrr:dev \
-f docker/Dockerfile \
--target dev-builder \
.
Expand Down
5 changes: 3 additions & 2 deletions docker/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ Runs CI in the docker dev container.

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker build $PULL \
-t stactools-packages/ephemeral:dev \
-t stactools-packages/noaa-hrrr:dev \
-f docker/Dockerfile \
--target dev-builder \
.
docker run --rm \
-e DOCKER=true \
--entrypoint scripts/cibuild \
stactools-packages/ephemeral:dev
stactools-packages/noaa-hrrr:dev
fi
4 changes: 2 additions & 2 deletions docker/console
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Run a console in a docker container with all prerequisites installed.

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker run --rm -it \
-v "$(pwd)":/opt/stactools-ephemeral \
-v "$(pwd)":/opt/stactools-noaa-hrrr \
-p 8000:8000 \
--entrypoint /bin/bash \
stactools-packages/ephemeral:dev
stactools-packages/noaa-hrrr:dev
fi
23 changes: 23 additions & 0 deletions docker/jupyter
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

if [[ -n "${STACTOOLS_DEBUG}" ]]; then
set -x
fi

function usage() {
echo -n \
"Usage: $(basename "$0")
Run a jupyter notebook server in a docker container with all prerequisites installed.
"
}

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker run --rm -it \
-v "$(pwd)":/opt/stactools-noaa-hrrr \
-p 8000:8000 \
--entrypoint /bin/bash \
stactools-packages/noaa-hrrr:dev \
-c "source /opt/conda/bin/activate && source /opt/venv/bin/activate && jupyter lab --ip=0.0.0.0 --port=8000 --no-browser --allow-root"
fi
4 changes: 2 additions & 2 deletions docker/lint
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Run code formatters in a docker container with all prerequisites installed.

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker run --rm -it \
-v "$(pwd)":/opt/stactools-ephemeral \
-v "$(pwd)":/opt/stactools-noaa-hrrr \
--entrypoint scripts/lint \
stactools-packages/ephemeral:dev
stactools-packages/noaa-hrrr:dev
fi
4 changes: 2 additions & 2 deletions docker/stac
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ will be reflected in the execution.

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker run --rm -it \
-v "$(pwd)":/opt/stactools-ephemeral \
stactools-packages/ephemeral:dev "${@}"
-v "$(pwd)":/opt/stactools-noaa-hrrr \
stactools-packages/noaa-hrrr:dev "${@}"
fi
4 changes: 2 additions & 2 deletions docker/test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Run linting and tests in a docker container with all prerequisites installed.

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker run --rm -it \
-v "$(pwd)":/opt/stactools-ephemeral \
-v "$(pwd)":/opt/stactools-noaa-hrrr \
--entrypoint scripts/test \
stactools-packages/ephemeral:dev
stactools-packages/noaa-hrrr:dev
fi
Loading
Loading