Skip to content

Add --no-web to flamegraph reporters #790

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

Merged
merged 3 commits into from
Aug 16, 2025
Merged

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jul 7, 2025

Closes: #470

@Delengowski
Copy link

Thank you taking this on Pablo. I was just revisiting it to tackle while on vacation from work, and was looking at how other projects like Plotly Dash do this.

So the plan is to just vendor all the JavaScript script but conditionally use it. I thought the project may have wanted to just make a separate wheel build option to vendor if specified. This seems easier.

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.11%. Comparing base (fcd5362) to head (afed960).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #790      +/-   ##
==========================================
+ Coverage   92.05%   92.11%   +0.06%     
==========================================
  Files          95       95              
  Lines       11946    11953       +7     
  Branches      411      412       +1     
==========================================
+ Hits        10997    11011      +14     
+ Misses        949      942       -7     
Flag Coverage Δ
cpp 92.11% <100.00%> (+0.06%) ⬆️
python_and_cython 92.11% <100.00%> (+0.06%) ⬆️

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.

Copy link
Contributor

@godlygeek godlygeek left a comment

Choose a reason for hiding this comment

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

I've pushed two small fixups, but otherwise this LGTM.

This is much, much simpler than I was afraid this feature would be!

This commit introduces the infrastructure needed to bundle external CDN
dependencies as local assets for offline use. The package.json now
includes all necessary vendor dependencies including Bootstrap, jQuery,
D3, DataTables, and Plotly.js. The webpack configuration has been
updated with CopyWebpackPlugin to automatically copy minified assets
from node_modules to a local vendor directory during the build process.

The Makefile has been enhanced with new targets: build-vendor creates
the vendor assets, the main build target now includes vendor asset
generation, and the clean target removes the vendor directory. This
build system enables the upcoming --no-web flag functionality that
allows memray to generate HTML reports that work without internet
access.

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
This commit adds all the pre-built vendor assets that were copied from
node_modules during the build process. The vendor directory now contains
minified versions of Bootstrap CSS and JavaScript, jQuery, Popper.js,
Lodash, and Plotly.js for the base functionality. For flamegraph
support, it includes the complete D3 v4 library along with
d3-scale-chromatic, d3-tip, and d3-flame-graph extensions. DataTables
libraries are included for table report functionality.

All assets are production-ready minified versions that match the exact
versions previously loaded from CDNs. The package-lock.json has been
updated to reflect the new dependency tree. These bundled assets will be
used when the --no-web flag is specified, ensuring that memray can
generate fully functional HTML reports on systems without internet
connectivity.

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
This commit implements the --no-web flag that allows memray to generate
HTML reports that work without internet access. The flag has been added
to both the flamegraph and table commands, and the flag value is passed
through the entire rendering pipeline from the command parsers to the
template engine.

The HTML templates have been updated to conditionally include assets
based on the no_web flag. When the flag is not specified, templates
continue to use CDN links for optimal performance and faster loading.
When --no-web is specified, templates instead inline the locally bundled
vendor assets using the include_file template function. This ensures
that generated reports are completely self-contained and functional on
airgapped systems.

The BaseReporter protocol and all reporter implementations have been
updated to accept the no_web parameter, maintaining backward
compatibility while enabling the new offline functionality. This change
addresses the need for memray to work in environments without internet
connectivity, as requested in issue bloomberg#470.

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>

Add news entry

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
@pablogsal pablogsal merged commit 3da2fc5 into bloomberg:main Aug 16, 2025
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--no-web Packaging Option
4 participants