Closed
Conversation
…ly.py into kaleido-docs-updates
Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com>
Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com>
Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com>
Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com>
Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com>
…ly.py into kaleido-docs-updates
…ly.py into kaleido-docs-updates
…DataValidator now
…y into refactor-validators
Contributor
|
this is looking good - thank you very much @bmaranville. We won't try to get it into the 6.1 release, but it will definitely be part of 6.2. |
Contributor
|
Note: plotly.py 6.1.0rc0 is 7549710 bytes as a .tar.gz; these changes get that down to 6601687 bytes, which is a 12.5% reduction on top of the reductions in #4978. cc @alexcjohnson |
Contributor
Author
That's great! Thanks very much for walking me through the code paths related to this issue. I look forward to seeing it in the 6.2 release. |
5 tasks
Contributor
|
closed in favor of #5214 (which rebases these changes on top of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Code PR
plotly.graph_objects, my modifications concern thecodegenfiles and not generated files.modified existing tests.
new tutorial notebook (please see the doc checklist as well).
Refactor of validators
This refactor is based on
release-6.0.1rc0Helps address #1208
Motivation
The large number of files in the
plotly/validatorsfolder slows down package installation, esp. on systems where files are inspected for viruses during install (e.g. Windows)The majority of the code is duplicated across these files as well, as there are e.g. >650 instances of nearly-identical classes inheriting
_plotly_utils.basevalidators.BooleanValidatorMitigation
Things to note, in the current validator arrangement:
plotly.validatorsinherit directly from classes in_plotly_utils.basevalidators__init__plotly.validator_cache.ValidatorCache.get_validator(parent_name, prop_name)python commands.py codegenIn this PR, the following changes are made:
codegen, instead of generating and writing thousands of python files toplotly/validators/..., we create a single JSON file store atplotly/validators/_validators.jsonand for each(parent_name, prop_name)combination we add an entry to the store withValidatorCache.get_validatormethod is modified so that rather than calculating an import path and then importing a validator class from the file tree, it looks up the custom kwargs and validator class name from the JSON store, then creates (and caches) a new instance of the validator class frombasevalidators, with the custom init kwargs, finally returning the instanceplotly.validatorsin the codebase are refactored to use theValidatorCacheinstead (there were only a handful of these cases)The net result is that the number of files to be installed is reduced from 14981 to 1652.