- The frontend stores data in DB using django.
- Django also acts as a gateway for the frontend to asynchronous send training requests to FastAPI.
- The model training updates are sent back to django by FastAPI
- Please install Postgres 12.3 (in the linked example they use PostgreSQL 9.2, please ensure you replace 9.2 with 12.3)
- If on linux, please make sure to start postgres
sudo service postgresql start
- if you use the installation guide above for unix or windows you shouldn't have to do this
- If on linux, please make sure to start postgres
- Ensure your
leanlife
environment is activated - Open a terminal in the root directory execute
pip install -r requirements.txt
- Execute
python -m spacy download en_core_web_sm
(or whatever version you'd like, just make sure to update this in utils.py) - We will now setup the postgres connection. So, ensure that postgres is up and running. Navigate to the
src
folder insideannotation_backend
, executecd LEAN-LIFE/annotation_backend/src
.- Inside the
app
folder, navigate to settings.py- Find the
DATABASES
dictionary, and replace thePASSWORD
value with your own password
- Find the
- Inside the
- Navigate to the
src
folder insideannotation_backend
,cd LEAN-LIFE/annotation_backend/src
and run:./setup.sh PASSWORD-YOU-JUST-SET
<- (passing your password in as an argument)- you will be asked to create a user here, this user is what you will use to login to the LEAN-LIFE application
- To create additional superuser/admin use django's
python manage.py createsuperuser
- Start the backend from
cd LEAN-LIFE/annotation_backend/src
folder:python manage.py runserver 0.0.0.0:8000
- Postgres is not installed:
- To check: Open up terminal and exectue
which psql
. This should return a path. - To solve: Please follow the example provided
- To check: Open up terminal and exectue
- Some other application is listening on port 5432
- To check: (Unix, Linux):
sudo lsof -i:5432
, (Windows):netstat -tulpn | grep 5432
- To solve: Get the Process ID of the application running on the port and kill the process.
- To check: (Unix, Linux):
- Paths starting with
api/
are used by Vue.js frontend to save and retrieve data. - Other paths are for supporting django templates, which might be removed in a future release.
Once we have Data Models, Django gives us a database abstraction API that lets us create, retrieve, update, and delete objects. A model class represents database table, and an instance of that class represents a particular record in the database table. We use a similar structure for our models. For more information, visit this page.
We use serailizer to convert the querysets and model instances to native Python datatypes that can be easily rendered into JSON, XML, etc.
We use different serializer like NaturalLanguageExplanationSerializer
, SingleUserAnnotatedDocumentExplanationsSerializer
, SentimentAnalysisAnnotationSerializer
, RelationExtractionAnnotationHistorySerializer
etc.