Skip to content

Commit e840a9f

Browse files
authored
V4 chart studio extraction (#1597)
* Move plotly package under plotly-package directory * Move codegen, submodules, templategen to plotly-package directory * remove unused example images directory * optional import of chart_studio in src validator * Move figure factory tests to plotly-figure-factory-package * Split out plotly/package_data into the appropriate distribution package * Update setup.py packages * Update codegen for new directory structure * Update setup.py tasks for new directory structure * Add license file per subproject * Move figure_factory module back into plotly package and extract the geo shape files into a _plotly_geo data package * Remove legacy graph_reference module * Update test_offline to not depend on working directory * Update config.yml test * Update test_offline paths * CI updates * Remove plotly.tests import in chart_studio tests * Install plotly-geo-package
1 parent 2a44ce3 commit e840a9f

File tree

1,457 files changed

+5012
-1238
lines changed

Some content is hidden

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

1,457 files changed

+5012
-1238
lines changed

.circleci/config.yml

+27-24
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
command: 'sudo pip install tox'
1616
- run:
1717
name: Test with tox
18-
command: 'tox -e py27-core'
18+
command: 'cd plotly-package; tox -e py27-core'
1919
no_output_timeout: 20m
2020

2121
python-3.5-core:
@@ -31,7 +31,7 @@ jobs:
3131
command: 'sudo pip install tox'
3232
- run:
3333
name: Test with tox
34-
command: 'tox -e py35-core'
34+
command: 'cd plotly-package; tox -e py35-core'
3535
no_output_timeout: 20m
3636

3737
python-3.6-core:
@@ -47,7 +47,7 @@ jobs:
4747
command: 'sudo pip install tox'
4848
- run:
4949
name: Test with tox
50-
command: 'tox -e py36-core'
50+
command: 'cd plotly-package; tox -e py36-core'
5151
no_output_timeout: 20m
5252

5353
python-3.7-core:
@@ -63,7 +63,7 @@ jobs:
6363
command: 'sudo pip install tox'
6464
- run:
6565
name: Test with tox
66-
command: 'tox -e py37-core'
66+
command: 'cd plotly-package; tox -e py37-core'
6767
no_output_timeout: 20m
6868

6969
# Optional
@@ -80,11 +80,11 @@ jobs:
8080
command: 'sudo pip install tox'
8181
- run:
8282
name: Install npm dependencies
83-
command: cd plotly/tests/test_optional/test_jupyter && npm install
83+
command: cd plotly-package/plotly/tests/test_optional/test_jupyter && npm install
8484
no_output_timeout: 20m
8585
- run:
8686
name: Test with tox
87-
command: 'tox -e py27-optional'
87+
command: 'cd plotly-package; tox -e py27-optional'
8888
no_output_timeout: 20m
8989

9090
python-3.5-optional:
@@ -100,11 +100,11 @@ jobs:
100100
command: 'sudo pip install tox'
101101
- run:
102102
name: Install npm dependencies
103-
command: cd plotly/tests/test_optional/test_jupyter && npm install
103+
command: cd plotly-package/plotly/tests/test_optional/test_jupyter && npm install
104104
no_output_timeout: 20m
105105
- run:
106106
name: Test with tox
107-
command: 'tox -e py35-optional'
107+
command: 'cd plotly-package; tox -e py35-optional'
108108
no_output_timeout: 20m
109109

110110
python-3.6-optional:
@@ -120,11 +120,11 @@ jobs:
120120
command: 'sudo pip install tox'
121121
- run:
122122
name: Install npm dependencies
123-
command: cd plotly/tests/test_optional/test_jupyter && npm install
123+
command: cd plotly-package/plotly/tests/test_optional/test_jupyter && npm install
124124
no_output_timeout: 20m
125125
- run:
126126
name: Test with tox
127-
command: 'tox -e py36-optional'
127+
command: 'cd plotly-package; tox -e py36-optional'
128128
no_output_timeout: 20m
129129

130130
python-3.7-optional:
@@ -140,11 +140,11 @@ jobs:
140140
command: 'sudo pip install tox'
141141
- run:
142142
name: Install npm dependencies
143-
command: cd plotly/tests/test_optional/test_jupyter && npm install
143+
command: cd plotly-package/plotly/tests/test_optional/test_jupyter && npm install
144144
no_output_timeout: 20m
145145
- run:
146146
name: Test with tox
147-
command: 'tox -e py37-optional'
147+
command: 'cd plotly-package; tox -e py37-optional'
148148
no_output_timeout: 20m
149149

150150
# Plot.ly
@@ -161,7 +161,7 @@ jobs:
161161
command: 'sudo pip install tox'
162162
- run:
163163
name: Test with tox
164-
command: 'tox -e py27-plot_ly'
164+
command: 'cd chart-studio-package; tox -e py27-plot_ly'
165165
no_output_timeout: 20m
166166

167167
python-3.5-plot_ly:
@@ -177,7 +177,7 @@ jobs:
177177
command: 'sudo pip install tox'
178178
- run:
179179
name: Test with tox
180-
command: 'tox -e py35-plot_ly'
180+
command: 'cd chart-studio-package; tox -e py35-plot_ly'
181181
no_output_timeout: 20m
182182

183183
python-3.7-plot_ly:
@@ -193,7 +193,7 @@ jobs:
193193
command: 'sudo pip install tox'
194194
- run:
195195
name: Test with tox
196-
command: 'tox -e py37-plot_ly'
196+
command: 'cd chart-studio-package; tox -e py37-plot_ly'
197197
no_output_timeout: 20m
198198

199199
python-2-7-orca:
@@ -220,8 +220,8 @@ jobs:
220220
command: |
221221
. /home/circleci/miniconda/etc/profile.d/conda.sh
222222
conda activate circle_optional
223-
pytest --disable-warnings plotly/tests/test_core
224-
pytest plotly/tests/test_orca
223+
pytest --disable-warnings plotly-package/plotly/tests/test_core
224+
pytest plotly-package/plotly/tests/test_orca
225225
226226
- store_artifacts:
227227
path: plotly/tests/test_orca/images/linux/failed
@@ -250,8 +250,8 @@ jobs:
250250
command: |
251251
. /home/circleci/miniconda/etc/profile.d/conda.sh
252252
conda activate circle_optional
253-
pytest --disable-warnings plotly/tests/test_core
254-
pytest plotly/tests/test_orca
253+
pytest --disable-warnings plotly-package/plotly/tests/test_core
254+
pytest plotly-package/plotly/tests/test_orca
255255
256256
- store_artifacts:
257257
path: plotly/tests/test_orca/images/linux/failed
@@ -280,8 +280,8 @@ jobs:
280280
command: |
281281
. /home/circleci/miniconda/etc/profile.d/conda.sh
282282
conda activate circle_optional
283-
pytest --disable-warnings plotly/tests/test_core
284-
pytest plotly/tests/test_orca
283+
pytest --disable-warnings plotly-package/plotly/tests/test_core
284+
pytest plotly-package/plotly/tests/test_orca
285285
286286
- store_artifacts:
287287
path: plotly/tests/test_orca/images/linux/failed
@@ -300,19 +300,21 @@ jobs:
300300
command: 'sudo pip install tox requests yapf pytz decorator retrying inflect'
301301
- run:
302302
name: Update plotlywidget version
303-
command: 'python setup.py updateplotlywidgetversion'
303+
command: 'cd plotly-package; python setup.py updateplotlywidgetversion'
304304
- run:
305305
name: Update plotly.js to dev
306-
command: 'python setup.py updateplotlyjsdev'
306+
command: 'cd plotly-package; python setup.py updateplotlyjsdev'
307307
- run:
308308
name: Test with tox
309309
command: |
310+
cd plotly-package
310311
locale
311312
tox -e py37-core -- -a '!nodev'
312313
no_output_timeout: 20m
313314
- run:
314315
name: Commit
315316
command: |
317+
cd plotly-package
316318
sudo mkdir /dist
317319
git config --global user.email "[email protected]"
318320
git config --global user.name "Your Name"
@@ -322,6 +324,7 @@ jobs:
322324
- run:
323325
name: Build source distribution package
324326
command: |
327+
cd plotly-package
325328
python setup.py sdist
326329
sudo cp dist/* /dist
327330
when: always
@@ -334,7 +337,7 @@ jobs:
334337
sudo cp ./plotlywidget* /dist
335338
when: always
336339
- store_artifacts:
337-
path: /dist
340+
path: plotly-package/dist
338341

339342
workflows:
340343
version: 2

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ plotly.egg-info/
3535

3636
plotly/tests/test_orca/images/*/failed
3737
plotly/tests/test_orca/images/*/tmp
38+
/plotly-package/plotly/tests/test_core/test_offline/plotly.min.js
39+
/plotly-package/plotly/tests/test_core/test_offline/temp-plot.html
File renamed without changes.
File renamed without changes.
File renamed without changes.

chart_studio/tests/test_optional/test_utils/test_utils.py renamed to chart-studio-package/chart_studio/tests/test_optional/test_utils/test_utils.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33

44
import _plotly_utils.utils
55
from chart_studio.grid_objs import Column
6-
from plotly import utils
7-
from plotly.tests.test_optional.test_utils.test_utils import numeric_list, \
8-
mixed_list, np_list
6+
from datetime import datetime as dt
7+
import numpy as np
8+
9+
np_list = np.array([1, 2, 3, np.NaN, np.NAN, np.Inf, dt(2014, 1, 5)])
10+
numeric_list = [1, 2, 3]
11+
mixed_list = [1, 'A', dt(2014, 1, 5), dt(2014, 1, 5, 1, 1, 1),
12+
dt(2014, 1, 5, 1, 1, 1, 1)]
913

1014

1115
class TestJSONEncoder(TestCase):

chart_studio/tests/utils.py renamed to chart-studio-package/chart_studio/tests/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ def stash_session(self):
4949

5050
def restore_session(self):
5151
session._session.clear() # clear and update to preserve references.
52-
session._session.update(self._session)
52+
session._session.update(self._session)

chart_studio/tools.py renamed to chart-studio-package/chart_studio/tools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,4 @@ def __init__(self, url, width, height):
396396
super(PlotlyDisplay, self).__init__(data=self.embed_code)
397397

398398
def _repr_html_(self):
399-
return self.embed_code
399+
return self.embed_code
File renamed without changes.

chart_studio/widgets/graph_widget.py renamed to chart-studio-package/chart_studio/widgets/graph_widget.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Load JS widget code
2121
# No officially recommended way to do this in any other way
2222
# http://mail.scipy.org/pipermail/ipython-dev/2014-April/013835.html
23-
js_widget_code = pkgutil.get_data('plotly',
23+
js_widget_code = pkgutil.get_data('chart_studio',
2424
'package_data/graphWidget.js'
2525
).decode('utf-8')
2626

chart-studio-package/setup.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from setuptools import setup
2+
import os
3+
4+
5+
def readme():
6+
parent_dir = os.path.dirname(os.path.realpath(__file__))
7+
with open(os.path.join(parent_dir, 'README.md')) as f:
8+
return f.read()
9+
10+
11+
setup(
12+
name="chart-studio",
13+
version="1.0.0a1",
14+
author="Chris P",
15+
author_email="[email protected]",
16+
maintainer="Jon Mease",
17+
maintainer_email="[email protected]",
18+
url="https://plot.ly/python/",
19+
project_urls={"Github": "https://github.com/plotly/plotly.py"},
20+
description="An open-source, interactive graphing library for Python",
21+
long_description=readme(),
22+
long_description_content_type="text/markdown",
23+
classifiers=[
24+
"Development Status :: 5 - Production/Stable",
25+
"Programming Language :: Python :: 2",
26+
"Programming Language :: Python :: 2.7",
27+
"Programming Language :: Python :: 3",
28+
"Programming Language :: Python :: 3.3",
29+
"Programming Language :: Python :: 3.4",
30+
"Programming Language :: Python :: 3.5",
31+
"Programming Language :: Python :: 3.6",
32+
"Programming Language :: Python :: 3.7",
33+
"Topic :: Scientific/Engineering :: Visualization",
34+
],
35+
license="MIT",
36+
packages=[
37+
"chart_studio",
38+
"chart_studio.api",
39+
"chart_studio.api.v1",
40+
"chart_studio.api.v2",
41+
"chart_studio.dashboard_objs",
42+
"chart_studio.grid_objs",
43+
"chart_studio.plotly",
44+
"chart_studio.plotly.chunked_requests",
45+
"chart_studio.presentation_objs",
46+
"chart_studio.widgets",
47+
],
48+
package_data={'chart_studio': ['package_data/*']},
49+
install_requires=["plotly", "requests", "retrying>=1.3.3", "six"],
50+
zip_safe=False,
51+
)

chart-studio-package/tox.ini

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
; Tox is a testing tool that manages virtualenvs for testing multiple Python
2+
; environments in a consistent/controlled way.
3+
4+
; SETTING ENVIRONMENT VARIABLES AND TOX TESTING VARIABLES
5+
;
6+
; You can limit tox testing to certain environments via the `-e` (envlist)
7+
; command line option:
8+
; tox -e py27-core,py34-core
9+
; OR, you can just set the `TOXENV` environment variable, which is handy:
10+
; TOXENV=py27-core,py34-core
11+
;
12+
; Integrating with the virtualenvs in Circle CI is a bit of a pain. For
13+
; whatever reason the "executable" `python35` (at the time of writing) cannot
14+
; be activated directly. Instead the circle.yml file specifies the actual
15+
; binary directly. Because of this, you too have to set the following env
16+
; variables:
17+
; PLOTLY_TOX_PYTHON_27=python2.7
18+
; PLOTLY_TOX_PYTHON_34=python3.4
19+
; ...
20+
; These will be specific to your machine and may not look like the ones above.
21+
; If you're not testing with all the python versions (see TOXENV above),
22+
; there's no need to install and map other versions.
23+
24+
; PASSING ADDITONAL ARGUMENTS TO TEST COMMANDS
25+
; The {posargs} is tox-specific and passes in any command line args after `--`.
26+
; For example, given the testing command in *this* file:
27+
; nosetests {posargs} -x plotly/tests/test_core
28+
;
29+
; The following command:
30+
; tox -- -a '!slow'
31+
;
32+
; Tells tox to call:
33+
; nosetests -a '!slow' -x plotly/tests/test_core
34+
;
35+
; Which is a nice way to skip slow tests for faster testing cycles.
36+
37+
[tox]
38+
; The py{A,B,C}-{X,Y} generates a matrix of envs:
39+
; pyA-X,pyA-Y,pyB-X,pyB-Y,pyC-X,pyC-Y
40+
envlist = py{27,34,37}-plot_ly
41+
42+
; Note that envs can be targeted by deps using the <target>: dep syntax.
43+
; Only one dep is allowed per line as of the time of writing. The <target>
44+
; can be a `-` (hyphen) concatenated string of the environments to target
45+
; with the given dep.
46+
47+
; These commands are general and will be run for *all* environments.
48+
[testenv]
49+
passenv=PLOTLY_TOX_*
50+
whitelist_externals=
51+
mkdir
52+
deps=
53+
coverage==4.3.1
54+
decorator==4.0.9
55+
mock==2.0.0
56+
nose==1.3.7
57+
requests==2.12.4
58+
six==1.10.0
59+
pytz==2016.10
60+
retrying==1.3.3
61+
pytest==3.5.1
62+
backports.tempfile==1.0
63+
pandas==0.23.2
64+
numpy==1.14.3
65+
ipywidgets==7.2.0
66+
matplotlib==2.2.3
67+
--editable=file:///{toxinidir}/../plotly-package
68+
69+
70+
; Plot.ly environments
71+
[testenv:py27-plot_ly]
72+
basepython={env:PLOTLY_TOX_PYTHON_27:}
73+
commands=
74+
python --version
75+
nosetests {posargs} -x chart_studio/tests/
76+
77+
[testenv:py35-plot_ly]
78+
basepython={env:PLOTLY_TOX_PYTHON_35:}
79+
commands=
80+
python --version
81+
nosetests {posargs} -x chart_studio/tests/
82+
83+
[testenv:py37-plot_ly]
84+
basepython={env:PLOTLY_TOX_PYTHON_37:}
85+
commands=
86+
python --version
87+
nosetests {posargs} -x chart_studio/tests/

example_images/simple_scatter.png

-14.5 KB
Binary file not shown.

example_images/subplot_methods.png

-52.2 KB
Binary file not shown.

js/webpack.config.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ module.exports = [
2121
entry: './src/extension.js',
2222
output: {
2323
filename: 'extension.js',
24-
path: path.resolve(__dirname, '..', 'plotlywidget', 'static'),
24+
path: path.resolve(
25+
__dirname, '..', 'plotly-package', 'plotlywidget', 'static'),
2526
libraryTarget: 'amd'
2627
}
2728
},
@@ -34,7 +35,8 @@ module.exports = [
3435
entry: './src/index.js',
3536
output: {
3637
filename: 'index.js',
37-
path: path.resolve(__dirname, '..', 'plotlywidget', 'static'),
38+
path: path.resolve(
39+
__dirname, '..', 'plotly-package', 'plotlywidget', 'static'),
3840
libraryTarget: 'amd'
3941
},
4042
node: {

0 commit comments

Comments
 (0)