Clarify Local Hosting Documentation#44
Clarify Local Hosting Documentation#44wtokumaru wants to merge 15 commits intochronoscio:masterfrom wtokumaru:clarify
Conversation
|
Does this repo not have an option to request reviews and assign relevant developers? It also would not let me select any labels before submitting. I suspect it is a permissions thing since I still can not add any after submitting. |
.autopep8.py
Outdated
| @@ -1,4 +1,5 @@ | |||
| #!/usr/bin/env python3 | |||
| # TODO: Explain usage here? Why do we need both pylint and pep8? | |||
There was a problem hiding this comment.
PEP8 is a Python formatting guideline. Autopep8 is a tool to automatically format python code according to the PEP8 standards. Pylint is a tool to lint python code.
There was a problem hiding this comment.
Okay, pep8 for format, separately from linting.
.autopep8.py
Outdated
| @@ -1,4 +1,5 @@ | |||
| #!/usr/bin/env python3 | |||
| # TODO: Explain usage here? Why do we need both pylint and pep8? | |||
There was a problem hiding this comment.
I assume that this all happens through CI but is it also possible to run these directly?
There was a problem hiding this comment.
Yes, they can be executed normally. VSCode is supposed to call them on save as well but it's not entirely working, see #32
django.env.sample
Outdated
| AUTH0_CLIENT_SECRET={SECRET} | ||
| API_IDENTIFIER={IDENTIFIER} | ||
| AUTH0_DOMAIN=chronoscio.auth0.com | ||
| API_IDENTIFIER=https://chronoscio.org/api/ |
There was a problem hiding this comment.
Included defaults here as well because we can.
project/interactivemap/settings.py
Outdated
| 'interactivemap-frontend-*.now.sh', | ||
| ) | ||
|
|
||
| AUTH0_DOMAIN = os.environ.get('AUTH0_DOMAIN', 'chronoscio.auth0.com') |
There was a problem hiding this comment.
Removed this default because it does not seem to work when combined with empty strings.
There was a problem hiding this comment.
I don't know what you mean
There was a problem hiding this comment.
Traceback (most recent call last):
File "project/manage.py", line 29, in <module>
execute_from_command_line(sys.argv)
File "/home/tokumaru/.local/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/home/tokumaru/.local/lib/python3.5/site-packages/django/core/management/__init__.py", line 317, in execute
settings.INSTALLED_APPS
File "/home/tokumaru/.local/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/home/tokumaru/.local/lib/python3.5/site-packages/django/conf/__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "/home/tokumaru/.local/lib/python3.5/site-packages/django/conf/__init__.py", line 106, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/tokumaru/chronoscio/backend/project/interactivemap/settings.py", line 174, in <module>
jwks = json.loads(jsonurl.read())
File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
I traced it back to precisely this one-line change and checked several times why flipping back and forth between line options. It happens if AUTH0_DOMAIN is 'chronoscio.auth0.com' while the other two are empty strings or None. However, if all 3 are None, it works fine. Might only be a problem when hosting locally.
There was a problem hiding this comment.
What are the exact values of your environment variables?
There was a problem hiding this comment.
The edge case I am describing is when you have none of the django.env sourced. When that happens it can still work with the defaults specified in settings.py except for this. When all the env vars are set, there is no need for defaults. The problem I observed is that the url is not compatible with empty strings or Nones, but if all three are None then they are compatible.
project/interactivemap/settings.py
Outdated
| AUTH0_CLIENT_ID = os.environ.get('AUTH0_CLIENT_ID', '') | ||
| AUTH0_CLIENT_SECRET = os.environ.get('AUTH0_CLIENT_SECRET', '') | ||
| AUTH0_CLIENT_ID = os.environ.get('AUTH0_CLIENT_ID') | ||
| AUTH0_CLIENT_SECRET = os.environ.get('AUTH0_CLIENT_SECRET') |
There was a problem hiding this comment.
All three being None though seems to work.
.pylint.py
Outdated
| @@ -1,4 +1,5 @@ | |||
| #!/usr/bin/env python3 | |||
| # TODO: Explain usage here? Why do we need both pylint and pep8? | |||
|
The Travis build failed in the same way that this fails when I try to use Docker, suggesting the problem is in the code rather than with my computer. I assume that master usually passes, so which change here makes a difference? |
quorth0n
left a comment
There was a problem hiding this comment.
CONTRIBUTING.md must be placed in root, it's a GitHub specific thing. Maybe we could make a symlink or something.
README.md
Outdated
| AUTH0_CLIENT_ID={Client ID} | ||
| AUTH0_CLIENT_SECRET={Client Secret} | ||
| ``` | ||
| 4) Install and run [Postgresql](https://www.postgresql.org/docs/9.3/static/tutorial-install.html) (AKA postgres) locally. You should not need to worry about creating any accounts or doing any setup but you may need to debug OS-specific problems that appear. For example, you may need to install postgis as well. (TODO: Test this on wiped setups to find out specific steps to do this properly.) |
There was a problem hiding this comment.
I think this is a little more verbose then necessary. A link should probably be provided to the geodjango setup information. Account handling is up to the user and OS-specific problems are a given so I don't think this sentence is necessary.
There was a problem hiding this comment.
What is the geodjango setup needed for?What link in particular? I do not remember doing it but may have forgotten.
README.md
Outdated
| AUTH0_CLIENT_SECRET={Client Secret} | ||
| ``` | ||
| 4) Install and run [Postgresql](https://www.postgresql.org/docs/9.3/static/tutorial-install.html) (AKA postgres) locally. You should not need to worry about creating any accounts or doing any setup but you may need to debug OS-specific problems that appear. For example, you may need to install postgis as well. (TODO: Test this on wiped setups to find out specific steps to do this properly.) | ||
| 5) Change the HOST variable in the [settings.py](https://github.com/chronoscio/backend/blob/master/project/interactivemap/settings.py) file to be `localhost` instead of `db`. You may also need to change the PORT variable to match whatever you have set for postgis (TODO: investigate this). |
There was a problem hiding this comment.
That would make sense but the weird thing here is that the final line I had to run to get everything working for me was actually postgis. O_o
See: https://stackoverflow.com/questions/41666196/how-to-change-install-postgis-location-postgres
The answer here sudo apt-get install postgresql-9.6-postgis-scripts did not work for me but the comment on the answer that did more brute force sudo apt install postgis did work. However, you can see from the next comment that this is not the best way to solve the problem and is kind of overkill so I did not want to include it in the docs.
There was a problem hiding this comment.
For geodjango you shouldn't need to install anything past postgresql-x.x, postgresql-x.x-postgis, postgresql-server-dev-x.x, python-psycopg2 according to the documentation.
README.md
Outdated
| ``` | ||
| 7) Migrate and run the server with django. | ||
| ```bash | ||
| # Migrate the project. |
README.md
Outdated
|
|
||
| project/api: REST API and a test file (how/why do we run the test)? Defines the Nation, Territory, and DiplomaticRelation classes, which are our primary database items. | ||
|
|
||
| project/interactivemap: Django settings and website directory layout? |
There was a problem hiding this comment.
I don't think documentation here is necessary past the project/ folder as it is standard django architecture.
There was a problem hiding this comment.
What exactly is standard vs. custom? Which files exactly? If we have a standard directory with a custom subdirectory in it I would like to make it clear what is going on.
README.md
Outdated
|
|
||
| project/interactivemap: Django settings and website directory layout? | ||
|
|
||
| project: Django execution wrapper. |
There was a problem hiding this comment.
Django application directory*
| 2. Create Application > All Scopes > Authorize | ||
| 3. See the `client_id`, `client_secret`, and `audience` variables in the example cURL | ||
| 1. Log into https://manage.auth0.com/#/applications. It does not matter what names you select. | ||
| 2. Create Application > All Scopes > Authorize. Or just create a SPA (Single Page Application). |
There was a problem hiding this comment.
I'm going to have to look into this for the proper procedure. See #39.
There was a problem hiding this comment.
Good to know. I had not gotten around to reading that issue yet.
project/interactivemap/settings.py
Outdated
| 'interactivemap-frontend-*.now.sh', | ||
| ) | ||
|
|
||
| AUTH0_DOMAIN = os.environ.get('AUTH0_DOMAIN', 'chronoscio.auth0.com') |
There was a problem hiding this comment.
I don't know what you mean
project/interactivemap/settings.py
Outdated
| AUTH0_CLIENT_ID = os.environ.get('AUTH0_CLIENT_ID', '') | ||
| AUTH0_CLIENT_SECRET = os.environ.get('AUTH0_CLIENT_SECRET', '') | ||
| AUTH0_CLIENT_ID = os.environ.get('AUTH0_CLIENT_ID') | ||
| AUTH0_CLIENT_SECRET = os.environ.get('AUTH0_CLIENT_SECRET') |
It's a permission thing. |
Weird, I never saw this as a problem in other projects. How do you know this? Is it just to make a pop-up when submitting a PR? |
|
Never mind actually, I just checked GitHub's docs, they say it can be placed in the |
README.md
Outdated
| AUTH0_CLIENT_ID={Client ID} | ||
| AUTH0_CLIENT_SECRET={Client Secret} | ||
| ``` | ||
| 4) Install and run [Postgresql](https://www.postgresql.org/docs/9.3/static/tutorial-install.html) (AKA postgres) locally. You should not need to worry about creating any accounts. You will also need to make sure you have set up [geodjango](https://docs.djangoproject.com/en/2.1/ref/contrib/gis/install/). (TODO: Test this on wiped setups to find out specific steps to do this properly.) |
There was a problem hiding this comment.
This documentation link should refer to .../en/stable/contrib/... so that it's not version specific.
django.env.sample
Outdated
| API_IDENTIFIER={IDENTIFIER} | ||
| AUTH0_DOMAIN={PROJECT.auth0.com} | ||
| AUTH0_CLIENT_ID={Client ID} | ||
| AUTH0_CLIENT_SECRET={Client Secret} |
There was a problem hiding this comment.
Why was API identifier removed? Also, the sed regex in .travis.yml looks for specific values for these fields which it replaces with our secrets so that will have to be updated as well.
There was a problem hiding this comment.
I just separated it elsewhere in the file to look nicer. Will look into updating .travis.yml.
There was a problem hiding this comment.
Going to swap it back to {IDENTIFIER} I suppose for Travis to be the same, though it should not be necessary to include there? Why are some of these set with defaults in the sample env but others set with defaults in settings.py and/or .travis/yml? It seems kind of arbitrary. It feels more natural to be to just have one set of defaults and maaaaybe a second set of test-specific defaults but not 3 separate ones.
There was a problem hiding this comment.
Oh sorry, didn't catch that. It's an Auth0-specific thing so I think it'd be better placed in the Auth0 group. I agree about the defaults actually, let's just keep them all here for simplicity's sake. The only test specific defaults are so that all third party libs can use our access tokens and such which is why they aren't publicly displayed.
|
@wtokumaru About the permissions thing, I added you to the repo some time ago, have a look at https://github.com/chronoscio to accept it |
|
Should I be able to assign, request reviews, and add tags now? I still do not appear to be able to do nay despite the member identification. |
This was probably due to me not updating the /travis.yml so I am looking into that. |
|
Weird, the CI just went from working to not, without adding any commits, anyone have an idea why? Does it just have that much lag? |
|
My guess would be that it went from "in progress" to failing. Regardless the reason is because of the changes to this line: Line 6 in 1544696
Line 15 in 1544696 I think that as we established it has to be the frontend application's client ID (see my recent posts in #39) we should keep it as |
README.md
Outdated
| # ChronoScio Backend [](https://travis-ci.org/interactivemap/backend) [](https://www.codacy.com/app/whirish/backend?utm_source=github.com&utm_medium=referral&utm_content=interactivemap/backend&utm_campaign=Badge_Grade) | ||
|
|
||
| ## Getting Started | ||
| We normally use [Docker](https://en.wikipedia.org/wiki/Docker_(software)) to simplify installation and configuration. Docker makes virtual "containers" as images which allow us to isolate code we run and work around computer-specific weirdnesses. Docker should work on [Linux](https://docs.docker.com/install/linux/docker-ce/ubuntu/) or [macOS](https://docs.docker.com/docker-for-mac/install/) but requires Hyper-V, which is not available on Windows 10 Home edition. If you have trouble with setting up Docker, see the **Local Development** instructions below instead. Otherwise, it should be simple to get started: |
There was a problem hiding this comment.
Mention that it does works on Windows 10 Pro 64 bit.
README.md
Outdated
| # Navigate to http://localhost/, if you get a 502 error postgres likely has not been initialized yet, | ||
| # try again in a few seconds | ||
| ``` | ||
| Use `docker-compose down` to stop hosting when you are done. |
There was a problem hiding this comment.
or just make stop or make clean (rebase this pr off latest master)
…essarily an sh file.
|
Could you try adding a |
|
@whirish Are you sure about that? Our travis builds are public, anyone can then see our Auth0 credentials |
|
@amaurymartiny Doesn't Travis filter out secrets when they're printed? I was thinking worst case we could just delete the build log |
Took the liberty to modify the documentation to be more clear (to me at least). I think that we want to err on the side of excessive hand-holding and completeness to minimize inadvertent configuration hazing.
Also added several small comments and linting changes in other files which I can remove if they are too intrusive. I intend to remove and isolate to separate PRs anything particularly controversial.