Skip to content

Conversation

Neko1313
Copy link
Contributor

@Neko1313 Neko1313 commented Jul 8, 2025

SUMMARY

Added support for configurable PDF compression levels in Superset. The changes include:

  • New configuration variable PDF_COMPRESSION_LEVEL in config.py with four compression levels: "NONE", "FAST", "MEDIUM", "SLOW" (defaults to "MEDIUM")
  • Passing this parameter through bootstrap data to the frontend
  • Using the compression parameter in the downloadAsPdf function to improve performance and file size optimization
  • Updated TypeScript BootstrapData interface to support the new field

This allows administrators to configure the balance between PDF generation speed and file size based on system requirements and user needs.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

No visual changes - this is an internal performance optimization for PDF generation.

TESTING INSTRUCTIONS

  1. Run Superset with different PDF_COMPRESSION_LEVEL values in config.py
  2. Try exporting dashboards or charts to PDF
  3. Verify that PDFs are generated correctly
  4. Compare file sizes and generation speed with different compression levels:
    • PDF_COMPRESSION_LEVEL = "NONE" - fastest generation, largest file size
    • PDF_COMPRESSION_LEVEL = "FAST" - fast generation, medium file size
    • PDF_COMPRESSION_LEVEL = "MEDIUM" - moderate speed, good compression
    • PDF_COMPRESSION_LEVEL = "SLOW" - slower generation, best compression
  5. Ensure bootstrap data contains the correct pdf_compression_level value
  6. Test that the compression parameter is properly passed to the PDF generation library

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

Additional Notes:

  • Changes are backward compatible - if the variable is not set, the default value is used
  • No database migration required for this feature
  • TypeScript typing updated to support the new field
  • Configuration follows existing Superset patterns for PDF-related settings

Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Performance Default PDF compression too aggressive ▹ view ✅ Fix detected
Files scanned
File Path Reviewed
superset-frontend/src/utils/downloadAsPdf.ts
superset-frontend/src/types/bootstrapTypes.ts
superset/views/base.py
superset/config.py

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

Copy link

codecov bot commented Jul 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.91%. Comparing base (76d897e) to head (ca90cbf).
⚠️ Report is 2586 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #34096       +/-   ##
===========================================
+ Coverage   60.48%   71.91%   +11.42%     
===========================================
  Files        1931      587     -1344     
  Lines       76236    43467    -32769     
  Branches     8568     4699     -3869     
===========================================
- Hits        46114    31260    -14854     
+ Misses      28017    10979    -17038     
+ Partials     2105     1228      -877     
Flag Coverage Δ
hive 46.29% <100.00%> (-2.86%) ⬇️
javascript ?
mysql 70.94% <100.00%> (?)
postgres 70.99% <100.00%> (?)
presto 49.98% <100.00%> (-3.82%) ⬇️
python 71.88% <100.00%> (+8.37%) ⬆️
sqlite 70.58% <100.00%> (?)
unit 100.00% <ø> (+42.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas
Copy link
Member

rusackas commented Jul 9, 2025

re-running CI 🤞

@Quatters
Copy link
Contributor

Quatters commented Jul 9, 2025

Great feature, thank you!

@sadpandajoe sadpandajoe requested a review from rusackas July 9, 2025 17:17
@Neko1313
Copy link
Contributor Author

@rusackas Will you make a confirmation please?

@rusackas
Copy link
Member

re-running CI. Ping me again (here or on Superset Slack) if it passes

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but adding @sadpandajoe / @eschutho in case they have concerns for.... certain hosted SaaS services built around Superset ;)

@rusackas rusackas merged commit 77a5969 into apache:master Sep 25, 2025
77 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants