Skip to content

Commit

Permalink
Merge pull request #22 from kartoza/feat-spw
Browse files Browse the repository at this point in the history
Feat SPW model integration
  • Loading branch information
danangmassandy committed Jul 22, 2024
2 parents fe1db70 + 0df1730 commit 3463957
Show file tree
Hide file tree
Showing 42 changed files with 2,726 additions and 97 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"../deployment/docker-compose.override.devcontainer.yml"
],
"service": "dev",
"runServices": ["db", "minio", "redis", "celery_beat", "worker", "dev"],
"runServices": ["db", "minio", "plumber", "redis", "celery_beat", "worker", "dev"],
"workspaceFolder": "/home/web/project",
"runArgs": [
"--env-file",
Expand All @@ -23,7 +23,7 @@
"shutdownAction": "stopCompose",
"customizations": {
"vscode": {
"extensions": ["ms-python.python", "ms-azuretools.vscode-docker"],
"extensions": ["ms-python.python", "ms-azuretools.vscode-docker", "njpwerner.autodocstring"],
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/local/bin/python",
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ coverage:
changes: false
patch:
default:
threshold: "5%"
threshold: "10%"
ignore:
- "**/migrations/*.py"
- "django_project/core/settings/*.py"
5 changes: 4 additions & 1 deletion deployment/.template.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ DATABASE_PORT=5432
REDIS_HOST=redis
REDIS_PASSWORD=redis_password

RABBITMQ_HOST=rabbitmq
SENTRY_DSN=
INITIAL_FIXTURES=
PLUMBER_PORT=8282

# Minio Variables for django default storages
MINIO_AWS_ACCESS_KEY_ID=minio_tomorrownow
Expand All @@ -42,3 +42,6 @@ SALIENT_AWS_ENDPOINT_URL=
SALIENT_AWS_BUCKET_NAME=tomorrownow
SALIENT_AWS_DIR_PREFIX=
SALIENT_AWS_REGION_NAME=

# API keys
TOMORROW_IO_API_KEY=
16 changes: 16 additions & 0 deletions deployment/docker-compose.override.devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ services:
links:
- db
- worker
- plumber

minio:
image: quay.io/minio/minio:RELEASE.2024-03-30T09-41-56Z.fips
Expand All @@ -62,3 +63,18 @@ services:
volumes:
- ./volumes/minio_data:/data
restart: always

plumber:
build:
context: ../
dockerfile: deployment/plumber/Dockerfile
env_file:
- .env
volumes:
- ../:/home/web/project
- ../django_project:/home/web/django_project
ports:
- "8282:8282"
links:
- db
- redis
12 changes: 12 additions & 0 deletions deployment/docker-compose.override.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ services:
- celery_beat
entrypoint: [ ]

plumber:
build:
context: ../
dockerfile: deployment/plumber/Dockerfile
env_file:
- .env
volumes:
- ../django_project:/home/web/django_project
links:
- db
- redis

minio:
image: quay.io/minio/minio:RELEASE.2024-03-30T09-41-56Z.fips
command: minio server /data --console-address ":9001"
Expand Down
1 change: 0 additions & 1 deletion deployment/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ services:
- DATABASE_USERNAME=docker
- DATABASE_PASSWORD=docker
- DATABASE_HOST=db
- RABBITMQ_HOST=rabbitmq
- DJANGO_SETTINGS_MODULE=core.settings.test
- SECRET_KEY=SECRET_KEY

Expand Down
12 changes: 12 additions & 0 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ services:
links:
- db
- worker
- plumber

worker:
<<: *default-common-django
Expand All @@ -63,6 +64,7 @@ services:
- db
- redis
- celery_beat
- plumber

celery_beat:
<<: *default-common-django
Expand All @@ -81,3 +83,13 @@ services:
- nginx-cache:/home/web/nginx_cache
links:
- django

plumber:
build:
context: ../
dockerfile: deployment/plumber/Dockerfile
env_file:
- .env
links:
- db
- redis
4 changes: 3 additions & 1 deletion deployment/docker/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ pdbpp
responses
mock==4.0.3

pytest-django
pytest-django
# mock requests
requests-mock
42 changes: 42 additions & 0 deletions deployment/plumber/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM rstudio/plumber:v1.2.0 AS prod

# install python 3.10
RUN apt-get update -y && apt-get upgrade -y

RUN apt install software-properties-common -y

RUN add-apt-repository ppa:deadsnakes/ppa

RUN apt install Python3.10

RUN apt-get install -y --no-install-recommends \
gcc gettext cron \
spatialite-bin libsqlite3-mod-spatialite \
python3-dev python3-gdal python3-psycopg2 python3-ldap \
python3-pip python3-pil python3-lxml python3-pylibmc \
uwsgi uwsgi-plugin-python3 \
libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev

# install R packages
RUN install2.r --error tidyverse tidygam mgcv ggpubr classInt zoo

# Install pip packages
ADD deployment/docker/requirements.txt /requirements.txt
RUN pip3 install --upgrade pip && pip install --upgrade pip
# Fix uwsgi build failure missing cc1
ARG CPUCOUNT=1
RUN pip3 install -r /requirements.txt

# add django project
ADD django_project /home/web/django_project

# create directories
RUN mkdir -p /home/web/plumber_data/

# add entrypoint.sh
ADD django_project/plumber_entrypoint.sh /home/web/plumber_entrypoint.sh

EXPOSE 8181

WORKDIR /home/web/django_project
ENTRYPOINT [ "/home/web/plumber_entrypoint.sh" ]
3 changes: 2 additions & 1 deletion django_project/core/settings/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
'core',
'frontend',
'gap',
'gap_api'
'gap_api',
'spw'
)

TEMPLATES[0]['DIRS'] += [
Expand Down
3 changes: 2 additions & 1 deletion django_project/gap/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class DatasetAdmin(admin.ModelAdmin):
"""Dataset admin."""

list_display = (
'name', 'provider', 'type', 'time_step', 'store_type',
'name', 'provider', 'type', 'time_step',
'store_type', 'is_internal_use'
)


Expand Down
6 changes: 6 additions & 0 deletions django_project/gap/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
from gap.providers.cbam import CBAMNetCDFReader
from gap.providers.salient import SalientNetCDFReader
from gap.providers.tahmo import TahmoDatasetReader
from gap.providers.tio import (
TomorrowIODatasetReader,
PROVIDER_NAME as TIO_PROVIDER
)


def get_reader_from_dataset(dataset: Dataset):
Expand All @@ -27,6 +31,8 @@ def get_reader_from_dataset(dataset: Dataset):
return SalientNetCDFReader
elif dataset.provider.name == 'Tahmo':
return TahmoDatasetReader
elif dataset.provider.name == TIO_PROVIDER:
return TomorrowIODatasetReader
else:
raise TypeError(
f'Unsupported provider name: {dataset.provider.name}'
Expand Down
1 change: 0 additions & 1 deletion django_project/gap/providers/cbam.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
)



class CBAMNetCDFReader(BaseNetCDFReader):
"""Class to read NetCDF file from CBAM provider."""

Expand Down
2 changes: 1 addition & 1 deletion django_project/gap/providers/tahmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
Tomorrow Now GAP.
.. note:: CBAM Data Reader
.. note:: Tahmo Data Reader
"""

from typing import List
Expand Down
Loading

0 comments on commit 3463957

Please sign in to comment.