Skip to content

Commit

Permalink
Orca integration for static image export (#1120)
Browse files Browse the repository at this point in the history
Integrates orca into plotly.py to support exporting figures as static images 🎉 

See #1120 for discussion of architecture and API updates.

Also adds new `test_orca/` test suite.
  • Loading branch information
jonmmease authored Aug 25, 2018
1 parent 27ab46a commit 46e0683
Show file tree
Hide file tree
Showing 45 changed files with 12,733 additions and 6 deletions.
93 changes: 93 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,96 @@ jobs:
command: 'tox -e py37-plot_ly'
no_output_timeout: 20m

"python-2-7-orca":
docker:
- image: circleci/node:10.9-stretch-browsers
environment:
PYTHON_VERSION: 2.7

steps:
- checkout
- restore_cache:
keys:
- conda-27-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
- run:
name: Create conda environment
command: .circleci/create_conda_optional_env.sh

- save_cache:
key: conda-27-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
paths:
- /home/circleci/miniconda/
- run:
name: Run Tests
command: |
. /home/circleci/miniconda/etc/profile.d/conda.sh
conda activate circle_optional
pytest --disable-warnings plotly/tests/test_core
pytest plotly/tests/test_orca
- store_artifacts:
path: plotly/tests/test_orca/images/linux/failed

"python-3-5-orca":
docker:
- image: circleci/node:10.9-stretch-browsers
environment:
PYTHON_VERSION: 3.5

steps:
- checkout
- restore_cache:
keys:
- conda-35-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
- run:
name: Create conda environment
command: .circleci/create_conda_optional_env.sh

- save_cache:
key: conda-35-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
paths:
- /home/circleci/miniconda/
- run:
name: Run Tests
command: |
. /home/circleci/miniconda/etc/profile.d/conda.sh
conda activate circle_optional
pytest --disable-warnings plotly/tests/test_core
pytest plotly/tests/test_orca
- store_artifacts:
path: plotly/tests/test_orca/images/linux/failed

"python-3-7-orca":
docker:
- image: circleci/node:10.9-stretch-browsers
environment:
PYTHON_VERSION: 3.7

steps:
- checkout
- restore_cache:
keys:
- conda-37-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
- run:
name: Create conda environment
command: .circleci/create_conda_optional_env.sh

- save_cache:
key: conda-37-v1-{{ checksum ".circleci/create_conda_optional_env.sh" }}
paths:
- /home/circleci/miniconda/
- run:
name: Run Tests
command: |
. /home/circleci/miniconda/etc/profile.d/conda.sh
conda activate circle_optional
pytest --disable-warnings plotly/tests/test_core
pytest plotly/tests/test_orca
- store_artifacts:
path: plotly/tests/test_orca/images/linux/failed

workflows:
version: 2
build:
Expand All @@ -250,3 +340,6 @@ workflows:
- "python-2.7-plot_ly"
- "python-3.4-plot_ly"
- "python-3.7-plot_ly"
- "python-2-7-orca"
- "python-3-5-orca"
- "python-3-7-orca"
23 changes: 23 additions & 0 deletions .circleci/create_conda_optional_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

if [ ! -d $HOME/miniconda/envs/circle_optional ]; then
# Download miniconda
if [ "$PYTHON_VERSION" = "2.7" ]; then
wget http://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh
else
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
fi

chmod +x miniconda.sh

# Install miniconda
./miniconda.sh -b -p $HOME/miniconda

# Create environment
# PYTHON_VERSION=3.6
$HOME/miniconda/bin/conda create -n circle_optional --yes python=$PYTHON_VERSION \
requests six pytz retrying psutil pandas decorator pytest mock nose poppler

# Install orca into environment
$HOME/miniconda/bin/conda install --yes -n circle_optional -c plotly plotly-orca
fi
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ venv
build
dist
plotly.egg-info/

plotly/tests/test_orca/images/*/failed
plotly/tests/test_orca/images/*/tmp
2 changes: 1 addition & 1 deletion js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions optional-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ numpy
coverage==4.3.1
mock==2.0.0
nose==1.3.3
pytest==3.5.1

## orca ##
psutil

## codegen dependencies ##
yapf
Expand All @@ -37,5 +41,5 @@ pyshp
geopandas
shapely

# ipyplotly integration
pil
# image uri conversion
pillow
2 changes: 1 addition & 1 deletion plotly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
from __future__ import absolute_import

from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
utils, session, offline, colors)
utils, session, offline, colors, io)
from plotly.version import __version__
2 changes: 2 additions & 0 deletions plotly/io/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from ._orca import to_image, write_image
from . import orca
Loading

0 comments on commit 46e0683

Please sign in to comment.