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

Add back the mime renderer JL extension #5096

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
17 changes: 10 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ commands:
source .venv/bin/activate
uv pip install .
uv pip install -r ./test_requirements/requirements_optional.txt
cd js
cd plotly/labextension
npm ci
npm run build

@@ -273,18 +273,20 @@ jobs:
- run:
name: initial NPM Build
command: |
python -m venv venv
. venv/bin/activate
cd js
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
source .venv/bin/activate
uv pip install jupyter
cd plotly/labextension
npm ci
npm run build
git status

- run:
name: PyPI Build
command: |
. venv/bin/activate
pip install build
source .venv/bin/activate
uv pip install build
python -m build --sdist --wheel -o dist
cp -R dist output
git status
@@ -323,7 +325,8 @@ jobs:
uv pip uninstall plotly
cd ..
uv pip install -e .
cd js
uv pip install jupyter
cd plotly/labextension
npm ci
npm run build
cd ../doc
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -60,6 +60,8 @@ doc/.ipynb_checkpoints
tags
doc/check-or-enforce-order.py
plotly/package_data/widgetbundle.js
plotly/labextension/static
plotly/labextension/lib

tests/percy/*.html
tests/percy/pandas2/*.html
6 changes: 3 additions & 3 deletions commands.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
from distutils import log

project_root = os.path.dirname(os.path.abspath(__file__))
node_root = os.path.join(project_root, "js")
node_root = os.path.join(project_root, "plotly", "labextension")
is_repo = os.path.exists(os.path.join(project_root, ".git"))
node_modules = os.path.join(node_root, "node_modules")
targets = [
@@ -23,9 +23,9 @@
]
)

# Load plotly.js version from js/package.json
# Load plotly.js version from plotly/labextension/package.json
def plotly_js_version():
path = os.path.join(project_root, "js", "package.json")
path = os.path.join(project_root, "plotly", "labextension", "package.json")
with open(path, "rt") as f:
package_json = json.load(f)
version = package_json["dependencies"]["plotly.js"]
16 changes: 0 additions & 16 deletions js/package.json

This file was deleted.

9 changes: 9 additions & 0 deletions plotly/__init__.py
Original file line number Diff line number Diff line change
@@ -180,3 +180,12 @@ def hist_series(data_frame, **kwargs):
skip += ["figsize", "bins", "legend"]
new_kwargs = {k: kwargs[k] for k in kwargs if k not in skip}
return histogram(data_frame, **new_kwargs)

def _jupyter_labextension_paths():
"""Called by Jupyter Lab Server to detect if it is a valid labextension and
to install the extension.
"""
return [{
'src': 'labextension/static',
'dest': 'jupyterlab-plotly',
}]
3 changes: 1 addition & 2 deletions plotly/io/_base_renderers.py
Original file line number Diff line number Diff line change
@@ -76,8 +76,7 @@ def to_mimebundle(self, fig_dict):
class PlotlyRenderer(MimetypeRenderer):
"""
Renderer to display figures using the plotly mime type. This renderer is
compatible with JupyterLab (using the @jupyterlab/plotly-extension),
VSCode, and nteract.
compatible with VSCode and nteract.

mime type: 'application/vnd.plotly.v1+json'
"""
2 changes: 1 addition & 1 deletion plotly/io/_renderers.py
Original file line number Diff line number Diff line change
@@ -549,7 +549,7 @@ def show(fig, renderer=None, validate=True, **kwargs):
default_renderer = "browser"

# Fallback to renderer combination that will work automatically
# in the classic notebook (offline), jupyterlab, nteract, vscode, and
# in the classic notebook, jupyterlab, nteract, vscode, and
# nbconvert HTML export.
if not default_renderer:
default_renderer = "plotly_mimetype+notebook"
Loading
Oops, something went wrong.