Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
35ff983
Merge pull request #103 from QuantuMobileSoftware/#14329-Please-fix-C…
Madog000 Jan 13, 2021
e209842
14329_fix_CI_for_clearcut
DmitriyLugovoy Apr 20, 2021
b026724
Merge pull request #105 from QuantuMobileSoftware/14329_fix_CI_for_cl…
DmitriyLugovoy Apr 20, 2021
96e3af9
14329_fix_CI_for_clearcut
DmitriyLugovoy Apr 20, 2021
a209d3f
Merge pull request #106 from QuantuMobileSoftware/14329_fix_CI_for_cl…
DmitriyLugovoy Apr 20, 2021
fe3eb32
15374 update docker-compose-prod.yml
DmitriyLugovoy May 17, 2021
b47c678
Merge pull request #107 from QuantuMobileSoftware/15374_fix_external_…
DmitriyLugovoy May 17, 2021
12005c0
15374 update prod_settings.py
DmitriyLugovoy May 17, 2021
e7be5e8
Merge pull request #108 from QuantuMobileSoftware/15374_fix_external_…
DmitriyLugovoy May 17, 2021
c6f22de
15374 increase celery task time limit
DmitriyLugovoy May 17, 2021
c833de1
15374 update clearcut_detection_backend/cron_tab_prod
DmitriyLugovoy May 17, 2021
9674975
Merge pull request #109 from QuantuMobileSoftware/15374_fix_external_…
DmitriyLugovoy May 17, 2021
56d102f
15374 update docker-compose-prod.yml for model
DmitriyLugovoy May 17, 2021
099b7e4
Merge pull request #110 from QuantuMobileSoftware/15374_fix_external_…
DmitriyLugovoy May 17, 2021
22a1fbc
15374 update docker-compose-prod.yml - add deploy for gpu
DmitriyLugovoy May 18, 2021
16f0833
15374 fix docker-compose-prod.yml
DmitriyLugovoy May 18, 2021
e2eaefd
15374 fix path to lancover
DmitriyLugovoy May 18, 2021
af4859c
15374 fix clearcut_detection_backend/model2/utils.py path to landcove…
DmitriyLugovoy May 18, 2021
db3ca74
15374 add logs
DmitriyLugovoy May 18, 2021
08cc20a
15374 fix path to results in model
DmitriyLugovoy May 19, 2021
2ec1879
Merge pull request #111 from QuantuMobileSoftware/15374_fix_external_…
DmitriyLugovoy May 19, 2021
b2ce131
15374 disable cron
DmitriyLugovoy May 19, 2021
e025f13
Merge pull request #112 from QuantuMobileSoftware/15374_fix_external_…
DmitriyLugovoy May 19, 2021
c86337a
15374 add path vars to config file
DmitriyLugovoy May 19, 2021
588d8ce
Merge pull request #113 from QuantuMobileSoftware/15374_fix_external_…
DmitriyLugovoy May 19, 2021
1bccc35
15374 fix logging in model2
DmitriyLugovoy May 19, 2021
f8f8382
Merge pull request #114 from QuantuMobileSoftware/15374_fix_external_…
DmitriyLugovoy May 19, 2021
b5041b8
Update django.Dockerfile
Madog000 Oct 11, 2021
2f23945
fix clearcut_detection_backend/django.Dockerfile
DmitriyLugovoy Oct 22, 2021
d2f32c4
fix clearcut_detection_backend/django.Dockerfile
DmitriyLugovoy Oct 22, 2021
3cc3aae
Merge branch 'master' into fix_numpy
DmitriyLugovoy Oct 26, 2021
151238e
fix_numpy
DmitriyLugovoy Oct 26, 2021
383845d
fix_numpy
DmitriyLugovoy Oct 26, 2021
c084763
fix_numpy
DmitriyLugovoy Oct 26, 2021
3ed13a7
updated django.Dockerfile
DmitriyLugovoy Oct 28, 2021
7aaad0a
requirements.txt was cleaned out
DmitriyLugovoy Oct 29, 2021
03a2573
Merge pull request #115 from QuantuMobileSoftware/fix_numpy
DmitriyLugovoy Oct 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
EMAIL_HOST_USER = 'SET_ME_PLEASE_SMTP_USERNAME'
EMAIL_HOST_PASSWORD = 'SET_ME_PLEASE_SMTP_PASSWORD'
EMAIL_ADMIN_MAIL = ['SET_ME_PLEASE_SMTP_ADMIN_MAIL']

DOWNLOADED_IMAGES_DIR = Path('/data/source_images/')
MODEL_TIFFS_DIR = Path('/data/model_tiffs')
MAPBOX_TIFFS_DIR = Path('/data/mapbox_tiffs')
2 changes: 1 addition & 1 deletion clearcut_detection_backend/cron_tab_prod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Cron tab prod

0 0,12 * * * python update.py
#0 0,12 * * * python update_new.py
114 changes: 53 additions & 61 deletions clearcut_detection_backend/django.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,79 +1,71 @@
FROM python:3.6
FROM python:3.7.7

# Set environment variables
#ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV ROOTDIR /usr/local/
ENV GDAL_VERSION 2.2.4
ENV OPENJPEG_VERSION 2.2.0
ARG GDAL_VERSION=3.1.4

WORKDIR $ROOTDIR/
WORKDIR ${ROOTDIR}/

ADD http://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz $ROOTDIR/src/
ADD https://github.com/uclouvain/openjpeg/archive/v${OPENJPEG_VERSION}.tar.gz $ROOTDIR/src/openjpeg-${OPENJPEG_VERSION}.tar.gz
RUN apt-get update && apt-get upgrade -y\
&& apt-get install software-properties-common -y\
&& add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main"\
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -\
&& apt-get update\
&& apt-get install postgresql-client-13 -y\
&& apt-get install sqlite3 -y

# See https://docs.djangoproject.com/en/3.1/ref/contrib/gis/install/geolibs/

RUN apt-get update -y && apt-get install -y \
software-properties-common \
python3-software-properties \
build-essential \
python-dev \
python3-dev \
python-numpy \
python3-numpy \
libspatialite-dev \
sqlite3 \
libpq-dev \
libcurl4-gnutls-dev \
libproj-dev \
libxml2-dev \
libgeos-dev \
libnetcdf-dev \
libpoppler-dev \
libspatialite-dev \
libhdf4-alt-dev \
libhdf5-serial-dev \
bash-completion \
cmake
RUN wget https://download.osgeo.org/geos/geos-3.8.1.tar.bz2 \
&& tar -xjf geos-3.8.1.tar.bz2 \
&& cd geos-3.8.1 \
&& ./configure \
&& make \
&& make install \
&& cd .. \
&& rm -rf geos-3.8.1 geos-3.8.1.tar.bz2

RUN /bin/bash -c "pip install numpy==1.16.4"
RUN wget https://download.osgeo.org/proj/proj-6.3.2.tar.gz \
&& wget https://download.osgeo.org/proj/proj-datumgrid-1.8.tar.gz \
&& tar -xzf proj-6.3.2.tar.gz \
&& mkdir proj-6.3.2/nad && cd proj-6.3.2/nad \
&& tar -xzf ../../proj-datumgrid-1.8.tar.gz \
&& cd .. \
&& ./configure \
&& make \
&& make install \
&& cd .. \
&& rm -rf proj-6.3.2 proj-6.3.2.tar.gz proj-datumgrid-1.8.tar.gz

# Compile and install OpenJPEG
RUN cd src && tar -xvf openjpeg-${OPENJPEG_VERSION}.tar.gz && cd openjpeg-${OPENJPEG_VERSION}/ \
&& mkdir build && cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$ROOTDIR \
&& make && make install && make clean \
&& cd $ROOTDIR && rm -Rf src/openjpeg*
RUN apt-get -y install python3-pip
RUN pip3 install numpy==1.17.3

# Compile and install GDAL
RUN cd src && tar -xvf gdal-${GDAL_VERSION}.tar.gz && cd gdal-${GDAL_VERSION} \
&& ./configure --with-python --with-spatialite --with-pg --with-curl --with-openjpeg=$ROOTDIR \
&& make && make install && ldconfig \
&& apt-get update -y \
&& apt-get remove -y --purge build-essential wget \
&& cd $ROOTDIR && cd src/gdal-${GDAL_VERSION}/swig/python \
RUN wget https://download.osgeo.org/gdal/${GDAL_VERSION}/gdal-${GDAL_VERSION}.tar.gz \
&& tar -xzf gdal-${GDAL_VERSION}.tar.gz \
&& cd gdal-${GDAL_VERSION} \
&& ./configure --with-python=python3.7 --with-proj=${ROOTDIR} \
&& make \
&& make install \
&& cd swig/python \
&& python3 setup.py build \
&& python3 setup.py install \
&& cd $ROOTDIR && rm -Rf src/gdal*
&& cd ${ROOTDIR} \
&& rm -rf gdal-${GDAL_VERSION} gdal-${GDAL_VERSION}.tar.gz

