()
| 83 | |
| 84 | |
| 85 | async 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: |
no test coverage detected
searching dependent graphs…