Skip to content

Commit

Permalink
Remove version caps on flask related packages, remove psycopg2, and f…
Browse files Browse the repository at this point in the history
…ix the docker build (#1558)
  • Loading branch information
cskaandorp committed Nov 1, 2023
1 parent e234877 commit 0444692
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Build the image for testing
uses: docker/build-push-action@v4
with:
context: .
context: ./Docker/simple
load: true
tags: asreview/asreview:test
- name: Test the built image
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ thumb
sketch
notes.md

flask_config.json
flask_config.*
16 changes: 16 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ accounts and link these accounts to projects. Currently we are using a small SQL
database (asreview.development.sqlite or asreview.production.sqlite) in the ASReview
folder to store that information.

Note that it is possible to run the authenticated application with a
[Postgresql database](https://www.postgresql.org/). Using Postgresql requires 2 extra
installation steps:
1. Install the [psycopg2](https://www.psycopg.org/docs/) package. At the time of this writing
2 versions of this package exist: `psycopg2` and `psycopg2-binary`. According to the
[documentation](https://www.psycopg.org/docs/install.html#quick-install) the binary
version works on most operating systems.
2. Use the [configuration file](#full-configuration) to setup the connection
between the application and the database.

### Bare bones authentication

Using authentication imposes more configuration. Let's start with running a bare bones
Expand Down Expand Up @@ -225,6 +235,12 @@ ALLOWED_ORIGINS = ["http://localhost:3000"]
```
The HOST and PORT determine what address the ASReview server listens to. If this deviates from `localhost` and port 5000, and you run the front end separately, make sure the [front end can find the backend](#front-end-development-and-connectioncors-issues). The ALLOWED_ORIGINS key must be set if you run the front end separately. Put in a list all URLs that your front end uses. This can be more than one URL. Failing to do so will certainly lead to CORS issues.

Do you want to use a Postgresql database? Then add the `SQLALCHEMY_DATABASE_URI` key to the config file:

```toml
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://username:password@host:port/database_name"
```

### Converting an unauthenticated application into an authenticated one

Start the application with authentication enabled for the first time. This ensures the creation of the necessary database. To avoid unwanted user input, shutdown the application.
Expand Down
1 change: 1 addition & 0 deletions Docker/auth_verified/Dockerfile_backend
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN apt-get update \
&& apt-get install -y git build-essential libpq-dev\
&& pip3 install --upgrade pip setuptools \
&& pip3 install --user gunicorn \
&& pip3 install --user psycopg2 \
&& pip3 install --user . \
&& pip3 install --user asreview-datatools asreview-insights asreview-makita asreview-wordcloud

Expand Down
2 changes: 1 addition & 1 deletion asreview/webapp/authentication/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class User(UserMixin, DB.Model):
email = Column(String(100), unique=True)
name = Column(String(100))
affiliation = Column(String(100))
hashed_password = Column(String(150))
hashed_password = Column(String(500))
confirmed = Column(Boolean)
public = Column(Boolean)
token = Column(String(150))
Expand Down
3 changes: 3 additions & 0 deletions asreview/webapp/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ pytest --random-order -s -v ./asreview/webapp/tests/test_api/test_projects.py -k
## Database

A database is needed to run the tests for authenticated versions of the app. In the `config` file a number of TOML configuration files exist that are used to create different versions of the app. The configuration files that create an authenticated version of the app lack the `SQLALCHEMY_DATABASE_URI` parameter! That parameter tells the backend where it can find the database. If that parameter is missing, the app will create and initialize a sqlite3 database automatically. After the test suite has been executed, this database will be removed. In case you would like to run all tests in a specific database, you need to provide the URI of the database yourself.

If you want to use a [Postgresql database](https://www.postgresql.org/), read the DEVELOPMENT documentation
how to set it up.
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def get_long_description():
"rispy~=0.7.0",
"xlrd>=1.0.0",
"setuptools",
"flask>=2.3.0,<3",
"flask>=2.3.0",
"flask_cors",
"flask-login",
"flask-login>=0.6.3",
"flask-mail",
"Werkzeug>=2.3.2,<3",
"Werkzeug>=2.3.2",
"openpyxl",
"jsonschema",
"filelock",
Expand All @@ -65,7 +65,6 @@ def get_long_description():
"gevent>=20",
"datahugger>=0.2",
"synergy_dataset",
"psycopg2",
"sqlalchemy-utils",
]

Expand Down

0 comments on commit 0444692

Please sign in to comment.