diff --git a/.devcontainer/Dockerfile.dev b/.devcontainer/Dockerfile.dev index bf3306d0..dc75fa13 100644 --- a/.devcontainer/Dockerfile.dev +++ b/.devcontainer/Dockerfile.dev @@ -45,15 +45,12 @@ ENV PIP_BREAK_SYSTEM_PACKAGES 1 USER root RUN apt-get update && apt-get install -y python3 python3-pip python3-dev pkg-config default-libmysqlclient-dev \ libpcre3-dev -# Create a dummy secret -COPY < "/etc/discourse/client-api-key"' pip3 install .[dev,test] make setup env: TIRA_ROOT: ${{github.workspace}}/model/src TIRA_CONFIG: ${{github.workspace}}/application/config/tira-application-config.yml + DISCOURSE_API_KEY: "I am so secret" - name: Run backend tests working-directory: ${{github.workspace}}/application/test run: pytest diff --git a/application/config/tira-application-config.yml b/application/config/tira-application-config.yml index e2089bc9..742f631a 100644 --- a/application/config/tira-application-config.yml +++ b/application/config/tira-application-config.yml @@ -2,10 +2,9 @@ debug: !ENV ${TIRA_DEBUG:false} allowed_hosts: - "*" -django_secret: "not-so-secret" +django_secret: !ENV ${DJANGO_SECRET:change-me!} # --- tira_root: !ENV ${TIRA_ROOT:/tira} -disraptor_secret_file: /etc/discourse/client-api-key # The directory where logs are written to. Defaults to TIRA_ROOT/log/tira-application # logging_dir: /mnt/ceph/tira/log/tira-application # grpc_host can be local or remote. If local, it will call localhost (i.e. for testing). If remote, it will call the vm-host @@ -22,3 +21,4 @@ database: port: !ENV ${TIRA_DB_PORT:3306} # ignored when using sqlite3 github_token: !ENV ${TIRA_GITHUB_TOKEN} discourse_api_url: !ENV ${DISCOURSE_API_URL:https://www.tira.io} +discourse_api_key: !ENV ${DISCOURSE_API_KEY:""} diff --git a/application/src/django_admin/settings.py b/application/src/django_admin/settings.py index 07bf8508..491d7be0 100644 --- a/application/src/django_admin/settings.py +++ b/application/src/django_admin/settings.py @@ -10,7 +10,6 @@ https://docs.djangoproject.com/en/3.1/ref/settings/ """ -import errno import importlib.resources as resources import logging import os @@ -52,7 +51,6 @@ (TIRA_ROOT / "state").mkdir(parents=True, exist_ok=True) -DISRAPTOR_SECRET_FILE = Path(custom_settings["disraptor_secret_file"]) HOST_GRPC_PORT = custom_settings.get("host_grpc_port", "50051") APPLICATION_GRPC_PORT = custom_settings.get("application_grpc_port", "50052") GRPC_HOST = custom_settings.get("grpc_host", "local") # can be local or remote @@ -378,6 +376,7 @@ def logger_config(log_dir: Path): USE_TZ = True DISCOURSE_API_URL = custom_settings["discourse_api_url"] +DISRAPTOR_API_KEY = custom_settings["discourse_api_key"] PUBLIC_TRAINING_DATA = set(["jena-topics-20231026-test", "leipzig-topics-20231025-test"]) CODE_SUBMISSION_REFERENCE_REPOSITORIES = { @@ -400,10 +399,3 @@ def logger_config(log_dir: Path): } CODE_SUBMISSION_REPOSITORY_NAMESPACE = "tira-io" -if DISRAPTOR_SECRET_FILE.exists(): - DISRAPTOR_API_KEY = DISRAPTOR_SECRET_FILE.read_text().strip() -elif DEBUG: - logging.warning(f"The Disraptor Secret File, {DISRAPTOR_SECRET_FILE}, could not be found.") - DISRAPTOR_API_KEY = "" -else: - raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), str(DISRAPTOR_SECRET_FILE)) diff --git a/application/test/settings_test.py b/application/test/settings_test.py index ca2c4ffc..64bfda39 100644 --- a/application/test/settings_test.py +++ b/application/test/settings_test.py @@ -10,7 +10,6 @@ https://docs.djangoproject.com/en/3.1/ref/settings/ """ -import errno import importlib.resources as resources import logging import os @@ -52,7 +51,6 @@ (TIRA_ROOT / "state").mkdir(parents=True, exist_ok=True) -DISRAPTOR_SECRET_FILE = Path(custom_settings["disraptor_secret_file"]) HOST_GRPC_PORT = custom_settings.get("host_grpc_port", "50051") APPLICATION_GRPC_PORT = custom_settings.get("application_grpc_port", "50052") GRPC_HOST = custom_settings.get("grpc_host", "local") # can be local or remote @@ -318,6 +316,7 @@ def logger_config(log_dir: Path): USE_TZ = True DISCOURSE_API_URL = custom_settings["discourse_api_url"] +DISRAPTOR_API_KEY = custom_settings["discourse_api_key"] PUBLIC_TRAINING_DATA = set(["jena-topics-20231026-test", "leipzig-topics-20231025-test"]) CODE_SUBMISSION_REFERENCE_REPOSITORIES = { @@ -328,10 +327,3 @@ def logger_config(log_dir: Path): REFERENCE_DATASETS: dict[str, str] = {} CODE_SUBMISSION_REPOSITORY_NAMESPACE = "tira-io" -if DISRAPTOR_SECRET_FILE.exists(): - DISRAPTOR_API_KEY = DISRAPTOR_SECRET_FILE.read_text().strip() -elif DEBUG: - logging.warning(f"The Disraptor Secret File, {DISRAPTOR_SECRET_FILE}, could not be found.") - DISRAPTOR_API_KEY = "" -else: - raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), str(DISRAPTOR_SECRET_FILE)) diff --git a/pipelines/src/config/tira-application-config.dev.yml b/pipelines/src/config/tira-application-config.dev.yml index 98b82d87..d7e66d17 100644 --- a/pipelines/src/config/tira-application-config.dev.yml +++ b/pipelines/src/config/tira-application-config.dev.yml @@ -1,13 +1,10 @@ # ---task/celebrity-profiling/user/hodge20a debug: true allowed_hosts: - - "0.0.0.0" -django_secret: 'not-so-secret' + - "*" +django_secret: "not-so-secret" # --- # tira_root: /mnt/ceph/tira -# deployment = {disraptor} -deployment: disraptor -# disraptor_secret_file: /etc/discourse/client-api-key # The directory where logs are written to. Defaults to TIRA_ROOT/log/tira-application # logging_dir: /mnt/ceph/tira/log/tira-application # grpc_host can be local or remote. If local, it will call localhost (i.e. for testing). If remote, it will call the vm-host @@ -16,9 +13,9 @@ grpc_host: local host_grpc_port: 50051 application_grpc_port: 50052 database: - engine: django.db.backends.sqlite3 # django.db.backends.mysql or django.db.backends.sqlite3 - name: tira # when backend is sqlite, this will be the name of the database below TIRA_ROOT/state - user: tira # ignored when using sqlite3 - password: TODO-ENTER-PASSWORD # ignored when using sqlite3 - host: tira-mariadb # ignored when using sqlite3 - port: 3306 # ignored when using sqlite3 + engine: django.db.backends.sqlite3 # django.db.backends.mysql or django.db.backends.sqlite3 + name: tira # when backend is sqlite, this will be the name of the database below TIRA_ROOT/state + user: tira # ignored when using sqlite3 + password: TODO-ENTER-PASSWORD # ignored when using sqlite3 + host: tira-mariadb # ignored when using sqlite3 + port: 3306 # ignored when using sqlite3