Skip to content

Commit

Permalink
Removing the StanfordCoreNLP pre-requisite when using Docker vishakha…
Browse files Browse the repository at this point in the history
…-lall#99 resolved (vishakha-lall#104)

* handled env file paths and templates

* SCNLP pre-requisite removed; fixes vishakha-lall#99

* changed setup instructions in README.md
  • Loading branch information
chttrjeankr authored Mar 26, 2020
1 parent dbdc69c commit eafbd37
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 71 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM python:3.6
COPY requirements.txt ./requirements.txt
RUN pip install -r requirements.txt

COPY . /usr/var/
WORKDIR /usr/var/
COPY . /usr/var/MapBot
WORKDIR /usr/var/MapBot

CMD ["python", "./init.py"]
ENTRYPOINT ["/bin/sh","./docker-entrypoint.sh"]
9 changes: 9 additions & 0 deletions ENV/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DB_USER=root
DB_PASSWORD=<YOUR_MYSQL_ROOT_USER_PASSWORD_HERE>
DB_HOST=localhost
DATABASE=mapbot
DB_PORT=3306
GCLOUD_API_KEY=<YOUR_API_KEY_HERE>
JAVAHOME=<YOUR_JAVAHOME_PATH_HERE>
STANFORD_PATH_TO_JAR=<YOUR_STANFORD_PATH_TO_JAR_HERE>
STANFORD_PATH_TO_MODELS_JAR=<YOUR_STANFORD_PATH_TO_MODELS_JAR_HERE>
9 changes: 9 additions & 0 deletions ENV/docker.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DB_USER=root
DB_PASSWORD=root
DB_HOST=db
DATABASE=mapbot
DB_PORT=3306
GCLOUD_API_KEY=<YOUR_API_KEY_HERE>
JAVAHOME=/usr/local/openjdk-11/bin/java
STANFORD_PATH_TO_JAR=./stanford-corenlp-full-2018-10-05/stanford-corenlp-3.9.2.jar
STANFORD_PATH_TO_MODELS_JAR=./stanford-corenlp-full-2018-10-05/stanford-corenlp-3.9.2-models.jar
29 changes: 6 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,9 @@ Check out all related information [here](GSSoC.md)
- Enter root password when prompted
- `create database mapbot;`
- Verify creation of the database `show databases;`
- Unzip the StanfordCoreNLP package in the repository and keep the file names `stanford-corenlp-x.x.x.jar` and `stanford-corenlp-x.x.x-models.jar` handy.
- Run `git rm --cached config.py`
- Create a file `.env` in the base directory of the repository
- Copy the content of `template.txt` into `.env`
- Edit the `.env` file with the corresponding values
- mapbotuser = "root"
- mapbotpassword = <your_root_password>
- mapbothost = "localhost"
- mapbotdatabase = "mapbot"
- mapbotkey = <your_Google_Cloud_API_key>
- stanford_path_to_jar = <your_path_to_stanford-corenlp-x.x.x.jar>
- stanford_path_to_models_jar = <your_path_to_stanford-corenlp-x.x.x-models.jar>
- javahome = <your_path_to_jdk_bin_java.exe>
- Unzip the StanfordCoreNLP package in the repository and keep the file paths `stanford-corenlp-x.x.x.jar` and `stanford-corenlp-x.x.x-models.jar` handy.
- Run `git update-index --assume-unchanged ENV/*`
- Fill the existing template in `ENV/.env` with the corresponding values following the `KEY=VALUE` format
- Install dependencies from `requirements.txt` file. Run `pip install -r requirements.txt`
- You're all set up, run the `init.py` file. `python init.py`
- It is recommended that you set this project up in a virtual environment to keep the dependencies separated and for easier debugging. Here's how you can do that -
Expand All @@ -71,22 +61,15 @@ Check out all related information [here](GSSoC.md)

#### What are some pre-requisites? (with Docker)

