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

Create plotly.js bundle map programmatically #2336

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

salim-b
Copy link
Contributor

@salim-b salim-b commented Jan 31, 2024

Creates the proper bundleTraceMap list as internal package data object directly from the upstream JS file when plotly.js is updated.

The data is sourced from the file tasks/util/constants.js of the matching plotly.js Git tag via yay::gh_text_file(), which I wrote. The package is not (yet) available on CRAN and thus must be installed via remotes::install_gitlab("rpkg.dev/yay") for the time being. I think this shouldn't be an issue since tools/update_plotlyjs.R is run manually during development and is not intended to be run by users.

This commit adds an updated bundleTraceMap for the currently used plotly.js v2.11.1 to R/sysdata.rda, which now also includes plotly.js' strict bundle, so now plotly::partial_bundle(type = "strict") works as intended.

Creates the proper `bundleTraceMap` list as internal data object directly from the upstream JS file when updating plotly.js.

This commit adds an updated `bundleTraceMap` for the currently used plotly.js v2.11.1 to `R/sysdata.rda`.
@salim-b
Copy link
Contributor Author

salim-b commented Jan 31, 2024

Note that the failing tests are unrelated to this PR, AFAICT.

DESCRIPTION Outdated
@@ -23,7 +23,7 @@ Description: Create interactive web graphics from 'ggplot2' graphs and/or a cust
URL: https://plotly-r.com, https://github.com/plotly/plotly.R, https://plotly.com/r/
BugReports: https://github.com/plotly/plotly.R/issues
Depends:
R (>= 3.2.0),
R (>= 3.5),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this necessary?

Copy link
Contributor Author

@salim-b salim-b Jan 31, 2024

Choose a reason for hiding this comment

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

It's a requirement for R's latest serialization format (v3), cf. this line. We could stay on the v2 format if it's really important to support R < 3.5.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The line you're referring to is a build time, not run time dependency, so the version bump requirement isn't necessary

Copy link
Contributor Author

@salim-b salim-b Sep 3, 2024

Choose a reason for hiding this comment

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

Yeah, but it also becomes a runtime dependency once we ship pkg-internal data in v3 format (which we do with this PR). To cite the relevant doc:

Version 3 became the default from R 3.6.0 and can only be read by R versions 3.5.0 and higher.

Copy link
Collaborator

@cpsievert cpsievert Sep 3, 2024

Choose a reason for hiding this comment

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

Ahh, right, thanks for pointing that out. Could we just keep the current behavior? It doesn't seem worth it to me to break compatibility for relatively small R objects that only get loaded once

Copy link
Contributor Author

@salim-b salim-b Sep 3, 2024

Choose a reason for hiding this comment

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

Keeping the current behaviour is fine with me. But OTOH, R 3.5.0 was released more than 6 years ago, so I don't think we ought to care about supporting even more ancient versions.

I'll have a look at your other comments tomorrow. I'll revert to v2 serialization format then if you still think it's worth it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reverted to the v2 serialization format, see 93ef777.

tools/update_plotlyjs.R Outdated Show resolved Hide resolved
This makes non-base-R dependencies clearly apparent
@salim-b
Copy link
Contributor Author

salim-b commented Jun 6, 2024

@cpsievert Anything else I need to do to get this merged?

DESCRIPTION Outdated Show resolved Hide resolved
tools/update_plotlyjs.R Outdated Show resolved Hide resolved
Comment on lines 76 to 77
stringr::str_extract(pattern = "(?<=var partialBundleTraces = )\\{[^}]+\\}") |>
yaml::read_yaml(text = _)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It'd be nice if this could also handle const as well as throw informative errors if the str_extract() comes up empty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 74a4f4f.

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.

2 participants