Skip to content

Ipyplotly test fixes #974

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 7 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/
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