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

improve deploy scripts and allow for profiling memory performance #105

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pytest = "==5.3.4"
pyre-check = "==0.0.41"
## like the Unix `make` but better
invoke = "==1.4.1"

memory-profiler = "*"

[packages]
# REST API
Expand Down Expand Up @@ -61,6 +61,8 @@ six = "==1.11.0"
idna = "==2.6"
## because google-auth 1.11.2 wants setuptools>=40.3.0
setuptools = ">=40.3.0"
colorama = "*"
termcolor = "*"

[requires]
python_version = "3.6"
24 changes: 23 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
python3 setup_special_files_from_env.py
./download_nlp_stuff.sh
python3 download_nltk_stuff.py
gunicorn flask_api:app --config=gunicorn_config.py
python3 setup_special_files_from_env.py && \
./download_nlp_stuff.sh && \
python3 download_nltk_stuff.py && \
gunicorn flask_api:app --config=gunicorn_config.py
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ catalogue==1.0.0
certifi==2019.11.28
chardet==3.0.4
Click==7.0
colorama==0.4.3
cymem==2.0.3
Flask==1.1.1
Flask-Cors==3.0.8
Expand Down Expand Up @@ -48,6 +49,7 @@ six==1.11.0
spacy==2.2.3
SQLAlchemy==1.3.13
srsly==1.0.1
termcolor==1.1.0
thinc==7.3.1
tqdm==4.43.0
uritemplate==3.0.1
Expand Down
17 changes: 15 additions & 2 deletions setup_special_files_from_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
from os import environ
import json
from utilities import yaml_utils # noqa
from colorama import init
from termcolor import colored

# initialize colorama
init()


# NimbusDatabase stuff
SAMPLE_CONFIG_FILE = "config.json_SAMPLE"
Expand All @@ -22,7 +28,9 @@
GOOGLE_CLOUD_NLP_CREDENTIALS_FILE = "auth.json"
GOOGLE_CLOUD_NLP_CREDENTIALS_KEY = "GOOGLE_CLOUD_NLP_CREDENTIALS"

BAD_CONFIG_MSG = "uh oh, config vars not set, check heroku settings"
BAD_CONFIG_MSG = "uh oh, config vars not set,\n\tmake sure to\n\t" + colored(
"source .export_env_vars", "white", "on_cyan", attrs=["bold"]
)
assert environ.get("DATABASE_HOSTNAME", None) is not None, BAD_CONFIG_MSG
assert environ.get("DATABASE_PASSWORD", None) is not None, BAD_CONFIG_MSG
assert environ.get("DATABASE_USERNAME", None) is not None, BAD_CONFIG_MSG
Expand All @@ -36,7 +44,12 @@
assert environ.get("GOOGLE_CLOUD_NLP_MODEL_NAME", None) is not None, BAD_CONFIG_MSG # noqa
# fmt: on

BAD_CONFIG_MSG_2 = "uh oh, config var is empty string, check docker"
BAD_CONFIG_MSG_2 = "uh oh, config var , check docker"

BAD_CONFIG_MSG_2 = "uh oh, config var is empty string,\n\tcheck docker OR make sure to\n\t" + colored(
"source .export_env_vars", "white", "on_cyan", attrs=["bold"]
)

assert environ.get("DATABASE_HOSTNAME", None) != "", BAD_CONFIG_MSG_2
assert environ.get("DATABASE_PASSWORD", None) != "", BAD_CONFIG_MSG_2
assert environ.get("DATABASE_USERNAME", None) != "", BAD_CONFIG_MSG_2
Expand Down