Skip to content

Commit

Permalink
Settings: Update django project settings (#1610)
Browse files Browse the repository at this point in the history
  • Loading branch information
deshraj authored Mar 30, 2018
1 parent 4f09e0d commit 2a536ac
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 197 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ omit =
*/middleware/*
frontend/
settings/prod.py
settings/staging.py
scripts/seed.py
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ You can also use Docker Compose to run all the components of EvalAI together. Th

### Using Virtual Environment

1. Install [python] 2.x (EvalAI only supports python2.x for now.), [git], [postgresql] version >= 10.1, [RabbitMQ] and [virtualenv], in your computer, if you don't have it already.
1. Install [python] 2.7.10 or above, [git], [postgresql] version >= 10.1, [RabbitMQ] and [virtualenv], in your computer, if you don't have it already.
*If you are having trouble with postgresql on Windows check this link [postgresqlhelp].*
2. Get the source code on your machine via git.
Expand Down Expand Up @@ -96,13 +96,13 @@ You can also use Docker Compose to run all the components of EvalAI together. Th
```
sudo -i -u (username)
createdb evalai
python manage.py migrate --settings=settings.dev
python manage.py migrate
```
6. Seed the database with some fake data to work with.
```
python manage.py seed --settings=settings.dev
python manage.py seed
```
This command also creates a `superuser(admin)`, a `host user` and a `participant user` with following credentials.
Expand All @@ -113,7 +113,7 @@ You can also use Docker Compose to run all the components of EvalAI together. Th
7. That's it. Now you can run development server at [http://127.0.0.1:8000] (for serving backend)

```
python manage.py runserver --settings=settings.dev
python manage.py runserver
```


Expand Down
6 changes: 3 additions & 3 deletions docker/dev/django/container-start.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
cd /code && \
python manage.py migrate --noinput --settings=settings.dev && \
python manage.py seed --settings=settings.dev && \
python manage.py runserver --settings=settings.dev 0.0.0.0:8000
python manage.py migrate --noinput && \
python manage.py seed && \
python manage.py runserver 0.0.0.0:8000
2 changes: 1 addition & 1 deletion docker/prod/django/evalai_supervisor.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[program:uwsgi]
directory=/code
environment=DJANGO_SETTINGS_MODULE="settings.prod"
environment=DJANGO_SETTINGS_MODULE="settings"
command=/usr/local/bin/uwsgi --ini=docker/prod/django/uwsgi.ini
autostart=true
autorestart=true
Expand Down
2 changes: 1 addition & 1 deletion docs/source/directory_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ All of the codebase related to testing resides in `tests` folder in the root dir
To perform certain actions like seeding the database, we use Django management commands. Since the management commands are common throughout the project, they are present in `base` application directory. At the moment, the only management command is `seed`, which is used to populate the database with some random values. The command can be invoked by calling

```
python manage.py seed --settings=settings.dev
python manage.py seed
```
4 changes: 2 additions & 2 deletions docs/source/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ python manage.py makemigrations jobs --name=execution_time_limit
* While creating migrations on local environment, don't forget to add development settings.

```
python manage.py makemigrations --settings=settings.dev
python manage.py makemigrations
```

The following is an example of a complete named migration for the `jobs` app, wherein a execution time limit field is added to the `Submission` model:

```
python manage.py makemigrations jobs --name=execution_time_limit --settings=settings.dev
python manage.py makemigrations jobs --name=execution_time_limit
```

* Files create after running `makemigrations` should be committed along with other files
Expand Down
16 changes: 8 additions & 8 deletions docs/source/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ createdb evalai -U postgres
# update postgres user password
psql -U postgres -c "ALTER USER postgres PASSWORD 'postgres';"
# run migrations
python manage.py migrate --settings=settings.dev
python manage.py migrate
```
* For setting up frontend, run
Expand All @@ -110,7 +110,7 @@ bower install
```
# activate virtual environment if not activated
source venv/bin/activate
python manage.py runserver --settings=settings.dev
python manage.py runserver
```

* To run frontend development server at [http://127.0.0.1:8888](http://127.0.0.1:8888), simply do:
Expand Down Expand Up @@ -205,7 +205,7 @@ createdb evalai -U postgres
# update postgres user password
psql -U postgres -c "ALTER USER postgres PASSWORD 'postgres';"
# run migrations
python manage.py migrate --settings=settings.dev
python manage.py migrate
```

* For setting up frontend, run
Expand All @@ -223,7 +223,7 @@ npm install -g bower
```
# activate virtual environment if not activated
source venv/bin/activate
python manage.py runserver --settings=settings.dev
python manage.py runserver
```

* To run frontend development server for at [frontend]
Expand All @@ -236,7 +236,7 @@ gulp dev:runserver
```
# activate virtual environment if not activated
source venv/bin/activate
python manage.py runserver --settings=settings.dev
python manage.py runserver
```

* To run frontend development server at [http://127.0.0.1:8888](http://127.0.0.1:8888), simply do:
Expand Down Expand Up @@ -302,13 +302,13 @@ Follow this guide to setup your development machine.
```
Enter your password for authentication and a new database will be added.
```
python manage.py migrate --settings=settings.dev
python manage.py migrate
```

* Seed the database with some fake data to work with.

```
python manage.py seed --settings=settings.dev
python manage.py seed
```
This command also creates a `superuser(admin)`, a `host user` and a `participant user` with following credentials.

Expand All @@ -321,7 +321,7 @@ Follow this guide to setup your development machine.
* That's it. Now you can run development server at [http://127.0.0.1:8000] (for serving backend)
```
python manage.py runserver --settings=settings.dev
python manage.py runserver
```
Expand Down
85 changes: 0 additions & 85 deletions docs/source/windows_installation.md

This file was deleted.

2 changes: 1 addition & 1 deletion evalai/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.prod")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

application = get_wsgi_application()
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.prod")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion scripts/seed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Command to run : python manage.py shell --settings=settings.dev < scripts/seed.py
# Command to run : python manage.py shell < scripts/seed.py
import os

from datetime import timedelta
Expand Down
12 changes: 12 additions & 0 deletions settings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

try:
from .dev import * # noqa
except ImportError:
pass

try:
from .prod import * # noqa
except ImportError:
pass
4 changes: 3 additions & 1 deletion settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

DEBUG = False

ALLOWED_HOSTS = ['evalapi.cloudcv.org', 'evalai.cloudcv.org']
ALLOWED_HOSTS = ['evalapi.cloudcv.org', 'evalai.cloudcv.org',
'api.evalai.cloudcv.org', 'staging.evalai.cloudcv.org']

# Database
# https://docs.djangoproject.com/en/1.10.2/ref/settings/#databases
Expand All @@ -15,6 +16,7 @@
CORS_ORIGIN_WHITELIST = (
'evalai.cloudcv.org',
'evalai.s3.amazonaws.com',
'staging.evalai.cloudcv.org',
)

DATABASES = {
Expand Down
88 changes: 0 additions & 88 deletions settings/staging.py

This file was deleted.

0 comments on commit 2a536ac

Please sign in to comment.