Skip to content

Commit 5cad40c

Browse files
ayjaytemilykl
andauthored
Andrew/verbose error (#374)
* Improve errors and typechecking in toolls. * Add some improved typing. * Move from closure type thread args to explicit * Fix typing issues in fig tools. * Fix typing in _mocker. * Add new sync server to separate file. * Fix API name. * CHANGELOG.txt * Fix API typo. * Fix bad access. * Fix some typing stuff. * Add typing extensions to dev block. * Change error wording. * Remove unnecessary word in changelog. * Fix all to reflect names. * Check for no tabs before running. * Fix up result checking in task * Bump choreographer version * Changelog * Update src/py/kaleido/kaleido.py Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com> * Eliminate dev comments. --------- Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com>
1 parent fc78f04 commit 5cad40c

4 files changed

Lines changed: 545 additions & 213 deletions

File tree

src/py/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Improve verbosity of errors when starting kaleido improperly
12
- Add new api functions start/stop_sync_server
23
v1.0.0
34
- Add warning if using incompatible Plotly version

src/py/kaleido/kaleido.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def __init__(self, *args, **kwargs): # noqa: D417 no args/kwargs in description
102102
self._background_render_tasks = set()
103103
self._main_tasks = set()
104104
self._tabs_ready = asyncio.Queue(maxsize=0)
105+
self._total_tabs = 0
105106
self._tmp_dir = None
106107

107108
page = kwargs.pop("page_generator", None)
@@ -165,6 +166,7 @@ async def _conform_tabs(self, tabs=None) -> None:
165166
_logger.info("All navigates done, putting them all in queue.")
166167
for tab in kaleido_tabs:
167168
await self._tabs_ready.put(tab)
169+
self._total_tabs = len(kaleido_tabs)
168170
_logger.debug("Tabs fully navigated/enabled/ready")
169171

170172
async def populate_targets(self) -> None:
@@ -216,6 +218,10 @@ async def _get_kaleido_tab(self) -> _KaleidoTab:
216218
217219
"""
218220
_logger.info(f"Getting tab from queue (has {self._tabs_ready.qsize()})")
221+
if not self._total_tabs:
222+
raise RuntimeError(
223+
"Before generating a figure, you must await `k.open()`.",
224+
)
219225
tab = await self._tabs_ready.get()
220226
_logger.info(f"Got {tab.tab.target_id[:4]}")
221227
return tab
@@ -248,9 +254,12 @@ def _clean_tab_return_task(self, main_task, task):
248254
raise e
249255

250256
def _check_render_task(self, name, tab, main_task, error_log, task):
251-
if e := task.exception():
252-
if isinstance(e, asyncio.CancelledError):
253-
_logger.info(f"Something cancelled {name}.")
257+
if task.cancelled():
258+
_logger.info(f"Something cancelled {name}.")
259+
error_log.append(
260+
ErrorEntry(name, asyncio.CancelledError, tab.javascript_log),
261+
)
262+
elif e := task.exception():
254263
_logger.error(f"Render Task Error In {name}- ", exc_info=e)
255264
if isinstance(e, (asyncio.TimeoutError, TimeoutError)) and error_log:
256265
error_log.append(

src/py/pyproject.toml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ maintainers = [
2626
{name = "Andrew Pikul", email = "ajpikul@gmail.com"},
2727
]
2828
dependencies = [
29-
"choreographer>=1.0.5",
29+
"choreographer>=1.0.7",
3030
"logistro>=1.0.8",
3131
"orjson>=3.10.15",
3232
"packaging",
@@ -54,17 +54,6 @@ dev = [
5454
"typing-extensions>=4.12.2",
5555
]
5656

57-
#docs = [
58-
# "mkquixote @ git+ssh://git@github.com/geopozo/mkquixote; python_version>= '3.11'",
59-
# "mkdocs>=1.6.1",
60-
# "mkdocs-material>=9.5.49",
61-
#]
62-
63-
#[tool.uv.sources]
64-
#mkquixote = { path = "../../../mkquixote", editable = true }
65-
#choreographer = { path = "../../../devtools_protocol", editable = true }
66-
#logistro = { path = "../../../logistro", editable = true }
67-
6857
[tool.ruff.lint]
6958
select = ["ALL"]
7059
ignore = [

0 commit comments

Comments
 (0)