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

feat: make to_html deterministic #3487

Merged
merged 5 commits into from
Dec 20, 2021

Conversation

Skn0tt
Copy link
Contributor

@Skn0tt Skn0tt commented Nov 24, 2021

Closes #3449

This PR makes to_html deterministic. It does so by using a static ID for the HTML div that the plots are rendered into, as opposed to a random UUID that changes on every run.
This is useful when HTML reports are tracked using tools like DVC, where a difference in checksum is used as an indicator for content change.

Code PR

  • I have read through the contributing notes and understand the structure of the package. In particular, if my PR modifies code of plotly.graph_objects, my modifications concern the codegen files and not generated files.
  • I have added tests (if submitting a new feature or correcting a bug) or
    modified existing tests.
  • For a new feature, I have added documentation examples in an existing or
    new tutorial notebook (please see the doc checklist as well).
  • I have added a CHANGELOG entry if fixing/changing/adding anything substantial.
  • For a new feature or a change in behaviour, I have updated the relevant docstrings in the code to describe the feature or behaviour (please see the doc checklist as well).

@Skn0tt Skn0tt changed the title 3449 deterministic html feat: make to_html deterministic Nov 24, 2021
@nicolaskruchten
Copy link
Contributor

Thanks for this PR! Unfortunately, I won't be able to accept it as-is, as it might break things for folks who are using this function to generate HTML fragments for multiple figures, and then injecting them into the same downstream HTML file.

I would recommend adding a new argument to the end of the argument list like div_id with a default value of None (which would preserve the current behaviour) and if it's a string, then that string would be used in place of the UUID.

@Skn0tt
Copy link
Contributor Author

Skn0tt commented Nov 24, 2021

Hi Nicolas, thanks for getting back so fast! That makes a lot of sense, didn't think of usecases where multiple HTML outputs are in the same file. Implemented in 3b461a7.

@nicolaskruchten nicolaskruchten merged commit e735ba8 into plotly:master Dec 20, 2021
@nicolaskruchten
Copy link
Contributor

Thanks!

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.

Plotly Diagram file is non-deterministic due to random UUID
2 participants