Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0184bd4

Browse filesBrowse files
committed
use kaleido v1 for image tests
1 parent 67b0cfa commit 0184bd4
Copy full SHA for 0184bd4

File tree

Expand file treeCollapse file tree

3 files changed

+128
-70
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+128
-70
lines changed
Open diff view settings
Collapse file

‎.circleci/config.yml‎

Copy file name to clipboardExpand all lines: .circleci/config.yml
+41-11Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
install-firefox: false
4545
install-geckodriver: false
4646
install-chrome: true
47-
chrome-version: "132.0.6834.110"
47+
chrome-version: "142.0.7444.175"
4848
- attach_workspace:
4949
at: ~/
5050
- run:
@@ -83,7 +83,7 @@ jobs:
8383
install-firefox: false
8484
install-geckodriver: false
8585
install-chrome: true
86-
chrome-version: "132.0.6834.110"
86+
chrome-version: "142.0.7444.175"
8787
- attach_workspace:
8888
at: ~/
8989
- run:
@@ -105,7 +105,7 @@ jobs:
105105
install-firefox: false
106106
install-geckodriver: false
107107
install-chrome: true
108-
chrome-version: "132.0.6834.110"
108+
chrome-version: "142.0.7444.175"
109109
- attach_workspace:
110110
at: ~/
111111
- run:
@@ -127,7 +127,7 @@ jobs:
127127
install-firefox: false
128128
install-geckodriver: false
129129
install-chrome: true
130-
chrome-version: "132.0.6834.110"
130+
chrome-version: "142.0.7444.175"
131131
- attach_workspace:
132132
at: ~/
133133
- run:
@@ -168,7 +168,7 @@ jobs:
168168
install-firefox: false
169169
install-geckodriver: false
170170
install-chrome: true
171-
chrome-version: "132.0.6834.110"
171+
chrome-version: "142.0.7444.175"
172172
- attach_workspace:
173173
at: ~/
174174
- run:
@@ -189,7 +189,7 @@ jobs:
189189
install-firefox: false
190190
install-geckodriver: false
191191
install-chrome: true
192-
chrome-version: "132.0.6834.110"
192+
chrome-version: "142.0.7444.175"
193193
- attach_workspace:
194194
at: ~/
195195
- run:
@@ -217,9 +217,15 @@ jobs:
217217
make-baselines-virtual-webgl:
218218
parallelism: 8
219219
docker:
220-
- image: cimg/python:3.12.11
220+
- image: cimg/python:3.12.11-browsers
221221
working_directory: ~/plotly.js
222222
steps:
223+
- run: sudo apt-get update
224+
- browser-tools/install-browser-tools:
225+
install-firefox: false
226+
install-geckodriver: false
227+
install-chrome: true
228+
chrome-version: "142.0.7444.175"
223229
- attach_workspace:
224230
at: ~/
225231
- run: sudo apt-get update
@@ -236,9 +242,15 @@ jobs:
236242

237243
make-baselines-mathjax3:
238244
docker:
239-
- image: cimg/python:3.12.11
245+
- image: cimg/python:3.12.11-browsers
240246
working_directory: ~/plotly.js
241247
steps:
248+
- run: sudo apt-get update
249+
- browser-tools/install-browser-tools:
250+
install-firefox: false
251+
install-geckodriver: false
252+
install-chrome: true
253+
chrome-version: "142.0.7444.175"
242254
- attach_workspace:
243255
at: ~/
244256
- run: sudo apt-get update
@@ -256,9 +268,15 @@ jobs:
256268
make-baselines:
257269
parallelism: 12
258270
docker:
259-
- image: cimg/python:3.12.11
271+
- image: cimg/python:3.12.11-browsers
260272
working_directory: ~/plotly.js
261273
steps:
274+
- run: sudo apt-get update
275+
- browser-tools/install-browser-tools:
276+
install-firefox: false
277+
install-geckodriver: false
278+
install-chrome: true
279+
chrome-version: "142.0.7444.175"
262280
- attach_workspace:
263281
at: ~/
264282
- run: sudo apt-get update
@@ -276,9 +294,15 @@ jobs:
276294
make-baselines-b64:
277295
parallelism: 12
278296
docker:
279-
- image: cimg/python:3.12.11
297+
- image: cimg/python:3.12.11-browsers
280298
working_directory: ~/plotly.js
281299
steps:
300+
- run: sudo apt-get update
301+
- browser-tools/install-browser-tools:
302+
install-firefox: false
303+
install-geckodriver: false
304+
install-chrome: true
305+
chrome-version: "142.0.7444.175"
282306
- attach_workspace:
283307
at: ~/
284308
- run: sudo apt-get update
@@ -355,9 +379,15 @@ jobs:
355379

