Skip to content

Commit

Permalink
add /statistics, /feature, and /bbox endpoints (#30)
Browse files Browse the repository at this point in the history
* add /statistics, /bbox, /feature endpoints

* update development workflow to use `uv`
  • Loading branch information
hrodmn authored Oct 22, 2024
1 parent cde8188 commit afe8b6d
Show file tree
Hide file tree
Showing 21 changed files with 5,588 additions and 1,313 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,27 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.22"
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .["test"]
uv sync --all-extras
- name: run pre-commit
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
run: |
python -m pip install pre-commit
pre-commit run --all-files
uv run pre-commit run --all-files
- name: Run tests
run: python -m pytest --cov titiler.cmr --cov-report term-missing -s -vv
run: uv run pytest

deploy:
needs: [tests]
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,3 @@ cdk.context.json

notebooks/

uv.lock
40 changes: 32 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
# Development - Contributing

Issues and pull requests are more than welcome: https://github.com/developmentseed/titiler-cmr/issues
Issues and pull requests are more than welcome: <https://github.com/developmentseed/titiler-cmr/issues>

**dev install**

This project uses [`uv`](https://docs.astral.sh/uv/) to manage the python environment and dependencies.
To install the package for development you can follow these steps:

```bash
$ git clone https://github.com/developmentseed/titiler-cmr.git
$ cd titiler-cmr
$ pip install pre-commit -e .["dev,test"]
# install uv

# unix
curl -LsSf https://astral.sh/uv/install.sh | sh

# or windows
# powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

git clone https://github.com/developmentseed/titiler-cmr.git
cd titiler-cmr
uv sync --all-extras
```

## Linting

This repo is set to use `pre-commit` to run *isort*, *flake8*, *pydocstring*, *black* ("uncompromising Python code formatter") and mypy when committing new code.

```bash
uv pre-commit install
```

## Testing

You can then run the tests with the following command:

```sh
python -m pytest --cov titiler.cmr --cov-report term-missing
```bash
uv run pytest
```

This repo is set to use `pre-commit` to run *isort*, *flake8*, *pydocstring*, *black* ("uncompromising Python code formatter") and mypy when committing new code.
The tests use `vcrpy <https://vcrpy.readthedocs.io/en/latest/>`_ to mock API calls
with "pre-recorded" API responses. When adding new tests that incur actual network traffic,
use the ``@pytest.mark.vcr`` decorator function to indicate ``vcrpy`` should be used.
Record the new responses and commit them to the repository.

```bash
$ pre-commit install
uv run pytest -v -s --record-mode new_episodes
```
14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
ARG PYTHON_VERSION=3.11
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

WORKDIR /app

FROM python:${PYTHON_VERSION}-slim

WORKDIR /tmp
COPY pyproject.toml pyproject.toml
COPY uv.lock uv.lock

COPY titiler/ titiler/
COPY pyproject.toml pyproject.toml
COPY README.md README.md
COPY LICENSE LICENSE

RUN pip install --no-cache-dir --upgrade . uvicorn
RUN rm -rf titiler/ pyproject.toml README.md LICENSE
RUN uv sync --frozen --extra uvicorn

ARG EARTHDATA_USERNAME
ARG EARTHDATA_PASSWORD
Expand All @@ -28,5 +26,5 @@ RUN if [ -z "$EARTHDATA_USERNAME" ] || [ -z "$EARTHDATA_PASSWORD" ]; then \
# http://www.uvicorn.org/settings/
ENV HOST 0.0.0.0
ENV PORT 80
CMD uvicorn titiler.cmr.main:app --host ${HOST} --port ${PORT} --log-level debug
CMD uv run uvicorn titiler.cmr.main:app --host ${HOST} --port ${PORT} --log-level debug

Loading

0 comments on commit afe8b6d

Please sign in to comment.