- StanfordCoreNLP
- StanfordCoreNLP has a dependency on Java 8. `java -version` should complete successfully with version 1.8 or higher.
- Windows- Download as a .zip file from [here](https://stanfordnlp.github.io/CoreNLP/download.html).
- Linux and MacOS- Follow the instructions to download the file from [here](https://stanfordnlp.github.io/CoreNLP/download.html).
- Docker
- Take a look at [this](https://docs.docker.com/install/) for detailed installation instructions for Docker on Windows, Linux and Mac systems.
- Verify the installations by `docker --version` and `docker-compose --version`
- You won't need to download MySQL locally to make Docker work, but it's recommended as a pre-requisite to be able to debug programs outside Docker.

#### How to set me up Docker style?
- Clone the repository
- Unzip the StanfordCoreNLP package in the repository. Make sure the StanfordCoreNLP folder you downloaded in the prerequisite steps are in the cloned repository folder.
- Add config.py file to .gitignore to avoid pushing changes made to config
- Run `git rm --cached config.py`
- Modify *only* the following fields in `config.py` file with the corresponding values:
- key = <your_Google_Cloud_API_key>
- Run `git update-index --assume-unchanged ENV/*`
- Modify *only* the following fields in `ENV/docker.env` with the corresponding values:
- `GCLOUD_API_KEY=<your_Google_Cloud_API_key>`
- You're all set up, kick off with `start.sh` file by running `bash start.sh`.

------
Expand Down
39 changes: 18 additions & 21 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
import os
import dotenv
from dotenv import load_dotenv

dotenv.load_dotenv()
if os.getenv("DOCKER") == 'Y':
load_dotenv('ENV/docker.env')
else:
load_dotenv('ENV/.env')

user = os.getenv('mapbotuser')
password = os.getenv('mapbotpassword')
host = os.getenv('mapbothost')
database = os.getenv('mapbotdatabase')
port = os.getenv('mapbotport')
key = os.getenv('mapbotkey')
### MAKE SURE you have filled environment variables in `.env` files in `./ENV/` folder

stanford_path_to_jar = os.getenv('stanford_path_to_jar')
user = os.getenv("DB_USER")
password = os.getenv("DB_PASSWORD")
host = os.getenv("DB_HOST")
database = os.getenv("DATABASE")
port = os.getenv("DB_PORT")
key = os.getenv("GCLOUD_API_KEY") # Will be provided by mentors

stanford_path_to_models_jar = os.getenv('stanford_path_to_models_jar')
# your_path_to_stanford-corenlp-x.x.x.jar
stanford_path_to_jar = os.getenv("STANFORD_PATH_TO_JAR")

javahome = os.getenv('javahome')
# your_path_to_stanford-corenlp-x.x.x-models.jar
stanford_path_to_models_jar = os.getenv("STANFORD_PATH_TO_MODELS_JAR")


# DONOT CHANGE THE VALUES BELOW DURING INITIAL CONFIGURATION SET UP

docker = os.getenv("DOCKER")
if(docker=="Y"):
# print("Inside Docker")
user = os.getenv('dockeruser')
password = os.getenv('dockerpassword')
host = os.getenv('dockerhost')
javahome = os.getenv('dockerjavahome')
# for eg. 'C:\\Program\ Files\\Java\\jdk1.8.0_201\\bin\\java.exe' or '/usr/local/openjdk-11/bin/java'
javahome = os.getenv("JAVAHOME")
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
image: python:3.6
container_name: mapbot_bot
environment:
- DOCKER=true
- DOCKER=Y
build:
context: .
dockerfile: Dockerfile
Expand All @@ -29,7 +29,7 @@ services:
- java
volumes:
- java_storage:/usr/local/openjdk-11/:ro
- .:/usr/var
- .:/usr/var/MapBot
stdin_open: true
tty: true

Expand Down
12 changes: 12 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set -ex

if [ ! -d ./stanford-corenlp-full-2018-10-05 ]; then
wget http://nlp.stanford.edu/software/stanford-corenlp-full-2018-10-05.zip -nc -c
fi

if [ -f stanford-corenlp-full-2018-10-05.zip ]; then
unzip -n stanford-corenlp-full-2018-10-05.zip
rm stanford-corenlp-full-2018-10-05.zip
fi

python init.py
22 changes: 0 additions & 22 deletions template.txt

This file was deleted.

0 comments on commit eafbd37

Please sign in to comment.