MCPcopy Index your code
hub / github.com/plotly/plotly.js / make_baselines_async

Function make_baselines_async

test/image/make_baseline.py:85–153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83
84
85async def make_baselines_async():
86 kopts = dict(plotlyjs=plotlyjs)
87 if mathjax is not None:
88 kopts["mathjax"] = mathjax
89
90 async with kaleido.Kaleido(n=1, **kopts) as k:
91 for name in allNames:
92 outName = name
93 if mathjax_version == 3:
94 outName = "mathjax3___" + name
95
96 print(outName)
97
98 created = False
99
100 MAX_RETRY = 2 # 1 means retry once
101 for attempt in range(0, MAX_RETRY + 1):
102 with open(os.path.join(dirIn, name + ".json"), "r") as _in:
103 fig = json.load(_in)
104
105 width = 700
106 height = 500
107 if "layout" in fig:
108 layout = fig["layout"]
109 if "autosize" not in layout or not layout["autosize"]:
110 if "width" in layout:
111 width = layout["width"]
112 if "height" in layout:
113 height = layout["height"]
114
115 if (
116 "b64" in sys.argv
117 or "b64=" in sys.argv
118 or "b64-json" in sys.argv
119 ):
120 newFig = dict()
121 arraysToB64(fig, newFig)
122 fig = newFig
123 if "b64-json" in sys.argv and attempt == 0:
124 print(json.dumps(fig, indent=2))
125
126 try:
127 bytes = await k.calc_fig(
128 fig,
129 opts=dict(
130 format="png",
131 width=width,
132 height=height,
133 ),
134 topojson=topojson,
135 )
136 filename = os.path.join(dirOut, outName + ".png")
137 with open(filename, "wb") as f:
138 f.write(bytes)
139 created = True
140 except Exception as e:
141 print(e)
142 if attempt < MAX_RETRY:

Callers 1

make_baseline.pyFile · 0.85

Calls 2

arraysToB64Function · 0.90
printFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…