-
Notifications
You must be signed in to change notification settings - Fork 1
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
Updated settings and requirements to fix deployment issues #447
Conversation
a04410a
to
c37d9ef
Compare
odl_video/settings.py
Outdated
with open(f'{BASE_DIR}/.env') as envsettings: | ||
for line in envsettings: | ||
k, v = line.rstrip('\n').lstrip('export ').split('=', maxsplit=1) | ||
os.environ.setdefault(k=v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This throws an error: TypeError: setdefault() got an unexpected keyword argument 'k'
This works: os.environ.setdefault(k, v)
c37d9ef
to
841ea84
Compare
Codecov Report
@@ Coverage Diff @@
## master #447 +/- ##
==========================================
- Coverage 95.27% 95.24% -0.04%
==========================================
Files 136 136
Lines 4633 4643 +10
Branches 191 192 +1
==========================================
+ Hits 4414 4422 +8
- Misses 179 181 +2
Partials 40 40
Continue to review full report at Codecov.
|
@@ -488,7 +497,7 @@ | |||
}, | |||
'redis': { | |||
"BACKEND": "django_redis.cache.RedisCache", | |||
"LOCATION": CELERY_BROKER_URL, | |||
"LOCATION": REDIS_URL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CELERY_BROKER_URL
will default to REDIS_URL
if the env. variable isn't set, so maybe it might be best to not change this line, @noisecapella do you want to weigh in? That seems to be the pattern used in open-discussions & micromasters as well:
CELERY_BROKER_URL = get_string("CELERY_BROKER_URL", REDIS_URL)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like Giovanni added that line in a commit to add mandatory settings, I don't think REDIS_URL
has any special meaning to Celery or django-redis. I think the change here makes sense to keep the celery redis broker separate from the redis cache Django
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbertrand if we leave it as is and the CELERY_BROKER_URL
gets set to something other than a Redis protocol then that would break the cache config. That's why I broke them out to be separate settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sounds good to me then
odl_video/settings.py
Outdated
@@ -21,6 +21,14 @@ | |||
|
|||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |||
|
|||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this into a function and write tests for it?
@@ -488,7 +497,7 @@ | |||
}, | |||
'redis': { | |||
"BACKEND": "django_redis.cache.RedisCache", | |||
"LOCATION": CELERY_BROKER_URL, | |||
"LOCATION": REDIS_URL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like Giovanni added that line in a commit to add mandatory settings, I don't think REDIS_URL
has any special meaning to Celery or django-redis. I think the change here makes sense to keep the celery redis broker separate from the redis cache Django
648d89f
to
f55619d
Compare
odl_video/envs_test.py
Outdated
|
||
|
||
def test_parse_env(): | ||
testpath = 'testenv.txt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use a TemporaryFile
here or put it into a temporary directory? If it's not done with a context manager or something we should also put the os.remove
in a finally
block
odl_video/envs_test.py
Outdated
def test_parse_env(): | ||
testpath = 'testenv.txt' | ||
with open(testpath, 'w') as testfile: | ||
testfile.write('FOO_VAR=bar_var\nFOO_NUM=42') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change one of the lines to include an "export "
, and have one of the values include its own =
sign?
e2c2359
to
1aa25c5
Compare
odl_video/envs.py
Outdated
duplicating across multiple locations and not requiring explicit | ||
sourcing. | ||
|
||
:param env_file: path to a file consisting of key=value pairs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blarghmatey The typical format looks like this, can you change it? Otherwise looks good!
The file parsing available in uWSGI has a hardcoded line limit which was causing problems with managing the certificate strings via the env file. Added a block to read in the env file and set environment variables automatically as part of settings.py to work around that issue. Removed the `-e` flags from the git dependencies so that they get installed to the `dist-packages` directory instead of the home directory of the user that runs the pip command. This was causing issues with being able to import those packages at runtime. Added the `no-binary` flag for psycopg2 due to issues with how the wheel is linked to OpenSSL for Debian 9 (unbit/uwsgi#1569) Added the option to set the celery broker separately from the results backend in order to allow for using RabbitMQ in place of Redis.
1aa25c5
to
3c5b5c0
Compare
What are the relevant tickets?
#138
What's this PR do?
The file parsing available in uWSGI has a hardcoded line limit which was causing problems with managing the certificate strings via the env file. Added a block to read in the env file and set environment variables automatically as part of settings.py to work around that issue.
Removed the
-e
flags from the git dependencies so that they get installed to thedist-packages
directory instead of the home directory of the user that runs the pip command. This was causing issues with being able to import those packages at runtime.Added the option to set the celery broker separately from the results backend in order to allow for using RabbitMQ in place of Redis.
How should this be manually tested?
Ensure that the app will start properly with an env file formatted as
ENV_VAR=value
with noexport
prefix.Where should the reviewer start?
odl_video/settings.py and requirements.txt
What GIF best describes this PR or how it makes you feel?