Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #15 from developmentseed/main
Browse files Browse the repository at this point in the history
0.11.5 > 0.11.7
  • Loading branch information
graphific authored May 25, 2023
2 parents 2f56429 + fb49341 commit 4cc21c6
Show file tree
Hide file tree
Showing 44 changed files with 676 additions and 477 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.11.5
current_version = 0.11.7
commit = True
tag = True
tag_name = {new_version}
Expand Down
25 changes: 25 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Release Notes

## 0.11.7 (2023-05-18)

### titiler.core

* make HTML `templates` configurable in the factories
* rename `index.html` to `map.html`
* rename `dependencies.CRSParams` to `dependencies.CoordCRSParams`
* add `dst-crs` option for `/preview` and `/crop` endpoints to specify the output Coordinate Reference System.

### titiler.mosaic

* make HTML `templates` configurable in the factories

### titiler.extensions

* make HTML `templates` configurable in the factories
* rename `cog_index.html` to `cog_viewer.html`
* rename `stac_index.html` to `stac_viewer.html`
* add `zoom to point` in `stac` and `cog` viewers (author @dchirst, https://github.com/developmentseed/titiler/pull/614)

## 0.11.6 (2023-04-14)

* Allow a default `rescale` parameter to be set via a dependency (author @samn, https://github.com/developmentseed/titiler/pull/619)
* add `coord-crs` parameter for `/point`, `/part` and `/feature` endpoints

## 0.11.5 (2023-03-22)

* fix `TerrainRGB` (change interval from `1.0` to `0.1`)
Expand Down
43 changes: 31 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Issues and pull requests are more than welcome: https://github.com/developmentse
**dev install**

```bash
$ git clone https://github.com/developmentseed/titiler.git
$ cd titiler
$ pip install \
git clone https://github.com/developmentseed/titiler.git
cd titiler

python -m pip install \
pre-commit \
-e src/titiler/core["test"] \
-e src/titiler/extensions["test,cogeo,stac"] \
Expand All @@ -20,32 +21,50 @@ $ pip install \
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
$ pre-commit install
pre-commit install
```

### Run tests

Each `titiler`'s modules has its own test suite which can be ran independently

```
# titiler.core
python -m pytest src/titiler/core --cov=titiler.core --cov-report=xml --cov-append --cov-report=term-missing
# titiler.extensions
python -m pytest src/titiler/extensions --cov=titiler.extensions --cov-report=xml --cov-append --cov-report=term-missing
# titiler.mosaic
python -m pytest src/titiler/mosaic --cov=titiler.mosaic --cov-report=xml --cov-append --cov-report=term-missing
# titiler.application
python -m pytest src/titiler/application --cov=titiler.application --cov-report=xml --cov-append --cov-report=term-missing
```

### Docs

```bash
$ git clone https://github.com/developmentseed/titiler.git
$ cd titiler
$ pip install nbconvert mkdocs mkdocs-material mkdocs-jupyter pygments pdocs
git clone https://github.com/developmentseed/titiler.git
cd titiler
python -m pip install nbconvert mkdocs mkdocs-material mkdocs-jupyter pygments pdocs
```

Hot-reloading docs:

```bash
$ mkdocs serve -f docs/mkdocs.yml
mkdocs serve -f docs/mkdocs.yml
```

To manually deploy docs (note you should never need to do this because Github
Actions deploys automatically for new commits.):

```bash
$ mkdocs gh-deploy -f docs/mkdocs.yml
mkdocs gh-deploy -f docs/mkdocs.yml
```

```bash
pdocs as_markdown \
pdocs as_markdown \
--output_dir docs/src/api \
--exclude_source \
--overwrite \
Expand All @@ -57,15 +76,15 @@ $ mkdocs gh-deploy -f docs/mkdocs.yml
titiler.core.resources.enums \
titiler.core.middleware

pdocs as_markdown \
pdocs as_markdown \
--output_dir docs/src/api \
--exclude_source \
--overwrite \
titiler.extensions.cogeo \
titiler.extensions.viewer \
titiler.extensions.stac

pdocs as_markdown \
pdocs as_markdown \
--output_dir docs/src/api \
--exclude_source \
--overwrite \
Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,33 @@ To install from PyPI and run:

```bash
# Make sure you have pip up to date
$ python -m pip install -U pip
python -m pip install -U pip

$ python -m pip install titiler.{package}
python -m pip install titiler.{package}
# e.g.,
# python -m pip install titiler.core
# python -m pip install titiler.extensions
# python -m pip install titiler.mosaic
# python -m pip install titiler.application (also installs core, extensions and mosaic)

# Install uvicorn to run the FastAPI application locally
$ python -m pip install uvicorn
python -m pip install uvicorn

# Launch application locally
$ uvicorn titiler.application.main:app
uvicorn titiler.application.main:app
```

To install from sources and run for development:

```
$ git clone https://github.com/developmentseed/titiler.git
$ cd titiler
$ python -m pip install -U pip
$ python -m pip install -e src/titiler/core -e src/titiler/extensions -e src/titiler/mosaic -e src/titiler/application
$ python -m pip install uvicorn
$ uvicorn titiler.application.main:app --reload
git clone https://github.com/developmentseed/titiler.git
cd titiler
python -m pip install -U pip
python -m pip install -e src/titiler/core -e src/titiler/extensions -e src/titiler/mosaic -e src/titiler/application
python -m pip install uvicorn
uvicorn titiler.application.main:app --reload
```

## Docker
Expand All @@ -109,10 +111,10 @@ docker run --name titiler \

- Built the docker locally
```
$ git clone https://github.com/developmentseed/titiler.git
$ cd titiler
git clone https://github.com/developmentseed/titiler.git
cd titiler
$ docker-compose up --build titiler # or titiler-uvicorn
docker-compose up --build titiler # or titiler-uvicorn
```

Some options can be set via environment variables, see: https://github.com/tiangolo/uvicorn-gunicorn-docker#advanced-usage
Expand Down
63 changes: 32 additions & 31 deletions deployment/aws/cdk/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
import os
from typing import Any, Dict, List, Optional, Union

from aws_cdk import aws_apigatewayv2 as apigw
from aws_cdk import aws_apigatewayv2_integrations as apigw_integrations
from aws_cdk import App, CfnOutput, Duration, Stack, Tags
from aws_cdk import aws_apigatewayv2_alpha as apigw
from aws_cdk import aws_ec2 as ec2
from aws_cdk import aws_ecs as ecs
from aws_cdk import aws_ecs_patterns as ecs_patterns
from aws_cdk import aws_iam as iam
from aws_cdk import aws_lambda
from aws_cdk import aws_logs as logs
from aws_cdk import core
from aws_cdk.aws_apigatewayv2_integrations_alpha import HttpLambdaIntegration
from config import StackSettings
from constructs import Construct

settings = StackSettings()


class titilerLambdaStack(core.Stack):
class titilerLambdaStack(Stack):
"""
Titiler Lambda Stack
Expand All @@ -29,11 +30,11 @@ class titilerLambdaStack(core.Stack):

def __init__(
self,
scope: core.Construct,
scope: Construct,
id: str,
memory: int = 1024,
timeout: int = 30,
runtime: aws_lambda.Runtime = aws_lambda.Runtime.PYTHON_3_9,
runtime: aws_lambda.Runtime = aws_lambda.Runtime.PYTHON_3_10,
concurrent: Optional[int] = None,
permissions: Optional[List[iam.PolicyStatement]] = None,
environment: Optional[Dict] = None,
Expand All @@ -57,7 +58,7 @@ def __init__(
handler="handler.handler",
memory_size=memory,
reserved_concurrent_executions=concurrent,
timeout=core.Duration.seconds(timeout),
timeout=Duration.seconds(timeout),
environment=environment,
log_retention=logs.RetentionDays.ONE_WEEK,
)
Expand All @@ -68,19 +69,19 @@ def __init__(
api = apigw.HttpApi(
self,
f"{id}-endpoint",
default_integration=apigw_integrations.HttpLambdaIntegration(
default_integration=HttpLambdaIntegration(
f"{id}-integration", handler=lambda_function
),
)
core.CfnOutput(self, "Endpoint", value=api.url)
CfnOutput(self, "Endpoint", value=api.url)


class titilerECSStack(core.Stack):
class titilerECSStack(Stack):
"""Titiler ECS Fargate Stack."""

def __init__(
self,
scope: core.Construct,
scope: Construct,
id: str,
cpu: Union[int, float] = 256,
memory: Union[int, float] = 512,
Expand Down Expand Up @@ -123,7 +124,7 @@ def __init__(
listener_port=80,
task_image_options=ecs_patterns.ApplicationLoadBalancedTaskImageOptions(
image=ecs.ContainerImage.from_registry(
f"public.ecr.aws/developmentseed/titiler:{settings.image_version}",
f"ghcr.io/developmentseed/titiler:{settings.image_version}",
),
container_port=80,
environment=task_env,
Expand All @@ -142,8 +143,8 @@ def __init__(
scalable_target.scale_on_request_count(
"RequestScaling",
requests_per_target=50,
scale_in_cooldown=core.Duration.seconds(240),
scale_out_cooldown=core.Duration.seconds(30),
scale_in_cooldown=Duration.seconds(240),
scale_out_cooldown=Duration.seconds(30),
target_group=fargate_service.target_group,
)

Expand All @@ -161,7 +162,7 @@ def __init__(
)


app = core.App()
app = App()

perms = []
if settings.buckets:
Expand All @@ -175,20 +176,9 @@ def __init__(
)


# Tag infrastructure
for key, value in {
"Project": settings.name,
"Stack": settings.stage,
"Owner": settings.owner,
"Client": settings.client,
}.items():
if value:
core.Tag.add(app, key, value)

ecs_stackname = f"{settings.name}-ecs-{settings.stage}"
titilerECSStack(
ecs_stack = titilerECSStack(
app,
ecs_stackname,
f"{settings.name}-ecs-{settings.stage}",
cpu=settings.task_cpu,
memory=settings.task_memory,
mincount=settings.min_ecs_instances,
Expand All @@ -197,15 +187,26 @@ def __init__(
environment=settings.env,
)

lambda_stackname = f"{settings.name}-lambda-{settings.stage}"
titilerLambdaStack(
lambda_stack = titilerLambdaStack(
app,
lambda_stackname,
f"{settings.name}-lambda-{settings.stage}",
memory=settings.memory,
timeout=settings.timeout,
concurrent=settings.max_concurrent,
permissions=perms,
environment=settings.env,
)

# Tag infrastructure
for key, value in {
"Project": settings.name,
"Stack": settings.stage,
"Owner": settings.owner,
"Client": settings.client,
}.items():
if value:
Tags.of(ecs_stack).add(key, value)
Tags.of(lambda_stack).add(key, value)


app.synth()
6 changes: 3 additions & 3 deletions deployment/aws/lambda/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
ARG PYTHON_VERSION=3.9
ARG PYTHON_VERSION=3.10

FROM --platform=linux/amd64 public.ecr.aws/lambda/python:${PYTHON_VERSION}

WORKDIR /tmp

RUN pip install pip -U
RUN pip install "titiler.application==0.11.5" "mangum>=0.10.0" -t /asset --no-binary pydantic
RUN pip install "titiler.application==0.11.7" "mangum>=0.10.0" -t /asset --no-binary pydantic

# Reduce package size and remove useless files
RUN cd /asset && find . -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-[2-3][0-9]//'); cp $f $n; done;
RUN cd /asset && find . -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-[0-9]*//'); cp $f $n; done;
RUN cd /asset && find . -type d -a -name '__pycache__' -print0 | xargs -0 rm -rf
RUN cd /asset && find . -type f -a -name '*.py' -print0 | xargs -0 rm -f
RUN find /asset -type d -a -name 'tests' -print0 | xargs -0 rm -rf
Expand Down
Loading

0 comments on commit 4cc21c6

Please sign in to comment.