# Output version and capabilities by default.
CMD gdalinfo --version && gdalinfo --formats && ogrinfo --formats
RUN git clone https://github.com/mapbox/tippecanoe.git \
&& cd tippecanoe \
&& git checkout tags/1.36.0 \
&& make -j \
&& make install \
&& cd .. \
&& rm -rf tippecanoe

RUN apt-get install -y libgdal-dev
RUN ldconfig

RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install -y postgresql-client locales \
&& apt-get install -y gdal-bin python-gdal python3-gdal \
&& apt-get update && apt-get install -y gettext libgettextpo-dev \
# Cleanup
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
# mkdir for app
&& mkdir /code
RUN mkdir /code

# Set work directory
WORKDIR /code

# Install dependencies
COPY requirements.txt /code
RUN pip3 install -r requirements.txt
COPY requirements.txt /code/

RUN pip3 install -r requirements.txt
191 changes: 96 additions & 95 deletions clearcut_detection_backend/docker-compose-prod.yml
Original file line number Diff line number Diff line change
@@ -1,101 +1,102 @@
db_prod:
image: clearcut_detection/postgis_prod
expose:
- 5432
# ports:
# - "5433:5432"
env_file:
- db.env
volumes:
- ./db-data_prod/data:/var/lib/postgresql/data
- ./:/code
services:
db_prod:
image: clearcut_detection/postgis_prod
expose:
- 5432
ports:
- "5433:5432"
env_file:
- db.env
volumes:
- /home/clearcut/prod/db-data_prod/data:/var/lib/postgresql/data
- ./:/code

model_prod_2:
image: clearcut_detection/model2_prod
env_file:
- ./model2/model.env
# - ./model2/db.env
# - ./model2/rabbitmq.env
volumes:
- ./model2/:/model
- ./data/:/model/data
working_dir: /model
environment:
- DB_HOST=db_prod
- RABBITMQ_HOST=rabbitmq_prod
- CUDA_VISIBLE_DEVICES=0
- PREDICT=1
links:
- "rabbitmq_prod"
- "db_prod"
command: /bin/bash -c "./run_predict.sh" # todo
model_prod_2:
image: clearcut_detection/model2_prod
env_file:
- ./model2/model.env
volumes:
- ./model2/:/model
- /home/clearcut/prod/data_prod:/data
working_dir: /model
environment:
- DB_HOST=db_prod
- RABBITMQ_HOST=rabbitmq_prod
- CUDA_VISIBLE_DEVICES=0
- PREDICT=1
links:
- "rabbitmq_prod"
- "db_prod"
deploy:
resources:
reservations:
devices:
- capabilities: ["gpu"]
driver: "nvidia"
device_ids: ["GPU-b51efca2-01e2-2215-9434-5cc94ec7716e"]

react_prod:
image: node:10.15.0
volumes:
- ./frontend:/frontend
working_dir: /frontend
expose:
- "3001"
links:
- "django_prod"
command: /bin/bash -c "npm install && npm run-script build"
command: /bin/bash -c "./run_predict.sh" # todo

django_prod:
image: clearcut_detection/backend_prod
env_file:
- db.env
- django.env
- rabbitmq.env
environment:
- DJANGO_SETTINGS_MODULE=clearcut_detection_backend.prod_settings
- DB_HOST=db_prod
- RABBITMQ_HOST=rabbitmq_prod
# - SENTINEL_DOWNLOAD=1 # prevent requesting to sentinel
# - DOWNLOAD_IMG=0 # skip downloading images if SENTINEL_DOWNLOAD=true
# - PREPARE_TIF=1 # skip preprocessing images
# - MAKE_PREDICT=0 # skip predicting of clearcuts
# - CONVERT_TO_TIFF=0 # skip converting to tiff for uploading
# - UPLOAD_TO_MAPBOX=1 # skip uploading to mapbox server
volumes:
- ./:/code
working_dir: /code
links:
- "db_prod"
# - "model_prod_2"
- "rabbitmq_prod"
expose:
- 9000
# ports:
# - "9001:9000"
command: /bin/bash -c "exec invoke runbackend"
react_prod:
image: node:10.15.0
volumes:
- ./frontend:/frontend
working_dir: /frontend
command: /bin/bash -c "npm install && npm run-script build"

