1.0.1 • Published 5 years ago
distribution-amp v1.0.1
Distribution App
Sequence API input schema defined and usable by Distribution Consumer.
In order to work on this, you need to follow these steps:
Install system dependencies:
sudo apt-get install libffi-dev libssl0.9.8
Clone the repo in the expected location:
cd ~/code/
git clone git@github.com:natgeo/project-distribution.git
Create a virtual env:
cd ~/code/project-distribution/
mkvirtualenv distribution
echo 'cd ~/code/project-distribution' >> $WORKON_HOME/distribution/bin/postactivate
echo 'export APP_CONFIG=distribution.settings' >> $WORKON_HOME/distribution/bin/postactivate
echo 'export FLASK_APP=$HOME/code/project-distribution/distribution/__init__.py' >> $WORKON_HOME/distribution/bin/postactivate
echo 'unset FLASK_APP' >> $WORKON_HOME/distribution/bin/postdeactivate
echo 'unset APP_CONFIG' >> $WORKON_HOME/distribution/bin/postdeactivate
workon distribution
add2virtualenv .
Install the requirements:
$ pip install -r requirements.txt
Install AMP requirements
- Install nvm:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
- Create folder amp_result on
$PROJECT_FOLDER/distribution/amp_result/
- Run npm login:
npm login
user: ****
pass: ****
email: ****
Request credentials to the WebTools Team
- Inside distribution folder:
nvm install npm install
- set the following env vars in your
~/.bashrc
export NVM_DIR="/home/webapp/.nvm" export PATH=$PATH:$NVM_DIR/versions/node/v6.9.0/bin [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
- Create amp apiauth user:Request user and password to the Services Team
- Configure AMP into your local.py (local env only)
echo "AMP_CACHE_ENABLED = True\nAMP_ITEM_ENDPOINT = 'http://distribution-dev.nationalgeographic.com:5000/api/v1/item/{}" > distribution/settings/local.py
- Add this line to your /etc/hosts file (local env only)
127.0.0.1 distribution-dev.nationalgeographic.com
Set settings symbolic links:
ln -sf development.py distribution/settings/environment_overrides/active.py
Run Elastic
This is going to depend on your environment. By default, Distribution is going to connect to Elastic at localhost:9200
.
Run tests to validate everything:
workon distribution
tox
nosetests test
Run app:
python distribution