Skip to content

Commit

Permalink
removed src/tira_app/static and fixed TIRA_DEBUG handling
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMrSheldon committed Sep 6, 2024
1 parent 74ce9f7 commit af24afd
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 399 deletions.
1 change: 1 addition & 0 deletions application/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Makefile
README.md

test/tira-root
.data-dumps


# Gitignore contentn
Expand Down
21 changes: 11 additions & 10 deletions application/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FROM debian:stable-slim AS build
ENV TZ=Europe/Berlin
RUN <<EOF
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
apt-get update && apt-get install -y locales
apt-get -qq update && apt-get -qq install -y locales
echo "en_US.UTF-8 UTF-8" | tee -a /etc/locale.gen && locale-gen
EOF

Expand All @@ -38,21 +38,21 @@ ENV PIP_BREAK_SYSTEM_PACKAGES=1
ENV GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS=16

RUN <<EOF
apt-get update
apt-get -qq update
# Tools
apt-get install -y python3 python3-pip git pkg-config
apt-get -qq install -y python3 python3-pip git pkg-config
# Dependencies (stuff needed by at least one python package)
# For MariaDB
apt-get install -y default-libmysqlclient-dev
apt-get -qq install -y default-libmysqlclient-dev
EOF

USER tira
RUN <<EOF
export PATH="/home/tira/.local/bin:$PATH"

# Install dependencies
pip3 install --no-cache-dir --user ../python-client .[test,deploy]
pip3 install -q --no-cache-dir --user ../python-client .[test,deploy]

export PATH="/home/tira/.local/bin:$PATH"
python3 manage.py collectstatic
chmod +x ./src/tira_app/endpoints/aha # FIXME; aha is not copied to the Production Container

# Run tests
Expand All @@ -77,15 +77,16 @@ RUN useradd -ms /bin/bash tira
# Copy Data & Install Python and Dependencies #
########################################################################################################################
COPY --from=build --chown=tira:tira /home/tira/.local /home/tira/.local
COPY --from=build --chown=tira:tira /tira/config /tira/config
COPY --from=build /tira/src/tira_app/management/commands/irds_cli.sh /irds_cli.sh

RUN <<EOF
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
apt-get update && apt-get install -y locales
apt-get -qq update && apt-get -qq install -y locales
echo "en_US.UTF-8 UTF-8" | tee -a /etc/locale.gen && locale-gen

# Tools
apt-get install -y python3
apt-get -qq install -y python3 python3-dev
#
mkdir -p /tira/application/src
chown -R tira:tira /tira
Expand All @@ -98,7 +99,7 @@ USER tira
ENV PATH=/home/tira/.local/bin:$PATH
# CONFIGURE THE FOLLOWING ENVIRONMENT VARIABLES IN YOUR DOCKER-COMPOSE FILE
ENV HF_HOME=/home/tira/data/publicly-shared-datasets/huggingface/
ENV TIRA_CONFIG=/tira/config/tira-application-config.docker.yml
ENV TIRA_CONFIG=/tira/config/tira-application-config.yml
ENV TIRA_DEBUG=false

EXPOSE 80
Expand Down
2 changes: 1 addition & 1 deletion application/config/tira-application-config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ---task/celebrity-profiling/user/hodge20a
debug: ${TIRA_DEBUG:false}
debug: !ENV ${TIRA_DEBUG:false}
allowed_hosts:
- "127.0.0.1"
django_secret: "not-so-secret"
Expand Down
16 changes: 9 additions & 7 deletions application/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tool.black]
line-length = 120
exclude = '''/(
src/tira/migrations
| src/tira/proto
src/tira_app/migrations
| src/tira_app/proto
)'''

[tool.isort]
Expand All @@ -11,8 +11,8 @@ multi_line_output = 3
line_length = 120
include_trailing_comma = true
skip = [
"src/tira/migrations",
"src/tira/proto",
"src/tira_app/migrations",
"src/tira_app/proto",
]

[tool.mypy]
Expand All @@ -21,8 +21,8 @@ explicit_package_bases = true
ignore_missing_imports = true
install_types = true
exclude = [
"^src/tira/proto/.*\\.py$",
"^src/tira/migrations/.*\\.py$",
"^src/tira_app/proto/.*\\.py$",
"^src/tira_app/migrations/.*\\.py$",
]

[tool.pytest.ini_options]
Expand All @@ -32,4 +32,6 @@ python_files = "test_*.py"

[tool.pytest_env]
HF_HOME = "./tira-root/huggingface"
TIRA_ROOT = "./tira-root"
TIRA_ROOT = "./tira-root"
TIRA_CONFIG = "../config/tira-application-config.yml"
TIRA_DEBUG = true
7 changes: 5 additions & 2 deletions application/src/django_admin/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
import yaml
from pyaml_env import parse_config

from tira_app.util import str2bool

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

custom_settings = {}
cfgpath = os.environ.get("TIRA_CONFIG", str(BASE_DIR / "config" / "tira-application-config.yml"))
logging.info(f"Load settings from {cfgpath}.")
config = parse_config(cfgpath, default_value=None)
config = parse_config(cfgpath, default_value=None, loader=yaml.FullLoader)
custom_settings.update(config)

if "database" not in custom_settings:
Expand All @@ -39,7 +41,7 @@


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = custom_settings["debug"]
DEBUG = str2bool(custom_settings["debug"])
ALLOWED_HOSTS = custom_settings["allowed_hosts"]

TIRA_ROOT = Path(custom_settings["tira_root"])
Expand Down Expand Up @@ -95,6 +97,7 @@
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": ("tira_app.authentication.TrustedHeaderAuthentication",),
"DEFAULT_FILTER_BACKENDS": ("rest_framework_json_api.django_filters.DjangoFilterBackend",),
"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",),
}

ROOT_URLCONF = "django_admin.urls"
Expand Down
4 changes: 1 addition & 3 deletions application/src/tira_app/endpoints/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
from rest_framework.decorators import api_view
from rest_framework.request import Request
from rest_framework.response import Response

# TODO: this does not work so I hardcoded for now
# from tira import __version__ as tira_version
from tira import __version__ as tira_version

tira_version = "0.0.136"
rest_api_version = "v1.0.0-draft"
Expand Down
147 changes: 0 additions & 147 deletions application/src/tira_app/static/tira/css/tira-style.css

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed application/src/tira_app/static/tira/img/ia-icon.png
Binary file not shown.
2 changes: 0 additions & 2 deletions application/src/tira_app/static/tira/img/image-licence.txt

This file was deleted.

Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit af24afd

Please sign in to comment.