-
Notifications
You must be signed in to change notification settings - Fork 336
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
[Django Upgrade] [ENG-3947] Fix django debug toolbar and profiling tools for Django 3 #9987
Conversation
1c255aa
to
a98cff1
Compare
65b0360
to
250b832
Compare
4e84337
to
7c845bb
Compare
8907783
to
0f33c1f
Compare
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.
As discussed in flow, people may still use these tools. Let's keep it as for "pre-upgrade" fixes. We can remove these after the upgrade if it take too much effort to fix.
868882d
to
b15db2e
Compare
tasks/__init__.py
Outdated
echo=True | ||
) | ||
install_from_txt(ctx, os.path.join(HERE, 'requirements', 'dev.txt')) | ||
elif base: # then base requirements |
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.
I changed this to an elif
because these .txt
all contain a -r ../requirements.txt
so they incorporate those reqs anyway.
b15db2e
to
aff3e8a
Compare
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.
Looks good as discussed. I will make a few updates and push back before merge. See comments for details.
@@ -126,6 +126,7 @@ api/static/vendor | |||
# Local settings files | |||
local.py | |||
local.json | |||
requirements/debug.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.
I would just have debug.txt instead of having a -dist
version, which I will update and push back.
@@ -0,0 +1,17 @@ | |||
-r ../requirements.txt | |||
|
|||
# Requirements that are used locally only for a good developer experience |
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.
Just to mention the difference, missing two removed packages. I am OK removing django-sslserver
but why removing django-silk
? I will add it back in my update.
django-sslserver==0.19
django-silk==2.0.0
@@ -19,7 +19,7 @@ | |||
|
|||
|
|||
try: | |||
from tasks import local # noqa | |||
from tasks import local as local_dist # noqa |
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.
👍 I see. We import here just to check file existence without using it. That's why I am not seeing any usage diff.
def install_from_txt(ctx, req_path): | ||
ctx.run( | ||
pip_install(req_path), | ||
echo=True | ||
) |
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.
👍 for reducing dup code, I will add docstr
if debug: # then local debugging tools | ||
install_from_txt(ctx, os.path.join(HERE, 'requirements', 'debug.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.
Wondering about the orders of dev
, base
and debug
. debug
is another level after dev
thus needs dev
. I think updating the -r
option in debug.txt
to point dev.txt
will solve this.
admin/base/settings/defaults.py
Outdated
|
||
if DEBUG: | ||
INSTALLED_APPS += ('debug_toolbar', 'nplusone.ext.django',) | ||
MIDDLEWARE += ('debug_toolbar.middleware.DebugToolbarMiddleware', 'nplusone.ext.django.NPlusOneMiddleware',) | ||
DEBUG_TOOLBAR_CONFIG = { | ||
'SHOW_TOOLBAR_CALLBACK': lambda _: True, | ||
'DISABLE_PANELS': { | ||
'debug_toolbar.panels.templates.TemplatesPanel', | ||
'debug_toolbar.panels.redirects.RedirectsPanel' | ||
} | ||
} | ||
|
||
# If set to True, automated tests with extra queries will fail. | ||
NPLUSONE_RAISE = False |
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.
I believe our plan is to keep these.
admin/base/urls.py
Outdated
if DEBUG: | ||
import debug_toolbar | ||
|
||
urlpatterns += [ | ||
url(r'^__debug__/', include(debug_toolbar.urls)), | ||
] | ||
|
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.
Ditto
api/base/settings/defaults.py
Outdated
# If set to True, automated tests with extra queries will fail. | ||
NPLUSONE_RAISE = False | ||
|
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.
Ditto
api/base/settings/local-dist.py
Outdated
if DEBUG: | ||
INSTALLED_APPS += ('debug_toolbar', 'nplusone.ext.django',) | ||
MIDDLEWARE += ( | ||
'debug_toolbar.middleware.DebugToolbarMiddleware', | ||
'nplusone.ext.django.NPlusOneMiddleware', | ||
) | ||
DEBUG_TOOLBAR_CONFIG = { | ||
'SHOW_TOOLBAR_CALLBACK': lambda _: True, | ||
} | ||
ALLOWED_HOSTS.append('localhost') | ||
|
||
# django-silk | ||
INSTALLED_APPS += ('silk',) | ||
MIDDLEWARE += ( | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'silk.middleware.SilkyMiddleware', | ||
) | ||
|
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.
Ditto
api/base/urls.py
Outdated
# Add django-silk URLs if it's in INSTALLED_APPS | ||
if 'silk' in settings.INSTALLED_APPS: | ||
urlpatterns += [ | ||
url(r'^silk/', include('silk.urls', namespace='silk')), | ||
] | ||
|
||
if settings.DEBUG: | ||
import debug_toolbar | ||
|
||
urlpatterns += [ | ||
url(r'^__debug__/', include(debug_toolbar.urls)), | ||
] | ||
|
||
|
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.
Ditto
415be8a
to
a222153
Compare
@Johnetordoff the test failure tells us either that our GitHub Action tests have Update: confirmed |
e17a48d
to
b0c3e27
Compare
A minor concern that I forgot to mention, though I doubt it is actually an issue: |
PR closed since #10049 fixes the issue with a few troubling dev/local requirements. |
Purpose
The DJDTB is breaking when updating to Django 3 and though the bugs aren't particularly hard to fix this PR removes the DJDTB and other local profiling tools which could produce other issues in the future.
https://www.notion.so/cos/8-Django-Debug-toolbar-namespace-problem-0142b5d4dced4bbd9ce8d311d6935e6a
Changes
local.txt
dev.txt
QA Notes
Please make verification statements inspired by your code and what your code touches.
What are the areas of risk?
Any concerns/considerations/questions that development raised?
Documentation
Side Effects
Ticket