356380
make-exports:
357381
docker:
358-
- image: cimg/python:3.12.11
382+
- image: cimg/python:3.12.11-browsers
359383
working_directory: ~/plotly.js
360384
steps:
385+
- run: sudo apt-get update
386+
- browser-tools/install-browser-tools:
387+
install-firefox: false
388+
install-geckodriver: false
389+
install-chrome: true
390+
chrome-version: "142.0.7444.175"
361391
- attach_workspace:
362392
at: ~/
363393
- run: sudo apt-get update
Collapse file

‎.circleci/env_image.sh‎

Copy file name to clipboardExpand all lines: .circleci/env_image.sh
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ sudo apt install fontconfig
1515
sudo fc-cache -f
1616

1717
# install kaleido & plotly
18-
sudo python3 -m pip install kaleido==0.2.1 plotly==6.2.0 --progress-bar off
18+
sudo python3 -m pip install "plotly==6.5" "kaleido==1.2" --progress-bar off
1919

2020
# install numpy i.e. to convert arrays to typed arrays
21-
sudo python3 -m pip install numpy==1.24.2
21+
sudo python3 -m pip install "numpy==2.3" --progress-bar off
22+
23+
# verify versions of installed python packages
24+
sudo python3 -m pip freeze
Collapse file

‎test/image/make_baseline.py‎

Copy file name to clipboard
+82-57Lines changed: 82 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import asyncio
2+
import json
13
import os
24
import sys
3-
import json
5+
6+
import kaleido
47
import plotly.io as pio
8+
59
from convert_b64 import arraysToB64
610

11+
712
args = []
813
if len(sys.argv) == 2 :
914
args = sys.argv[1].split()
@@ -19,7 +24,7 @@
1924
dirIn = os.path.join(root, 'test', 'image', 'mocks')
2025
dirOut = os.path.join(root, 'build', 'test_images')
2126

22-
# N.B. equal is the falg to write to baselines not test_images
27+
# N.B. equal is the flag to write to baselines not test_images
2328

2429
if '=' in args :
2530
args = args[args.index('=') + 1:]
@@ -31,11 +36,12 @@
3136
print('output to', dirOut)
3237

3338
mathjax_version = 2
39+
mathjax = None
3440
if 'mathjax3' in sys.argv or 'mathjax3=' in sys.argv :
3541
# until https://github.com/plotly/Kaleido/issues/124 is addressed
3642
# we are uanble to use local mathjax v3 installed in node_modules
3743
# for now let's download it from the internet:
38-
pio.kaleido.scope.mathjax = 'https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js'
44+
mathjax = 'https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js'
3945
mathjax_version = 3
4046
print('Kaleido using MathJax v3')
4147

@@ -52,8 +58,8 @@
5258

5359
plotlyjs = plotlyjs_with_virtual_webgl
5460

55-
pio.kaleido.scope.plotlyjs = plotlyjs
56-
pio.kaleido.scope.topojson = "file://" + os.path.join(root, 'topojson', 'dist')
61+
pio.defaults.plotlyjs = plotlyjs
62+
pio.defaults.topojson = "file://" + os.path.join(root, 'topojson', 'dist')
5763
pio.templates.default = 'none'
5864

