-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
feat: Implement using Playwright for taking screenshots in reports #25247
Conversation
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.
Exciting stuff. First pass, comments mainly related to whether or not we should add the deps as required vs optional. I also have some unrelated grievances with how the current Allerts & Reports feature handles errors, but let's chat about those separately (=this is a good opportunity to think about improving this as we're refactoring the code that detects whether or not the page has rendered).
requirements/base.txt
Outdated
playwright==1.37.0 | ||
# via apache-superset |
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 think this should probably go into the dev, integration or test deps
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.
Could you explain why? Isn't reports one of the basic flows? Or maybe I misunderstand the purpose of those files
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.
The fact that it's marked as an optional dependency in setup.py
IMO means it should not be in base.txt
. Was this entry added by hand, or via pip-compile-multi
? I assume we'd need to change requirements/base.in
as follows to autogenerate this:
-e file:.[playwright]
setup.py
Outdated
@@ -108,6 +108,7 @@ def get_git_sha() -> str: | |||
"pandas[performance]>=2.0.3, <2.1", | |||
"parsedatetime", | |||
"pgsanity", | |||
"playwright", |
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.
Should we move this into an optional dep until selenium is deprecated?
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.
Where are the optional deps located?
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.
That's a good idea. @kgabryje in extras_require
below.
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.
Thanks, moved
docker/docker-bootstrap.sh
Outdated
@@ -31,6 +31,8 @@ fi | |||
if [ -f "${REQUIREMENTS_LOCAL}" ]; then | |||
echo "Installing local overrides at ${REQUIREMENTS_LOCAL}" | |||
pip install --no-cache-dir -r "${REQUIREMENTS_LOCAL}" | |||
playwright install-deps | |||
playwright install chromium |
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.
What's the correlation between the local overwrite config and installing playwright?
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.
There isn't, it's a leftover from my tests in POC phase 🤦 updated
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.
@eschutho Actually, now that we moved playwright to optional packages, I think we should make installing additional deps conditional. Do we have an established pattern for that?
superset/utils/machine_auth.py
Outdated
@@ -23,6 +23,7 @@ | |||
|
|||
from flask import current_app, Flask, request, Response, session | |||
from flask_login import login_user | |||
from playwright.sync_api import BrowserContext |
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.
you can move this import down to the authenticate_playwright_browser_context method if you get errors on it not loading when the feature flag is not on.
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 put the import behind a feature flag check - I couldn't move it to the method as it was used for typing that method
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.
Scratch that, importing feature_flag_manager causes a circular import
superset/utils/machine_auth.py
Outdated
elif request.cookies: | ||
cookies = request.cookies | ||
else: | ||
cookies = {} |
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.
should we try to dry this up from the other authenticate method?
/testenv up FEATURE_PLAYWRIGHT_REPORTS_AND_THUMBNAILS=true |
@kgabryje Ephemeral environment spinning up at http://18.236.98.170:8080. Credentials are |
beb24bf
to
bd9b693
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.
I think this is good to go after we decide on how to handle this new dependency.
requirements/base.txt
Outdated
playwright==1.37.0 | ||
# via apache-superset |
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.
The fact that it's marked as an optional dependency in setup.py
IMO means it should not be in base.txt
. Was this entry added by hand, or via pip-compile-multi
? I assume we'd need to change requirements/base.in
as follows to autogenerate this:
-e file:.[playwright]
bd9b693
to
d99cd13
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.
I think we should be consistent in either having separate func overrides in the constructor if the authenticate methods are separate, or merge them so as to only support one screenshot mechanism.
2ca0b98
to
c0dcb2e
Compare
c0dcb2e
to
e5e18dd
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.
LGTM, thanks for all the hard work here! ❤️
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 great @kgabryje!
Ephemeral environment shutdown and build artifacts deleted. |
@kgabryje I left a comment on a part that may break existing functionality. I'd suggest let's see if we can quickly fix forward. |
…ports (apache#25247)" This reverts commit ff95d0f.
…ports (apache#25247)" This reverts commit ff95d0f.
SUMMARY
Implements SIP-98.
If a feature flag
PLAYWRIGHT_REPORTS_AND_THUMBNAILS
is on, use Playwright instead of Selenium to take screenshots of dashboards and charts when preparing reports and thumbnails.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
The change should be visible when running a report on a dashboard that contains deck.gl charts.
Before:
After:
TESTING INSTRUCTIONS
PLAYWRIGHT_REPORTS_AND_THUMBNAILS
ffADDITIONAL INFORMATION
PLAYWRIGHT_REPORTS_AND_THUMBNAILS