Skip to content

Commit

Permalink
Remove the DJANGO_CONFIGURATION environment variable
Browse files Browse the repository at this point in the history
There are a few issues with it:

* It doesn't work for the Enterprise version, because its settings module is
  not located under `cvat.settings`.

* The name `DJANGO_CONFIGURATION` suggests that it's defined by Django, but
  it isn't. It's a CVAT-specific variable. There's also a 3rd-party module
  that uses this variable (django-configurations), but with different
  semantics, which could cause confusion.

* It's just redundant to have two variables that effectively do the same thing
  (`DJANGO_CONFIGURATION` and `DJANGO_SETTINGS_MODULE`).

Besides its runtime effect, `DJANGO_CONFIGURATION` is also used in the
Dockerfile to select the packages to install. I could see that still being
useful, so replace it with a build-only variable named `CVAT_CONFIGURATION`.
  • Loading branch information
SpecLad committed Sep 4, 2023
1 parent 3deadda commit 57c23b0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ COPY utils/dataset_manifest/requirements.txt /tmp/utils/dataset_manifest/require
# Exclude av from the requirements file
RUN sed -i '/^av==/d' /tmp/utils/dataset_manifest/requirements.txt

ARG DJANGO_CONFIGURATION="production"
ARG CVAT_CONFIGURATION="production"

RUN --mount=type=cache,target=/root/.cache/pip/http \
DATUMARO_HEADLESS=1 python3 -m pip wheel --no-deps \
-r /tmp/cvat/requirements/${DJANGO_CONFIGURATION}.txt \
-r /tmp/cvat/requirements/${CVAT_CONFIGURATION}.txt \
-w /tmp/wheelhouse

FROM golang:1.20.5 AS build-smokescreen
Expand All @@ -103,8 +103,8 @@ ENV TERM=xterm \
TZ=${TZ}

ARG USER="django"
ARG DJANGO_CONFIGURATION="production"
ENV DJANGO_CONFIGURATION=${DJANGO_CONFIGURATION}
ARG CVAT_CONFIGURATION="production"
ENV DJANGO_SETTINGS_MODULE="cvat.settings.${CVAT_CONFIGURATION}"

# Install necessary apt packages
RUN apt-get update && \
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM cvat/server:local

ENV DJANGO_CONFIGURATION=testing
ENV DJANGO_SETTINGS_MODULE=cvat.settings.testing
USER root

RUN apt-get update && \
Expand All @@ -25,7 +25,7 @@ RUN apt-get update && \
COPY cvat/requirements/ /tmp/cvat/requirements/
COPY utils/dataset_manifest/requirements.txt /tmp/utils/dataset_manifest/requirements.txt

RUN DATUMARO_HEADLESS=1 python3 -m pip install --no-cache-dir -r /tmp/cvat/requirements/${DJANGO_CONFIGURATION}.txt
RUN DATUMARO_HEADLESS=1 python3 -m pip install --no-cache-dir -r /tmp/cvat/requirements/testing.txt

COPY cvat-core ${HOME}/cvat-core
COPY cvat-data ${HOME}/cvat-data
Expand Down
3 changes: 1 addition & 2 deletions cvat/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

import cvat.utils.remote_debugger as debug

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cvat.settings.{}" \
.format(os.environ.get("DJANGO_CONFIGURATION", "development")))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cvat.settings.development")

application = get_asgi_application()

Expand Down
3 changes: 1 addition & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cvat.settings.{}" \
.format(os.environ.get("DJANGO_CONFIGURATION", "development")))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cvat.settings.development")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down

0 comments on commit 57c23b0

Please sign in to comment.