5965
ALL_MOCKS = [os.path.splitext(a)[0] for a in os.listdir(dirIn) if a.endswith('.json')]
@@ -79,55 +85,74 @@
7985
sys.exit(1)
8086

8187
failed = []
82-
for name in allNames :
83-
outName = name
84-
if mathjax_version == 3 :
85-
outName = 'mathjax3___' + name
86-
87-
print(outName)
88-
89-
created = False
90-
91-
MAX_RETRY = 2 # 1 means retry once
92-
for attempt in range(0, MAX_RETRY + 1) :
93-
with open(os.path.join(dirIn, name + '.json'), 'r') as _in :
94-
fig = json.load(_in)
95-
96-
width = 700
97-
height = 500
98-
if 'layout' in fig :
99-
layout = fig['layout']
100-
if 'autosize' not in layout or layout['autosize'] != True :
101-
if 'width' in layout :
102-
width = layout['width']
103-
if 'height' in layout :
104-
height = layout['height']
105-
106-
if 'b64' in sys.argv or 'b64=' in sys.argv or 'b64-json' in sys.argv :
107-
newFig = dict()
108-
arraysToB64(fig, newFig)
109-
fig = newFig
110-
if 'b64-json' in sys.argv and attempt == 0 : print(json.dumps(fig, indent = 2))
111-
112-
try :
113-
pio.write_image(
114-
fig=fig,
115-
file=os.path.join(dirOut, outName + '.png'),
116-
width=width,
117-
height=height,
118-
validate=False
119-
)
120-
created = True
121-
except Exception as e :
122-
print(e)
123-
if attempt < MAX_RETRY :
124-
print('retry', attempt + 1, '/', MAX_RETRY)
125-
else :
126-
failed.append(outName)
127-
128-
if(created) : break
129-
130-
if len(failed) > 0 :
131-
print('Failed at :')
132-
print(failed)
133-
sys.exit(1)
88+
89+
async def make_baselines_async():
90+
91+
kopts = dict(
92+
plotlyjs=plotlyjs,
93+
)
94+
if mathjax is not None:
95+
kopts['mathjax'] = mathjax
96+
97+
async with kaleido.Kaleido(n=1, **kopts) as k:
98+
for name in allNames:
99+
outName = name
100+
if mathjax_version == 3:
101+
outName = 'mathjax3___' + name
102+
103+
print(outName)
104+
105+
created = False
106+
107+
MAX_RETRY = 2 # 1 means retry once
108+
for attempt in range(0, MAX_RETRY + 1) :
109+
with open(os.path.join(dirIn, name + '.json'), 'r') as _in :
110+
fig = json.load(_in)
111+
112+
width = 700
113+
height = 500
114+
if 'layout' in fig :
115+
layout = fig['layout']
116+
if 'autosize' not in layout or layout['autosize'] != True :
117+
if 'width' in layout :
118+
width = layout['width']
119+
if 'height' in layout :
120+
height = layout['height']
121+
122+
if 'b64' in sys.argv or 'b64=' in sys.argv or 'b64-json' in sys.argv :
123+
newFig = dict()
124+
arraysToB64(fig, newFig)
125+
fig = newFig
126+
if 'b64-json' in sys.argv and attempt == 0 : print(json.dumps(fig, indent = 2))
127+
128+
try:
129+
bytes = await k.calc_fig(
130+
fig,
131+
path=None,
132+
opts=dict(
133+
format="png",
134+
width=width,
135+
height=height,
136+
),
137+
)
138+
filename = os.path.join(dirOut, outName + '.png')
139+
with open(filename, "wb") as f:
140+
f.write(bytes)
141+
created = True
142+
except Exception as e:
143+
print(e)
144+
if attempt < MAX_RETRY :
145+
print('retry', attempt + 1, '/', MAX_RETRY)
146+
else :
147+
failed.append(outName)
148+
149+
if(created): break
150+
151+
if len(failed) > 0 :
152+
print('Failed at :')
153+
print(failed)
154+
sys.exit(1)
155+
156+
157+
if __name__ == "__main__":
158+
asyncio.run(make_baselines_async())

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.