Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parley Model Refactor #11

Merged
merged 3 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions parlance/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
PROJECT = CONFDIR.parent.parent.parent


def environ_setting(name, required=False, default=None):
def environ_setting(name, default=None, required=False):
"""
Fetch setting from the environment or use the default. If required is set to True
then a warning is raised that Django is not configured properly.
Expand Down Expand Up @@ -158,6 +158,9 @@ def parse_bool(val):
STATIC_URL = "static/"
STATICFILES_DIRS = (PROJECT / "static",)

# Media files (uploads)
MEDIA_URL = "uploads/"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
Expand Down Expand Up @@ -228,7 +231,7 @@ def parse_bool(val):
## Logging and Error Reporting
##########################################################################

ADMINS = [("Parlance Admin", environ_setting("ADMIN_EMAIL", ""))]
ADMINS = [("Parlance Admin", environ_setting("ADMIN_EMAIL", default=""))]

SERVER_EMAIL = environ_setting("SERVER_EMAIL", default="")
EMAIL_USE_TLS = True
Expand Down
6 changes: 5 additions & 1 deletion parlance/settings/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from .base import * # noqa
from .base import PROJECT
from .base import environ_setting


##########################################################################
Expand All @@ -34,5 +35,8 @@
]

## Static files served by WhiteNoise
STATIC_ROOT = PROJECT / "assets"
STATIC_ROOT = environ_setting("STATIC_ROOT", default=PROJECT / "storage" / "static")
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

## Media files and uploads
MEDIA_ROOT = environ_setting("MEDIA_ROOT", default=PROJECT / "storage" / "uploads")
4 changes: 2 additions & 2 deletions parlance/settings/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"http://127.0.0.1:8000",
]

MEDIA_ROOT = PROJECT / "tmp" / "media"
MEDIA_ROOT = PROJECT / "tmp" / "uploads"

## Static files served by WhiteNoise nostatic server
STATIC_ROOT = PROJECT / "tmp" / "assets"
STATIC_ROOT = PROJECT / "tmp" / "static"
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

# Debugging email without SMTP
Expand Down
5 changes: 4 additions & 1 deletion parlance/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")

## Static files served by WhiteNoise
STATIC_ROOT = PROJECT / "assets"
STATIC_ROOT = environ_setting("STATIC_ROOT", default=PROJECT / "storage" / "static")
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

## Media files and uploads
MEDIA_ROOT = environ_setting("MEDIA_ROOT", default=PROJECT / "storage" / "uploads")


##########################################################################
## Sentry Error Management
Expand Down
3 changes: 2 additions & 1 deletion parley/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from collections import defaultdict
from parley.exceptions import ParlanceUploadError
from django.core.exceptions import ValidationError
from parley.models import LLM, Evaluation, Prompt, Response
from parley.models import LLM, Evaluation, Prompt, Response, Sensitive


##########################################################################
Expand Down Expand Up @@ -135,6 +135,7 @@ def handle_uploaded_file(self, td, f, counts):
'evaluation': Evaluation,
'prompt': Prompt,
'response': Response,
'sensitive': Sensitive,
}.get(row.pop('type').strip().lower(), None)

if rtype is None:
Expand Down
Loading