diff --git a/.gitignore b/.gitignore index 3f7765e..ea6b1d2 100644 --- a/.gitignore +++ b/.gitignore @@ -91,6 +91,7 @@ celerybeat-schedule # Environments .env .venv +database.env env/ venv/ ENV/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..03c0dc1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.10-slim + +RUN apt-get update \ + && apt-get -y install libpq-dev gcc \ + && pip install psycopg2 + +WORKDIR /app + +COPY requirements.txt . + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 8010 + +CMD ["python", "manage.py", "runserver", "0.0.0.0:8010"] \ No newline at end of file diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..d0b87e5 --- /dev/null +++ b/compose.yml @@ -0,0 +1,34 @@ +services: + web: + image: npsat-backend:latest + command: ["python", "manage.py", "runserver", "0.0.0.0:8010"] + volumes: + - .:/app + ports: + - "8010:8010" + depends_on: + - npsat-db + + npsat-db: + image: postgres + restart: always + env_file: + - ./database.env + healthcheck: + test: ["CMD-SHELL", "pg_isready"] + interval: 1s + timeout: 5s + retries: 10 + ports: + - "5432:5432" + volumes: + - npsat-db-data:/var/lib/postgresql/data + + adminer: + image: adminer + restart: always + ports: + - 8080:8080 + +volumes: + npsat-db-data: \ No newline at end of file diff --git a/npsat_manager/models.py b/npsat_manager/models.py index fdf1ac5..1144ab1 100644 --- a/npsat_manager/models.py +++ b/npsat_manager/models.py @@ -644,6 +644,7 @@ def process_results(results, model_run): log.error( error_message ) # log it as an error too so it goes to all the appropriate handlers + model_run.save() return # OK, now we should be safe to proceed # we're going to make a 2 dimensional numpy array where every row is a well and every column is a year diff --git a/optional-requirements.txt b/optional-requirements.txt deleted file mode 100644 index a1abb1f..0000000 --- a/optional-requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -requests -drf-yasg -pyyaml -uritemplate -numba -numpy \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index abbb30e..d295827 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,15 @@ Django==3.1.6 -arrow -djangorestframework>=3.11 -django-cors-headers -six -waitress -psycopg2 +arrow==1.3.0 +djangorestframework==3.15.1 +django-cors-headers==3.11.0 +six==1.16.0 +waitress==3.0.0 +psycopg2==2.9.9 + +# Optional Requirements +requests==2.32.3 +drf-yasg==1.21.7 +pyyaml==6.0.2 +uritemplate==4.1.1 +numba==0.60.0 +numpy==2.0.1 \ No newline at end of file