Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Augspurger committed Sep 22, 2023
1 parent d8d0bc4 commit 5c2efde
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 143 deletions.
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-nwm
> 2. Run `scripts/test`
> 3. See error
Expand Down
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-nwm/tree/main/>
67 changes: 0 additions & 67 deletions README-template.md

This file was deleted.

90 changes: 67 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,67 @@
# 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-nwm

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

- Name: noaa-nwm
- Package: `stactools.noaa_nwm`
- [stactools-noaa-nwm on PyPI](https://pypi.org/project/stactools-noaa-nwm/)
- Owner: @githubusername
- [Dataset homepage](http://example.com)
- STAC extensions used:
- [proj](https://github.com/stac-extensions/projection/)
- Extra fields:
- `noaa-nwm:custom`: A custom attribute
- [Browse the example in human-readable form](https://radiantearth.github.io/stac-browser/#/external/raw.githubusercontent.com/stactools-packages/noaa-nwm/main/examples/collection.json)
- [Browse a notebook demonstrating the example item and collection](https://github.com/stactools-packages/noaa-nwm/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

```shell
pip install stactools-noaa-nwm
```

## Command-line usage

Description of the command line functions

```shell
stac noaa-nwm create-item source destination
```

Use `stac noaa-nwm --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
```
18 changes: 9 additions & 9 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,38 @@ RUN conda update conda && \
FROM base as dependencies

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-nwm
COPY --from=base /opt/conda /opt/conda
COPY pyproject.toml ./
COPY src/stactools/ephemeral/__init__.py src/stactools/ephemeral/
COPY src/stactools/noaa_nwm/__init__.py src/stactools/noaa_nwm/
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
&& rm -r /opt/venv/lib/python3.11/site-packages/stactools/noaa_nwm


FROM dependencies as builder

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-nwm
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-nwm
CMD [ "stac", "noaanwm" ]


FROM dependencies as dev-dependencies

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-nwm
COPY --from=dependencies /opt/venv /opt/venv
COPY pyproject.toml .
RUN pip install -e '.[dev]' \
Expand All @@ -50,8 +50,8 @@ RUN pip install -e '.[dev]' \
FROM dev-dependencies as dev-builder

ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /opt/stactools-ephemeral
WORKDIR /opt/stactools-noaa-nwm
COPY --from=base /opt/conda /opt/conda
COPY --from=dependencies /opt/venv /opt/venv
COPY . .
CMD [ "stac", "ephemeralcmd" ]
CMD [ "stac", "noaanwm" ]
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-nwm:latest \
-f docker/Dockerfile \
--target builder \
.
docker build $PULL \
-t stactools-packages/ephemeral:dev \
-t stactools-packages/noaa-nwm:dev \
-f docker/Dockerfile \
--target dev-builder \
.
Expand Down
4 changes: 2 additions & 2 deletions docker/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ 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-nwm:dev \
-f docker/Dockerfile \
--target dev-builder \
.
docker run --rm \
--entrypoint scripts/cibuild \
stactools-packages/ephemeral:dev
stactools-packages/noaa-nwm: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-nwm \
-p 8000:8000 \
--entrypoint /bin/bash \
stactools-packages/ephemeral:dev
stactools-packages/noaa-nwm:dev
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-nwm \
--entrypoint scripts/lint \
stactools-packages/ephemeral:dev
stactools-packages/noaa-nwm: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-nwm \
stactools-packages/noaa-nwm: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-nwm \
--entrypoint scripts/test \
stactools-packages/ephemeral:dev
stactools-packages/noaa-nwm:dev
fi
8 changes: 4 additions & 4 deletions docs/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# stactools-ephemeral\n",
"# stactools-noaa-nwm\n",
"\n",
"This is a small notebook demonstrating use of this package and its generated items and collections.\n",
"It is intended to be executed from the root of this repository, since it relies on files that have been checked into this repo."
Expand Down Expand Up @@ -1259,7 +1259,7 @@
"from pathlib import Path\n",
"from pystac import Collection, Item\n",
"from IPython.display import display\n",
"import stactools.ephemeral.stac\n",
"import stactools.noaa_nwm.stac\n",
"\n",
"root = Path().cwd().parent\n",
"collection = Collection.from_file(str(root / \"examples\" / \"collection.json\"))\n",
Expand Down Expand Up @@ -1595,8 +1595,8 @@
],
"source": [
"tif_path = root / \"tests\" / \"data\" / \"asset.tif\"\n",
"item = stactools.ephemeral.stac.create_item(str(tif_path))\n",
"collection = stactools.ephemeral.stac.create_collection()\n",
"item = stactools.noaa_nwm.stac.create_item(str(tif_path))\n",
"collection = stactools.noaa_nwm.stac.create_collection()\n",
"collection.add_item(item)\n",
"display(collection)"
]
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: stactools-ephemeral
name: stactools-noaa-nwm
channels:
- conda-forge
- defaults
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[project]
name = "stactools-ephemeral"
name = "stactools-noaa-nwm"
version = "0.1.0"
description = "PROVIDE DESCRIPTION HERE"
description = "stactools package for NOAA's National Water Model"
readme = "README.md"
authors = [{ name = "Your name here", email = "your-email@example.com" }]
maintainers = [{ name = "Your name here", email = "your-email@example.com" }]
authors = [{ name = "Tom Augspurger", email = "taugspurger@microsoft.com" }]
maintainers = [{ name = "Tom Augspurger", email = "taugspurger@microsoft.com" }]
keywords = ["stactools", "pystac", "catalog", "STAC"]
license = { text = "Apache-2.0" }
classifiers = [
Expand Down Expand Up @@ -34,8 +34,8 @@ dev = [
docs = ["pystac~=1.8", "ipykernel~=6.25", "jinja2~=3.1"]

[project.urls]
Github = "https://github.com/stactools-packges/ephemeral"
Issues = "https://github.com/stactools-packges/ephemeral/issues"
Github = "https://github.com/stactools-packges/noaa-nwm"
Issues = "https://github.com/stactools-packges/noaa-nwm/issues"

[build-system]
requires = ["setuptools", "wheel"]
Expand Down
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
*.py ./**/*.py \
*.md

pytest --cov=stactools.ephemeral tests
pytest --cov=stactools.noaa_nwm tests
coverage xml
fi
fi
6 changes: 3 additions & 3 deletions scripts/update-examples
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import shutil
from pathlib import Path

import stactools.ephemeral.stac
import stactools.noaa_nwm.stac
from pystac import CatalogType

root = Path(__file__).parents[1]
examples = root / "examples"

collection = stactools.ephemeral.stac.create_collection()
item = stactools.ephemeral.stac.create_item(str(root / "tests" / "data" / "asset.tif"))
collection = stactools.noaa_nwm.stac.create_collection()
item = stactools.noaa_nwm.stac.create_item(str(root / "tests" / "data" / "asset.tif"))
collection.add_item(item)
collection.update_extent_from_items()
collection.normalize_hrefs(str(examples))
Expand Down
Loading

0 comments on commit 5c2efde

Please sign in to comment.