-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Local plot schema #648
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
Local plot schema #648
Conversation
Conflicts: plotly/api/v2/plot_schema.py plotly/graph_reference.py plotly/tests/test_core/test_api/test_v2/test_plot_schema.py plotly/tests/test_core/test_graph_reference/test_graph_reference.py
@Kully can you give this a review? We discussed the no-download-on-import portion of this in #642, but I've also done the following (which we haven't discussed wrt Semantic Versioning):
|
@@ -37,7 +37,8 @@ def _list_help(object_name, path=(), parent_object_names=()): | |||
items = graph_reference.ARRAYS[object_name]['items'] | |||
items_classes = [graph_reference.string_to_class_name(item) | |||
for item in items] | |||
lines = textwrap.wrap(repr(items_classes), width=LINE_SIZE-TAB_SIZE) | |||
items_classes.sort() | |||
lines = textwrap.wrap(repr(items_classes), width=LINE_SIZE-TAB_SIZE - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit Picky, but would lines = textwrap.wrap(repr(items_classes), width=LINE_SIZE - TAB_SIZE - 1)
or lines = textwrap.wrap(repr(items_classes), width=LINE_SIZE-TAB_SIZE-1)
be better for consistency?
@@ -167,7 +169,7 @@ def _dict_attribute_help(object_name, path, parent_object_names, attribute): | |||
if isinstance(val, list) and attribute == 'showline': | |||
val = val[0] | |||
|
|||
lines = textwrap.wrap(val, width=LINE_SIZE) | |||
lines = textwrap.wrap(val, width=LINE_SIZE - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing
attributes = list( | ||
graph_reference.get_valid_attributes(object_name, parent_object_names)) | ||
attributes.sort() | ||
lines = textwrap.wrap(repr(list(attributes)), width=LINE_SIZE-TAB_SIZE - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment
|
||
:raises: (ValueError) If the FLAG isn't found. | ||
:return: (list) The lines we're copying. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the doc strings should not have the extra space between last line and the triple quotes """
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe, I disagree on this one. But I'm OK with changing it. You like to do the blank line after the """
then?
if not flag_found: | ||
raise ValueError( | ||
'Failed to find flag:\n''{}\n''in graph_objs_tools.py.' | ||
.format(FLAG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More a suggestion, but for legibility, what do you think about putting the format(FLAG)
on the line above? I think it's 81 chars on that line, but would be worth IMO
Your call ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh... that string looks wrong to me, the extra '
characters? I'll fix this up.
|
||
|
||
def print_figure_patch(f): | ||
"""Print a patch to our Figure object into the given open file.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For one-liner doc strings, which is more common to your knowledge:
'''one-line-here'''
'''
one-line-here
'''
I usually do the latter. Let me know if you think this is worth worrying/thinking about
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One-liners can/should be one-liners:
https://www.python.org/dev/peps/pep-0257/#one-line-docstrings
Previously, we generated these *on import*, which is slow and it’s a little sneaky. Users end up using classes that are not actually written *anywhere* in our package. Now that we only update the plot schema in version releases (no longer on import), we can also just programmatically add in all the graph obj classes. Instead of adding them to memory, we literally just print them to the file. This is some serious meta-programming… but, the resulting file will have to be syntactically valid and pass our test suite, so I’m not *too* worried about it.
In Python 2, you *must* have an `__init__.py` file to have a python package. However, in Python 3, you don’t need that! We have `/graph_reference` and `graph_reference.py` defined, which seems to *work*, but is poorly organized and should be fixed. For instance, it causes `unresolved import errors` in IDEs that have `goto-source`-type functionality. Conflicts: makefile
This has been a source of confusion every time we end up needing a new resource (like a js or json file). If you forget to add the new pattern in `setup.py`, the installed site-package just won’t include the file. Now all our non `.py` files should live in `package_data/`.
I think this got introduced during some rebases ;__;.
377949e
to
33754a7
Compare
@Kully alright with this? |
@chriddyp , it'd be great to get a high-level 👍 from you on 51ef008 still. You don't need to dig into the code very much. In general I'm just wondering if you think the approach of moving the meta programming we were already doing into auto-generated lines inside the Specifically, all the work is done in Edit, after rebase --> c26e318 |
This PR stops auto-loading the plot-schema on import. We decided in #642 that this shouldn't need to force a major version bump, so I'll add a minor version bump here.
See #614 for the original PR. I noticed that we actually had a weird PY3 conflict due to a change in how importing works in PY3 (See commit notes).