Skip to content

[wip] - ipyplotly fixes #956

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

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,15 @@ test_output.txt

plotly/api/v2/spectacle_presentations.py

plotly/presentation_objs/
plotly/presentation_objs/

plotly/datatypes

plotly/validators

.idea

js/node_modules/

# Compiled javascript
plotlywidget/static/
20 changes: 18 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
machine:

pre:
- cd /home/ubuntu/.pyenv/plugins/python-build/../.. && git pull && cd -
- pyenv install 3.6.4

environment:

PLOTLY_CONFIG_DIR: ${HOME}/.plotly
Expand All @@ -8,26 +12,38 @@ machine:
PLOTLY_TOX_PYTHON_33: /home/ubuntu/.pyenv/versions/3.3.3/bin/python3.3
PLOTLY_TOX_PYTHON_34: /home/ubuntu/.pyenv/versions/3.4.3/bin/python3.4
PLOTLY_TOX_PYTHON_35: /home/ubuntu/.pyenv/versions/3.5.0/bin/python3.5
PLOTLY_TOX_PYTHON_36: /home/ubuntu/.pyenv/versions/3.6.4/bin/python3.6
PLOTLY_JUPYTER_TEST_DIR: /home/ubuntu/${CIRCLE_PROJECT_REPONAME}/plotly/tests/test_optional/test_jupyter

node:
# use a pre-installed version of node so we don't need to download it.
version: 4.2.2
version: 6.11.1

dependencies:

override:

# Temporary workaround
- mv plotly/graph_objs/graph_objs.py plotly/graph_objs/graph_objs_temp.py
- touch plotly/graph_objs/graph_objs.py
- mv plotly/graph_objs/graph_objs_temp.py plotly/graph_objs/graph_objs.py

# install everything tox knows about and the plotly package.
- pyenv local 3.6.4
- pip install -e .
- pip install tox
- tox --notest
- python setup.py codegen
- pip install -I .
- jupyter nbextension enable --py widgetsnbextension
- jupyter nbextension install --py --symlink --sys-prefix plotlywidget
- jupyter nbextension enable --py --sys-prefix plotlywidget

# we need to cd out of the project root to ensure the install worked
- cd ~ && python -c "import plotly"

# install jupyter test JS requirements
- cd ${PLOTLY_JUPYTER_TEST_DIR} && npm i
# - cd ${PLOTLY_JUPYTER_TEST_DIR} && npm i

cache_directories:

Expand Down
78 changes: 78 additions & 0 deletions codegen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import json
import os.path as opath
import os
import shutil

import time

from codegen.datatypes import build_datatypes_py, write_datatypes_py, append_figure_class
from codegen.utils import TraceNode, PlotlyNode, LayoutNode, FrameNode
from codegen.validators import write_validator_py, append_traces_validator_py


def perform_codegen():
outdir = 'plotly/'
# outdir = 'codegen/output'
# Load plotly schema
# ------------------
with open('plotly/package_data/default-schema.json', 'r') as f:
plotly_schema = json.load(f)

# Compute property paths
# ----------------------
base_traces_node = TraceNode(plotly_schema)
compound_trace_nodes = PlotlyNode.get_all_compound_datatype_nodes(plotly_schema, TraceNode)
compound_layout_nodes = PlotlyNode.get_all_compound_datatype_nodes(plotly_schema, LayoutNode)
compound_frame_nodes = PlotlyNode.get_all_compound_datatype_nodes(plotly_schema, FrameNode)

extra_layout_nodes = PlotlyNode.get_all_trace_layout_nodes(plotly_schema)

# Write out validators
# --------------------
validators_pkgdir = opath.join(outdir, 'validators')
if opath.exists(validators_pkgdir):
shutil.rmtree(validators_pkgdir)

# ### Layout ###
for node in compound_layout_nodes:
write_validator_py(outdir, node, extra_layout_nodes)

# ### Trace ###
for node in compound_trace_nodes:
write_validator_py(outdir, node)

# Write out datatypes
# -------------------
datatypes_pkgdir = opath.join(outdir, 'datatypes')
if opath.exists(datatypes_pkgdir):
shutil.rmtree(datatypes_pkgdir)

# ### Layout ###
for node in compound_layout_nodes:
write_datatypes_py(outdir, node, extra_layout_nodes)

# ### Trace ###
for node in compound_trace_nodes:
write_datatypes_py(outdir, node)

# Append traces validator class
# -----------------------------
append_traces_validator_py(validators_pkgdir, base_traces_node)

# Add Frames
# ----------
# ### Validator ###
for node in compound_frame_nodes:
write_validator_py(outdir, node)

# ### Datatypes ###
for node in compound_frame_nodes:
write_datatypes_py(outdir, node)

# Append figure class to datatypes
# --------------------------------
append_figure_class(datatypes_pkgdir, base_traces_node)


if __name__ == '__main__':
perform_codegen()
Loading