Skip to content
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

Exporting issue #29394

Open
2 of 3 tasks
chengkaijie0 opened this issue Jun 28, 2024 · 2 comments
Open
2 of 3 tasks

Exporting issue #29394

chengkaijie0 opened this issue Jun 28, 2024 · 2 comments
Labels
dashboard:export Related to exporting dashboards

Comments

@chengkaijie0
Copy link

Bug description

I am currently facing an issue in exporting my dashboards from page 3 onwards. Is there a way to go about solving this issue?

How to reproduce the bug

.

Screenshots/recordings

Capture

Superset version

master / latest-dev

Python version

I don't know

Node version

I don't know

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
@dosubot dosubot bot added the dashboard:export Related to exporting dashboards label Jun 28, 2024
Copy link

dosubot bot commented Jun 28, 2024

Hi @chengkaijie0! 👋 I'm a bot here to help you with bugs, questions, and becoming a contributor. Let's tackle this issue together!

To resolve the issue of being unable to export your dashboards from page 3 onwards in a multi-page PDF document, you should investigate the _get_screenshots and _get_pdf methods in the BaseReportState class. These methods are responsible for generating the screenshots and compiling them into a PDF.

Here is the relevant code snippet:

def _get_screenshots(self) -> list[bytes]:
    """
    Get chart or dashboard screenshots
    :raises: ReportScheduleScreenshotFailedError
    """
    url = self._get_url()
    _, username = get_executor(
        executor_types=app.config["ALERT_REPORTS_EXECUTE_AS"],
        model=self._report_schedule,
    )
    user = security_manager.find_user(username)
    if self._report_schedule.chart:
        window_width, window_height = app.config["WEBDRIVER_WINDOW"]["slice"]
        window_size = (
            self._report_schedule.custom_width or window_width,
            self._report_schedule.custom_height or window_height,
        )
        screenshot: Union[ChartScreenshot, DashboardScreenshot] = ChartScreenshot(
            url,
            self._report_schedule.chart.digest,
            window_size=window_size,
            thumb_size=app.config["WEBDRIVER_WINDOW"]["slice"],
        )
    else:
        window_width, window_height = app.config["WEBDRIVER_WINDOW"]["dashboard"]
        window_size = (
            self._report_schedule.custom_width or window_width,
            self._report_schedule.custom_height or window_height,
        )
        screenshot = DashboardScreenshot(
            url,
            self._report_schedule.dashboard.digest,
            window_size=window_size,
            thumb_size=app.config["WEBDRIVER_WINDOW"]["dashboard"],
        )
    try:
        image = screenshot.get_screenshot(user=user)
    except SoftTimeLimitExceeded as ex:
        logger.warning("A timeout occurred while taking a screenshot.")
        raise ReportScheduleScreenshotTimeout() from ex
    except Exception as ex:
        raise ReportScheduleScreenshotFailedError(
            f"Failed taking a screenshot {str(ex)}"
        ) from ex
    if not image:
        raise ReportScheduleScreenshotFailedError()
    return [image]

def _get_pdf(self) -> bytes:
    """
    Get chart or dashboard pdf
    :raises: ReportSchedulePdfFailedError
    """
    screenshots = self._get_screenshots()
    pdf = build_pdf_from_screenshots(screenshots)

    return pdf

The _get_screenshots method captures screenshots of the charts or dashboards, and the _get_pdf method compiles these screenshots into a PDF. If the issue is occurring from page 3 onwards, it might be due to a timeout or an error in capturing the screenshots.

To debug this issue, you can:

  1. Check for Timeouts: Ensure that the screenshot capturing process is not timing out. The SoftTimeLimitExceeded exception indicates a timeout.
  2. Error Handling: Look for any exceptions being raised in the _get_screenshots method. The ReportScheduleScreenshotFailedError exception indicates a failure in taking a screenshot.
  3. Logging: Add additional logging to capture more details about the failure. This can help identify if the issue is with specific pages or charts.
  4. Configuration: Verify the configuration settings for WEBDRIVER_WINDOW to ensure that the window size is appropriate for capturing the entire dashboard.

By addressing these points, you should be able to identify and resolve the issue with exporting your dashboards in a multi-page PDF document [1].

To continue talking to Dosu, mention @dosu.

@rusackas
Copy link
Member

Possibly related to (or even a duplicate of?) #29324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dashboard:export Related to exporting dashboards
Projects
None yet
Development

No branches or pull requests

2 participants