From 1a3c4bcb1c03bd8c608426ce45987d330b73b7e3 Mon Sep 17 00:00:00 2001 From: Chris Briggs Date: Thu, 25 Jan 2024 15:26:57 +0000 Subject: [PATCH] Added a few extra logging statements and updated Dockerfile --- Dockerfile | 5 ++++- india_forecast_app/app.py | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 25fb854..85dfb85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9-slim as base +FROM python:3.11-slim as base ENV PYTHONFAULTHANDLER=1 \ PYTHONHASHSEED=random \ @@ -8,6 +8,9 @@ WORKDIR /app FROM base as builder +RUN apt-get update +RUN apt-get install -y gdal-bin libgdal-dev g++ + ENV PIP_DEFAULT_TIMEOUT=100 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ PIP_NO_CACHE_DIR=1 \ diff --git a/india_forecast_app/app.py b/india_forecast_app/app.py index 7d30152..fd46797 100644 --- a/india_forecast_app/app.py +++ b/india_forecast_app/app.py @@ -150,19 +150,23 @@ def app(timestamp: dt.datetime | None, write_to_db: bool, log_level: str): with db_conn.get_session() as session: # 1. Get sites - log.info("Getting sites") + log.info("Getting sites...") site_ids = get_site_ids(session) + log.info(f"Found {len(site_ids)} sites") # 2. Load model - log.info("Loading model") + log.info("Loading model...") model = get_model() + log.info("Loaded model") # 3. Run model for each site for site_id in site_ids: - log.info(f"Running model for site={site_id}") + log.info(f"Running model for site={site_id}...") forecast_values = run_model(model=model, site_id=site_id, timestamp=timestamp) - - if forecast_values is not None: + + if forecast_values is None: + log.info(f"No forecast values for site_id={site_id}") + else: # 4. Write forecast to DB or stdout log.info(f"Writing forecast for site_id={site_id}") forecast = {