-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Update app configuration * feat: Add get_fwi helper * feat: Add app config * feat: Update api schemas * feat: Add FWI route to api * feat: Exclude risk route * feat: Add pyrorisks conda-lock for rasterio * refactor: Update API settings * chore: Update dependencies * chore: Remove build directory * chore: Add conda to dockerfile for rasterio * chore: Update docker-compose config * chore: Update dependencies and configuration * chore: Add docker image push workflow * chore: Update FWI script workflow * chore: Update doc-deployment action * fix: Bump setup-python action to v4 * fix: Fix type hints
- Loading branch information
Showing
19 changed files
with
12,786 additions
and
357 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,35 @@ | ||
name: push | ||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
env: | ||
IMAGE_NAME: pyro-risks | ||
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_LOGIN }} | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build docker | ||
run: docker compose build -t $DOCKERHUB_USER/$IMAGE_NAME:latest | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_LOGIN }} | ||
password: ${{ secrets.DOCKERHUB_PW }} | ||
- name: Push to hub | ||
run: docker push $DOCKERHUB_USER/$IMAGE_NAME:latest | ||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Push to container registry | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
docker tag $DOCKERHUB_USER/$IMAGE_NAME:latest $IMAGE_ID:latest | ||
docker push $IMAGE_ID:latest |
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 |
---|---|---|
@@ -1,19 +1,42 @@ | ||
FROM python:3.10-buster | ||
|
||
WORKDIR /app | ||
|
||
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && \ | ||
/bin/bash /tmp/miniconda.sh -b -p /opt/conda && \ | ||
rm /tmp/miniconda.sh | ||
|
||
ENV PATH=/opt/conda/bin:$PATH | ||
|
||
RUN conda install -c conda-forge conda-lock | ||
|
||
# Install and activate pyrorisks environment | ||
|
||
COPY pyrorisks.conda-lock.yml pyrorisks.conda-lock.yml | ||
|
||
RUN conda-lock install --name pyrorisks pyrorisks.conda-lock.yml && conda clean -a | ||
|
||
ENV CONDA_DEFAULT_ENV=pyrorisks | ||
ENV PATH /opt/conda/envs/${CONDA_DEFAULT_ENV}/bin:$PATH | ||
RUN echo "conda activate ${CONDA_DEFAULT_ENV}" >> ~/.bashrc | ||
|
||
# Install poetry | ||
RUN pip install poetry==1.8.1 | ||
|
||
# Set environment variables for poetry | ||
ENV POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 \ | ||
POETRY_VIRTUALENVS_CREATE=0 \ | ||
POETRY_CACHE_DIR=/tmp/poetry_cache \ | ||
VIRTUAL_ENV=/app/.venv \ | ||
PATH="/app/.venv/bin:$PATH" | ||
|
||
WORKDIR /app | ||
VIRTUAL_ENV=/opt/conda/envs/${CONDA_DEFAULT_ENV} \ | ||
PATH="/opt/conda/envs/${CONDA_DEFAULT_ENV}/bin:$PATH" \ | ||
PYTHONPATH="/opt/conda/envs/${CONDA_DEFAULT_ENV}/lib/python3.10/site-packages:${PYTHONPATH}" | ||
|
||
COPY pyrorisks ./pyrorisks | ||
COPY app ./app | ||
COPY build ./build | ||
COPY pyrorisks ./pyrorisks | ||
COPY pyproject.toml poetry.lock README.md ./ | ||
|
||
# Install pyrorisks package in pyrorisks conda environment | ||
RUN poetry install | ||
|
||
CMD ["bash"] |
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,28 @@ | ||
# Copyright (C) 2021-2022, Pyronear. | ||
|
||
# This program is licensed under the Apache License version 2. | ||
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0.txt> for full license details. | ||
|
||
from typing import Dict, Any | ||
from fastapi import APIRouter, Depends | ||
from fastapi import HTTPException, status | ||
from app.api.schemas import ScoreQueryParams, Score | ||
from pyrorisks.platform_fwi.get_fwi_effis_score import get_fwi as _get_fwi | ||
|
||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get( | ||
path="/", | ||
response_model=Score, | ||
summary="Provide European Forest Fire Information System (EFFIS) Fire Weather Index (FWI) categories.", | ||
) | ||
async def get_fwi(query: ScoreQueryParams = Depends()) -> Dict[str, Any]: | ||
results = _get_fwi(longitude=query.longitude, latitude=query.latitude, crs=query.crs) | ||
if results is None: | ||
raise HTTPException( | ||
status_code=status.HTTP_404_NOT_FOUND, | ||
detail=f"Fire Weather Index (FWI) for longitude {query.longitude} and latitude {query.latitude} was not found.", | ||
) | ||
return results |
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 was deleted.
Oops, something went wrong.
Empty file.
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,34 @@ | ||
# Copyright (C) 2021-2024, Pyronear. | ||
|
||
# This program is licensed under the Apache License 2.0. | ||
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details. | ||
|
||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
from pydantic import field_validator | ||
from typing import Optional | ||
|
||
__all__ = ["settings"] | ||
|
||
|
||
class Settings(BaseSettings): | ||
model_config = SettingsConfigDict(env_file="./../../.env") | ||
|
||
PROJECT_NAME: str = "Pyrorisks" | ||
PROJECT_DESCRIPTION: str = "API for wildfire risk estimation" | ||
LOGO_URL: str = "https://pyronear.org/img/logo_letters.png" | ||
VERSION: str = "0.1.0" | ||
DEBUG: bool = False | ||
|
||
@field_validator("DEBUG", mode="before") | ||
@classmethod | ||
def transform_debug(cls, value: str) -> bool: | ||
return value != "False" | ||
|
||
S3_BUCKET_NAME: Optional[str] = None | ||
S3_ACCESS_KEY: Optional[str] = None | ||
S3_SECRET_KEY: Optional[str] = None | ||
S3_REGION: Optional[str] = None | ||
S3_ENDPOINT_URL: Optional[str] = None | ||
|
||
|
||
settings = Settings() # type: ignore[call-arg] |
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
Binary file not shown.
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.