Skip to content

Commit

Permalink
Merge branch 'release/0.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
JeltevanBoheemen committed Jan 31, 2024
2 parents fcb2d94 + 2c08355 commit 91de0ef
Show file tree
Hide file tree
Showing 57 changed files with 5,246 additions and 6,175 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.org/UUDigitalHumanitieslab/sasta.svg?branch=develop)](https://travis-ci.org/UUDigitalHumanitieslab/sasta)

> SASTA: **S**emi-automatische **A**nalyse van **S**pontane **Ta**al
Annotate and analyze transcripts


Expand Down Expand Up @@ -60,7 +60,7 @@ Running the application in [development mode][8] (hit ctrl-C to stop):
$ yarn start
```

This will run the backend and frontend applications, as well as their unittests, and watch all source files for changes. You can visit the frontend on http://localhost:5000/, the browsable backend API on http://localhost:5000/api/ and the backend admin on http://localhost:5000/admin/. On every change, unittests rerun, frontend code rebuilds and open browser tabs refresh automatically (livereload).
This will run the backend and frontend applications, as well as their unittests, and watch all source files for changes. You can visit the frontend on http://localhost:8000/, the browsable backend API on http://localhost:8000/api/ and the backend admin on http://localhost:8000/admin/. On every change, unittests rerun, frontend code rebuilds and open browser tabs refresh automatically (livereload).

[8]: #development-mode-vs-production-mode

Expand Down Expand Up @@ -188,7 +188,7 @@ The purpose of development mode is to facilitate live development, as the name i
dimension | Development mode | Production mode
-----------|--------------------|-----------------
command | `yarn start` | `yarn start-p`
base address | http://localhost:5000 | http://localhost:4200
base address | http://localhost:8000 | http://localhost:4200
backend server (Django) | in charge of everything | serves backend only

frontend server (angular-cli) | serves | watch and build
Expand Down
4 changes: 2 additions & 2 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ $ python manage.py runserver
Once you see this line:

```console
Starting development server at http://127.0.0.1:5000/
Starting development server at http://127.0.0.1:8000/
```

you can visit http://localhost:5000/admin/ and http://localhost:5000/api/ in your browser of choice. If you attached an external frontend application, its main page will be at http://localhost:5000/.
you can visit http://localhost:8000/admin/ and http://localhost:8000/api/ in your browser of choice. If you attached an external frontend application, its main page will be at http://localhost:8000/.

### Enabling livereload

Expand Down
30 changes: 18 additions & 12 deletions backend/analysis/annotations/safreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,28 @@ def parse_word(self, utt_id, word_id, colname, word_data, wordposmap):
if not split_labels:
self.errors.append((utt_id, word_id, text, level, label))

for label in split_labels:
mapped = item2queryid(label, level, self.item_mapping)
if mapped:
query_id, fase = mapped
instance.annotations.append(SAFAnnotation(
level, label, fase, query_id))
self.document.exactresults[query_id].append((utt_id, word_id))

else:
logger.warning(
'Cannot resolve query_id for (%s, %s)', level, label)
self.errors.append((utt_id, word_id, text, level, label))
self.map_labels(split_labels, instance,
level, utt_id, word_id, text)

# read comments
comment_data = data.loc[data.level == SAF_COMMENT_LEVEL.lower()].dropna()
if not comment_data.empty:
instance.comment = str(comment_data[colname].iloc[0])

return instance

def map_labels(self, split_labels: List[str], saf_word: SAFWord, level: str, utt_id, word_id, text):
for label in split_labels:
mapped = item2queryid(label, level, self.item_mapping)
if mapped:
query_id, fase = mapped
saf_word.annotations.append(SAFAnnotation(
level, label, fase, query_id))
self.document.exactresults[query_id].append(
(utt_id, word_id))

else:
logger.warning(
'Cannot resolve query_id for (%s, %s)', level, label)
self.errors.append(
(utt_id, word_id, text, level, label))
6 changes: 3 additions & 3 deletions backend/analysis/management/commands/set_default_methods.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from analysis.models import Corpus, MethodCategory
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand


class Command(BaseCommand):
Expand All @@ -11,7 +11,7 @@ def handle(self, *args, **options) -> None:
for category in MethodCategory.objects.all():
print(f'Setting new defaults for category {category.name}')
self.handle_category(category)
except Exception as e:
except Exception:
pass
finally:
print('Setting new default methods complete')
Expand All @@ -28,7 +28,7 @@ def handle_category(self, category: MethodCategory):
corpus.save()
print(
f'Updated corpus {corpus.name} from {old_method.name if old_method else "None"} to {new_method.name}')
except Exception as e:
except Exception:
pass
finally:
print('Setting new default methods complete')
2 changes: 1 addition & 1 deletion backend/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main():
) from exc

from django.core.management.commands.runserver import Command as runserver
runserver.default_port = "5000"
runserver.default_port = "8000"

execute_from_command_line(sys.argv)

Expand Down
8 changes: 4 additions & 4 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ celery==5.2.7
# via
# -r requirements.in
# django-celery-results
certifi==2022.12.7
certifi==2023.7.22
# via requests
cffi==1.15.1
# via cryptography
Expand All @@ -57,7 +57,7 @@ click-repl==0.2.0
# via celery
corpus2alpino==0.3.10
# via -r requirements.in
cryptography==39.0.1
cryptography==41.0.6
# via pyjwt
cymem==2.0.6
# via
Expand Down Expand Up @@ -115,7 +115,7 @@ lxml==4.9.1
# python-docx
# sastadev
# tei-reader
markupsafe==2.1.1
markupsafe==2.0.1
# via jinja2
murmurhash==1.0.7
# via
Expand Down Expand Up @@ -257,7 +257,7 @@ typing-extensions==4.1.1
# via
# pydantic
# sastadev
urllib3==1.26.10
urllib3==1.26.18
# via
# django-revproxy
# requests
Expand Down
116 changes: 116 additions & 0 deletions backend/sasta/common_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
'''
Common settings between development and production environments.
Values here should be imported in settings.py
'''
# Application settings
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'livereload',
'django.contrib.staticfiles',
'django_celery_results',
'rest_framework',
'rest_framework.authtoken',
'allauth',
'allauth.account',
'allauth.socialaccount',
'rest_auth',
'rest_auth.registration',
'revproxy',
'analysis',
'authentication',
'parse',
'convert',
'sastadev'
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',

]

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
PROXY_FRONTEND = None

# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Europe/Amsterdam'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/media/'

# DRF
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.TokenAuthentication',
'sasta.authentication.CsrfExemptSessionAuthentication',
]
}

# Authentication
SITE_ID = 1
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_AUTHENTICATION_METHOD = 'username_email'

# Celery
CELERY_RESULT_BACKEND = 'django-db'
CELERY_IGNORE_RESULT = False
CELERY_TIMEZONE = TIME_ZONE
Loading

0 comments on commit 91de0ef

Please sign in to comment.