Skip to content

Commit 46e0683

Browse files
authored
Orca integration for static image export (plotly#1120)
Integrates orca into plotly.py to support exporting figures as static images 🎉 See plotly#1120 for discussion of architecture and API updates. Also adds new `test_orca/` test suite.
1 parent 27ab46a commit 46e0683

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+12733
-6
lines changed

.circleci/config.yml

+93
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,96 @@ jobs:
232232
command: 'tox -e py37-plot_ly'
233233
no_output_timeout: 20m
234234

235+
"python-2-7-orca":
236+
docker:
237+
- image: circleci/node:10.9-stretch-browsers
238+
environment:
239+
PYTHON_VERSION: 2.7
240+
241+
steps:
242+
- checkout
243+
- restore_cache:
244+
keys:
245+
- conda-27-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
246+
- run:
247+
name: Create conda environment
248+
command: .circleci/create_conda_optional_env.sh
249+
250+
- save_cache:
251+
key: conda-27-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
252+
paths:
253+
- /home/circleci/miniconda/
254+
- run:
255+
name: Run Tests
256+
command: |
257+
. /home/circleci/miniconda/etc/profile.d/conda.sh
258+
conda activate circle_optional
259+
pytest --disable-warnings plotly/tests/test_core
260+
pytest plotly/tests/test_orca
261+
262+
- store_artifacts:
263+
path: plotly/tests/test_orca/images/linux/failed
264+
265+
"python-3-5-orca":
266+
docker:
267+
- image: circleci/node:10.9-stretch-browsers
268+
environment:
269+
PYTHON_VERSION: 3.5
270+
271+
steps:
272+
- checkout
273+
- restore_cache:
274+
keys:
275+
- conda-35-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
276+
- run:
277+
name: Create conda environment
278+
command: .circleci/create_conda_optional_env.sh
279+
280+
- save_cache:
281+
key: conda-35-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
282+
paths:
283+
- /home/circleci/miniconda/
284+
- run:
285+
name: Run Tests
286+
command: |
287+
. /home/circleci/miniconda/etc/profile.d/conda.sh
288+
conda activate circle_optional
289+
pytest --disable-warnings plotly/tests/test_core
290+
pytest plotly/tests/test_orca
291+
292+
- store_artifacts:
293+
path: plotly/tests/test_orca/images/linux/failed
294+
295+
"python-3-7-orca":
296+
docker:
297+
- image: circleci/node:10.9-stretch-browsers
298+
environment:
299+
PYTHON_VERSION: 3.7
300+
301+
steps:
302+
- checkout
303+
- restore_cache:
304+
keys:
305+
- conda-37-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
306+
- run:
307+
name: Create conda environment
308+
command: .circleci/create_conda_optional_env.sh
309+
310+
- save_cache:
311+
key: conda-37-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
312+
paths:
313+
- /home/circleci/miniconda/
314+
- run:
315+
name: Run Tests
316+
command: |
317+
. /home/circleci/miniconda/etc/profile.d/conda.sh
318+
conda activate circle_optional
319+
pytest --disable-warnings plotly/tests/test_core
320+
pytest plotly/tests/test_orca
321+
322+
- store_artifacts:
323+
path: plotly/tests/test_orca/images/linux/failed
324+
235325
workflows:
236326
version: 2
237327
build:
@@ -250,3 +340,6 @@ workflows:
250340
- "python-2.7-plot_ly"
251341
- "python-3.4-plot_ly"
252342
- "python-3.7-plot_ly"
343+
- "python-2-7-orca"
344+
- "python-3-5-orca"
345+
- "python-3-7-orca"
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
if [ ! -d $HOME/miniconda/envs/circle_optional ]; then
4+
# Download miniconda
5+
if [ "$PYTHON_VERSION" = "2.7" ]; then
6+
wget http://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh
7+
else
8+
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
9+
fi
10+
11+
chmod +x miniconda.sh
12+
13+
# Install miniconda
14+
./miniconda.sh -b -p $HOME/miniconda
15+
16+
# Create environment
17+
# PYTHON_VERSION=3.6
18+
$HOME/miniconda/bin/conda create -n circle_optional --yes python=$PYTHON_VERSION \
19+
requests six pytz retrying psutil pandas decorator pytest mock nose poppler
20+
21+
# Install orca into environment
22+
$HOME/miniconda/bin/conda install --yes -n circle_optional -c plotly plotly-orca
23+
fi

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ venv
3535
build
3636
dist
3737
plotly.egg-info/
38+
39+
plotly/tests/test_orca/images/*/failed
40+
plotly/tests/test_orca/images/*/tmp

js/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

optional-requirements.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ numpy
1515
coverage==4.3.1
1616
mock==2.0.0
1717
nose==1.3.3
18+
pytest==3.5.1
19+
20+
## orca ##
21+
psutil
1822

1923
## codegen dependencies ##
2024
yapf
@@ -37,5 +41,5 @@ pyshp
3741
geopandas
3842
shapely
3943

40-
# ipyplotly integration
41-
pil
44+
# image uri conversion
45+
pillow

plotly/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
from __future__ import absolute_import
3030

3131
from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
32-
utils, session, offline, colors)
32+
utils, session, offline, colors, io)
3333
from plotly.version import __version__

plotly/io/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from ._orca import to_image, write_image
2+
from . import orca

0 commit comments

Comments
 (0)