You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "betodealmeida (via GitHub)" <gi...@apache.org> on 2025/01/30 21:59:34 UTC
[PR] fix: enforce `ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH` [superset]
betodealmeida opened a new pull request, #32053:
URL: https://github.com/apache/superset/pull/32053
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
We only enforce `ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH` when an alert/report is created. This means that if the feature flag is later changed to a smaller value it might not have any effect on pre-existing alerts/reports.
This PR adds a check during screenshot generation.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: enforce `ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH` [superset]
Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida commented on code in PR #32053:
URL: https://github.com/apache/superset/pull/32053#discussion_r1937899127
##########
superset/commands/report/execute.py:
##########
@@ -300,13 +300,16 @@ def _get_screenshots(self) -> list[bytes]:
)
user = security_manager.find_user(username)
+ max_width = app.config["ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH"]
Review Comment:
Oh, it's not a feature, just a configuration value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: enforce `ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH` [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #32053:
URL: https://github.com/apache/superset/pull/32053#discussion_r1937745614
##########
superset/commands/report/execute.py:
##########
@@ -300,13 +300,16 @@ def _get_screenshots(self) -> list[bytes]:
)
user = security_manager.find_user(username)
+ max_width = app.config["ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH"]
Review Comment:
@betodealmeida Maybe we should deprecate the `ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH` feature flag to remove it in a major version. It seems that this feature should always be enabled in case alerts and reports are too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: enforce `ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH` [superset]
Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on PR #32053:
URL: https://github.com/apache/superset/pull/32053#issuecomment-2625685424
Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment `/korbit-review`.
> Your admin can change your review schedule in the [Korbit Console](https://app.korbit.ai/settings)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: enforce `ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH` [superset]
Posted by "betodealmeida (via GitHub)" <gi...@apache.org>.
betodealmeida merged PR #32053:
URL: https://github.com/apache/superset/pull/32053
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix: enforce `ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH` [superset]
Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #32053:
URL: https://github.com/apache/superset/pull/32053#discussion_r1937746307
##########
tests/unit_tests/commands/report/execute_test.py:
##########
@@ -365,3 +370,113 @@ def test_get_tab_url(
)
result: str = class_instance._get_tab_url(dashboard_state)
assert result == "http://0.0.0.0:8080/superset/dashboard/p/uri/"
+
+
+def create_report_schedule(
+ mocker: MockerFixture,
+ custom_width: int | None = None,
+ custom_height: int | None = None,
+) -> ReportSchedule:
+ """Helper function to create a ReportSchedule instance with specified dimensions."""
+ schedule = ReportSchedule()
+ schedule.type = ReportScheduleType.REPORT
+ schedule.name = "Test Report"
+ schedule.description = "Test Description"
+ schedule.chart = mocker.MagicMock()
+ schedule.chart.id = 1
+ schedule.dashboard = None
+ schedule.database = None
+ schedule.custom_width = custom_width
+ schedule.custom_height = custom_height
+ return schedule
+
+
+@pytest.mark.parametrize(
+ "test_id,custom_width,max_width,window_width,expected_width",
+ [
+ # Test when custom width exceeds max width
+ ("exceeds_max", 2000, 1600, 800, 1600),
+ # Test when custom width is less than max width
+ ("under_max", 1200, 1600, 800, 1200),
+ # Test when custom width is None (should use window width)
+ ("no_custom", None, 1600, 800, 800),
+ # Test when custom width equals max width
+ ("equals_max", 1600, 1600, 800, 1600),
+ ],
+)
+def test_screenshot_width_calculation(
Review Comment:
Nice!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org