nginx_prod:
image: nginx:1.15.8
links:
- "django_prod"
expose:
- "8080"
# ports:
# - "8082:8082"
environment:
- VIRTUAL_HOST=clearcut.quantumobile.com
- VIRTUAL_PORT=8080
- LETSENCRYPT_HOST=clearcut.quantumobile.com
- LETSENCRYPT_EMAIL=o.tsiapa@quantumobile.com
volumes:
- ./nginx/nginx_prod.conf:/etc/nginx/conf.d/default.conf
- ./frontend/build:/frontend/build
django_prod:
image: clearcut_detection/backend_prod
env_file:
- db.env
- django.env
- rabbitmq.env
environment:
- DJANGO_SETTINGS_MODULE=clearcut_detection_backend.prod_settings
- DB_HOST=db_prod
- RABBITMQ_HOST=rabbitmq_prod
# - SENTINEL_DOWNLOAD=1 # prevent requesting to sentinel
# - DOWNLOAD_IMG=0 # skip downloading images if SENTINEL_DOWNLOAD=true
# - PREPARE_TIF=1 # skip preprocessing images
# - MAKE_PREDICT=0 # skip predicting of clearcuts
# - CONVERT_TO_TIFF=0 # skip converting to tiff for uploading
# - UPLOAD_TO_MAPBOX=1 # skip uploading to mapbox server
volumes:
- ./:/code
- /home/clearcut/prod/data_prod:/data
working_dir: /code
links:
- "db_prod"
- "rabbitmq_prod"
expose:
- 9000
command: /bin/bash -c "exec invoke runbackend"

rabbitmq_prod:
hostname: "rabbitmq_prod"
labels:
NAME: "rabbitmq_prod"
image: "rabbitmq"
env_file:
- rabbitmq.env
expose:
- 15672
- 5672
restart: always
nginx_prod:
image: nginx:1.15.8
links:
- "django_prod"
expose:
- "8080"
ports:
- "8080:8080"
environment:
- VIRTUAL_HOST=clearcut.quantumobile.com
- VIRTUAL_PORT=8080
- LETSENCRYPT_HOST=clearcut.quantumobile.com
- LETSENCRYPT_EMAIL=o.tsiapa@quantumobile.com
volumes:
- ./nginx/nginx_prod.conf:/etc/nginx/conf.d/default.conf
- ./frontend/build:/frontend/build

rabbitmq_prod:
hostname: "rabbitmq_prod"
labels:
NAME: "rabbitmq_prod"
image: "rabbitmq"
env_file:
- rabbitmq.env
expose:
- 15672
- 5672
restart: always

2 changes: 1 addition & 1 deletion clearcut_detection_backend/model2/celeryconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
worker_prefetch_multiplier = 1
worker_max_tasks_per_child = 1
task_acks_late = True
task_time_limit = 60 * 15
task_time_limit = 60 * 60
# database_table_names = {
# 'task': 'django_celery_results_taskresult',
# 'group': 'myapp_groupmeta',
Expand Down
14 changes: 14 additions & 0 deletions clearcut_detection_backend/model2/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import yaml
from pathlib import Path

with open('/model/predict_config.yml', 'r') as config:
cfg = yaml.load(config, Loader=yaml.SafeLoader)
Expand All @@ -18,3 +19,16 @@
RABBITMQ_PASS = os.environ.get('RABBITMQ_DEFAULT_PASS', 'guest')
RABBITMQ_HOST = os.environ.get('RABBITMQ_HOST', 'rabbitmq_prod')
RABBITMQ_PORT_NUMBER = os.environ.get('RABBITMQ_NODE_PORT_NUMBER', 5672)
CUDA_VISIBLE_DEVICES = os.environ.get('CUDA_VISIBLE_DEVICES', '0')

SCOPES = ['https://www.googleapis.com/auth/drive.file']

LANDCOVER_POLYGONS_PATH = Path('/data/landcover')
PREDICTED_PATH = Path('/data/predicted')
LANDCOVER_FILENAME = 'S2A_OPER_GIP_TILPAR_MPC__20151209T095117_V20150622T000000_21000101T000000_B00.kml'
SENTINEL_TILES = LANDCOVER_POLYGONS_PATH / LANDCOVER_FILENAME
LANDCOVER_GEOJSON = LANDCOVER_POLYGONS_PATH / 'landcover_polygons.geojson'

CLOUDS_PROBABILITY_THRESHOLD = 15
NEAREST_POLYGONS_NUMBER = 10
DATES_FOR_TILE = 2
Loading