Conversation
… example In a Jupyter kernel, dask's progress() draws an ipywidgets bar. ipywidgets is not a PyHealth dependency, so building any dataset's event cache in a notebook without it (e.g. a plain venv kernel in VS Code or Cursor) failed with ModuleNotFoundError and deleted the half-built cache. - base_dataset: pass notebook=False to dask's progress() when ipywidgets is not importable, so dask falls back to its text bar. - In notebooks (threaded workers), wait 0.3 s after the compute so closing the cluster does not race dask's 100 ms progress feed and log a spurious CancelledError traceback. - tests: simulate a kernel without ipywidgets; the build succeeds and the scheduler logs no errors (fails on master with ModuleNotFoundError). - examples/datasets_overview.ipynb: the synthetic-samples cell called SampleDataset(samples=...), which no longer exists; use create_sample_dataset. Its stale error output is cleared. - docs/install.rst: note on notebooks and the optional ipywidgets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a dataset builds its event cache in a Jupyter kernel,
BaseDatasetcalls dask'sprogress(). In a kernel, dask draws an ipywidgets progress bar, butipywidgetsis not a PyHealth dependency. In a notebook without it, such as a plain venv kernel in VS Code or Cursor, building any dataset fails:The same unguarded call is in the 2.0.2 release.
Changes
base_dataset.py:ipywidgetsisn't importable, passnotebook=Falseto dask'sprogress(), so dask falls back to its text bar. Withipywidgetsinstalled, behaviour is unchanged.CancelledErrortraceback, even though the data was written correctly. It's a pragmatic workaround and only runs in notebooks; happy to replace it if there's a cleaner hook.tests/core/test_base_dataset.py: simulates a kernel withoutipywidgets, as in Jupyter (threaded workers, kernel detection on). It asserts that the build succeeds and that the dask scheduler logs no errors. The test fails on master with theModuleNotFoundErrorabove and passes with this change.examples/datasets_overview.ipynb: the synthetic-samples cell calledSampleDataset(samples=…). That constructor no longer exists; the committed output already showed an error, and running it today raisesTypeError: … missing … 'path'. It now usescreate_sample_dataset(...), and its stale error output is cleared. The new cell runs and printsLoaded 2 synthetic samples.No other cell changed.docs/install.rst: a note on notebooks and the optionalipywidgets, under Platform-Specific Notes.Verification
tools/check_pr_rules.py: all rules pass.test_medcode_icd_mappings(medcode: ICD-9 <-> ICD-10 translation and grouper vocabularies via icd-mappings #1257), which fail locally only becauseicd-mappingswasn't installed in my older environment. With it installed, those tests andtest_base_datasetpass (47/47).🤖 Generated with Claude Code