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

Set up instructions (Ubuntu) #115

Closed
dolenda opened this issue Apr 4, 2020 · 2 comments
Closed

Set up instructions (Ubuntu) #115

dolenda opened this issue Apr 4, 2020 · 2 comments

Comments

@dolenda
Copy link
Contributor

dolenda commented Apr 4, 2020

Detailed and reorganized instructions based on READ.md and issue #76 prepared on Ubuntu, POP!_OS 19.10.

Prerequisites

  • Python >= 3.6
  • npm

Update OS and clone this repo

sudo apt update
sudo apt upgrade
git clone https://github.com/ScienceCommons/curate_science.git

Python set up

Check if pip3 and python3 are installed

pip3 -V
python3 -V

Create and activate virtual environment

cd /home/user_name/your_path/curate_science
python3 -m venv cs_env
source cs_env/bin/activate

Install all necessary Python packages
Make sure that wheel is installed wheel-V, if not, install it using pip3 install wheel. Then install all required Python packages, e.g. Django, Google Cloud Storage.

pip3 install -r requirements.txt

PostgreSQL set up

Install PostgreSQL >= 9.4

sudo apt install postgresql postgresql-contrib

Create .env file and set environmental variables with your own name, password, and key

DB_USER=user_name
DB_PASS=user_password
SECRET_KEY=key

Login to postgresql interactive terminal

sudo -u postgres psql

Create a database, user, and add access

CREATE DATABASE curate;
CREATE USER [DB_USER] WITH PASSWORD '[DB_PASS]';
GRANT ALL PRIVILEGES ON DATABASE curate TO [DB_USER];
ALTER USER [DB_USER] CREATEDB;

Get backup data
Email Curate Science admin to get access to the current backup file

Quit PostgreSQL shell and restore dump. Here its name is backup.bak

\q
psql curate < backup.bak

Django set up

Execute Django migrations
Make new migrations

python manage.py makemigrations

Apply migrations

python3 manage.py migrate

Access Django admin
Fill in your username, email, password

python3 manage.py createsuperuser

Get images

See Google Cloud API to install gsutil

Copy files from the staging bucket
Create a new folder media that contains images and copy files from the bucket using multithreaded gsutil cp

mkdir media
cd media
gsutil -m cp -r gs://curate-science-staging-2.appspot.com/key_figures .

Preparation for development

Check if npm is installed. Install dependencies, yarn globally and webpack locally

npm -v
npm install
npm install -g yarn
npm install webpack

Running Tests

python3 manage.py test

Starting local server for development

python3 manage.py runserver_plus
# In a new terminal (to compile JS bundle(s) and HTML)
yarn start

App should be running at localhost:8000
Django admin should be available at localhost:8000/admin

@eplebel
Copy link
Contributor

eplebel commented Apr 6, 2020

great, thanks so much for this!
i've now added a link to your more detailed dev setup instructions within the README file, see https://github.com/ScienceCommons/curate_science/blob/master/README.md#setup

@eplebel eplebel closed this as completed Apr 6, 2020
@dolenda
Copy link
Contributor Author

dolenda commented May 1, 2020

Today I updated my OS to Ubuntu 20.04 and the app did not work. I tried to restore the virtual environment, but couldn't run python manage.py runserver_plus afterward. I had to change the version of psycopg in the requirements.txt file before the installation of python dependencies
from
psycopg2==2.7.5 psycopg2-binary==2.7.5
to
psycopg2==2.8 psycopg2-binary==2.8
Somehow psycopg 2.7.5 couldn't be installed using pip. Now everything's fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants