@@ -101,15 +101,14 @@ class Kaleido(choreo.Browser):
101
101
102
102
### KALEIDO LIFECYCLE FUNCTIONS ###
103
103
104
- def __init__ ( # noqa: PLR0913
104
+ def __init__ (
105
105
self ,
106
- * args : Any , # TODO(AJP): does choreographer take args?
106
+ # *args: Any, force named vars for all choreographer passthrough
107
107
n : int = 1 ,
108
108
timeout : int | None = 90 ,
109
109
page_generator : None | PageGenerator | str | Path = None ,
110
110
plotlyjs : str | Path | None = None , # TODO(AJP): with page generator
111
111
mathjax : str | Path | None = None , # TODO(AJP): with page generator?
112
- stepper : bool = False ,
113
112
** kwargs : Any ,
114
113
) -> None :
115
114
"""
@@ -142,17 +141,12 @@ def __init__( # noqa: PLR0913
142
141
disabled. Defaults to None- which means to use version 2.35 via
143
142
CDN.
144
143
145
- stepper (bool, optional):
146
- A diagnostic tool that will ask the user to press enter between
147
- rendering each image. Only useful if also used with
148
- `headless=False`. See below. Defaults to False.
149
-
150
144
**kwargs (Any):
151
145
Additional keyword arguments passed through to the underlying
152
- Choreographer.browser constructor. Notable options include,
146
+ Choreographer.browser constructor. Notable options include
153
147
`headless=False` (show window), `enable_sandbox=True` (turn on
154
148
sandboxing), and `enable_gpu=True` which will allow use of the
155
- GPU. The defaults for these options are True, False, False
149
+ GPU. The defaults for these options are True, False, and False
156
150
respectively.
157
151
158
152
"""
@@ -166,22 +160,21 @@ def __init__( # noqa: PLR0913
166
160
page = page_generator
167
161
self ._timeout = timeout
168
162
self ._n = n
169
- self ._stepper = stepper
170
163
self ._plotlyjs = plotlyjs
171
164
self ._mathjax = mathjax
172
165
173
166
# Diagnostic
174
167
_logger .debug (f"Timeout: { self ._timeout } " )
175
168
176
169
try :
177
- super ().__init__ (* args , * *kwargs )
170
+ super ().__init__ (** kwargs )
178
171
except ChromeNotFoundError :
179
172
raise ChromeNotFoundError (
180
173
"Kaleido v1 and later requires Chrome to be installed. "
181
174
"To install Chrome, use the CLI command `kaleido_get_chrome`, "
182
175
"or from Python, use either `await kaleido.get_chrome()` "
183
176
"or `kaleido.get_chrome_sync()`." ,
184
- ) from None # overwriting the error entirely.
177
+ ) from None # overwriting the error entirely. (diagnostics)
185
178
186
179
# save this for open() because it requires close()
187
180
self ._saved_page_arg = page
@@ -226,8 +219,7 @@ async def _conform_tabs(self, tabs: Listish[choreo.Tab] | None = None) -> None:
226
219
_logger .debug2 (f"Subscribing * to tab: { tab } ." )
227
220
tab .subscribe ("*" , _utils .event_printer (f"tab-{ i !s} : Event Dump:" ))
228
221
229
- kaleido_tabs = [_KaleidoTab (tab , _stepper = self ._stepper ) for tab in tabs ]
230
- # TODO(AJP): why doesn't stepper use the global?
222
+ kaleido_tabs = [_KaleidoTab (tab ) for tab in tabs ]
231
223
232
224
await asyncio .gather (* (tab .navigate (self ._index ) for tab in kaleido_tabs ))
233
225
@@ -308,10 +300,7 @@ async def _return_kaleido_tab(self, tab: _KaleidoTab) -> None:
308
300
await self .tabs_ready .put (tab )
309
301
_logger .debug (f"{ tab .tab .target_id [:4 ]} put back." )
310
302
311
- #### WE'RE HERE
312
-
313
- # this task must calculate full_path before it
314
- # awaits, ie yielding control.
303
+ # _retuner_task MUST calculate full_path before it awaits
315
304
async def _render_task (
316
305
self ,
317
306
fig_arg : FigureDict ,
@@ -363,6 +352,7 @@ async def write_fig_from_object(
363
352
* ,
364
353
cancel_on_error : bool = False ,
365
354
_write : Literal [False ],
355
+ stepper : bool = False ,
366
356
) -> bytes : ...
367
357
368
358
@overload
@@ -372,6 +362,7 @@ async def write_fig_from_object(
372
362
* ,
373
363
cancel_on_error : Literal [True ],
374
364
_write : Literal [True ] = True ,
365
+ stepper : bool = False ,
375
366
) -> None : ...
376
367
377
368
@overload
@@ -381,6 +372,7 @@ async def write_fig_from_object(
381
372
* ,
382
373
cancel_on_error : Literal [False ] = False ,
383
374
_write : Literal [True ] = True ,
375
+ stepper : bool = False ,
384
376
) -> tuple [Exception ]: ...
385
377
386
378
@overload
@@ -390,6 +382,7 @@ async def write_fig_from_object(
390
382
* ,
391
383
cancel_on_error : bool ,
392
384
_write : Literal [True ] = True ,
385
+ stepper : bool = False ,
393
386
) -> tuple [Exception ] | None : ...
394
387
395
388
async def write_fig_from_object (
@@ -398,6 +391,7 @@ async def write_fig_from_object(
398
391
* ,
399
392
cancel_on_error = False ,
400
393
_write : bool = True , # backwards compatibility!
394
+ stepper : bool = False ,
401
395
) -> None | bytes | tuple [Exception ]:
402
396
"""Temp."""
403
397
if not _write :
@@ -418,6 +412,7 @@ async def write_fig_from_object(
418
412
fig_arg = fig_arg ,
419
413
topojson = fig_arg .get ("topojson" ),
420
414
_write = _write , # backwards compatibility
415
+ stepper = stepper ,
421
416
),
422
417
)
423
418
tasks .add (t )
@@ -438,14 +433,15 @@ async def write_fig_from_object(
438
433
if main_task :
439
434
self ._main_render_coroutines .remove (main_task )
440
435
441
- async def write_fig (
436
+ async def write_fig ( # noqa: PLR0913
442
437
self ,
443
438
fig : _fig_tools .Figurish ,
444
439
path : None | Path | str = None ,
445
440
opts : None | _fig_tools .LayoutOpts = None ,
446
441
* ,
447
442
topojson : str | None = None ,
448
443
cancel_on_error : bool = False ,
444
+ stepper : bool = False ,
449
445
) -> tuple [Exception ] | None :
450
446
"""Temp."""
451
447
if _fig_tools .is_figurish (fig ) or not isinstance (
@@ -467,6 +463,7 @@ async def _temp_generator() -> AsyncGenerator[FigureDict, None]:
467
463
return await self .write_fig_from_object (
468
464
fig_dicts = generator ,
469
465
cancel_on_error = cancel_on_error ,
466
+ stepper = stepper ,
470
467
)
471
468
472
469
async def calc_fig (
@@ -475,6 +472,7 @@ async def calc_fig(
475
472
opts : None | _fig_tools .LayoutOpts = None ,
476
473
* ,
477
474
topojson : str | None = None ,
475
+ stepper : bool = False ,
478
476
) -> bytes :
479
477
"""Temp."""
480
478
@@ -489,4 +487,5 @@ async def _temp_generator():
489
487
fig_dicts = _temp_generator (),
490
488
cancel_on_error = True ,
491
489
_write = False ,
490
+ stepper = stepper ,
492
491
)
0 commit comments