Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use skore-ui widgets in notebooks #926

Merged
merged 18 commits into from
Dec 20, 2024
Merged

feat: Use skore-ui widgets in notebooks #926

merged 18 commits into from
Dec 20, 2024

Conversation

rouk1
Copy link
Contributor

@rouk1 rouk1 commented Dec 12, 2024

This PR makes our existing widgets available in notebooks.

UI preview

vscode notebooks

widgets.mp4

JupyterLab

jupyter-widgets.mp4

Warning

For now Marimo is not supported as it requires to use Anywidget, I'd like to split this rework in another PR to merge this then iterate.
My Hex demo is expired so I could not test it : (

Implementation choices/details front

  • all body/root level CSS rules now use a class (.skore-ui) to avoid style leak
  • main.ts now instantiate it's main app dynamically according to it's container name
  • router.ts does not instantiate the browser history as a side effect (this feature is blocked by vs code)
  • build process now inlines fonts as base64 URLs
  • build process now output bundles with predictible names

Implementation choices/details back

  • items now implement a get_serializable_dict method that returns a JSON serializable dict
  • abstract item class now implements a _repr_mimebundle_ method that returns supported media types (for now HTML only)
  • API routes has been refactored to use the new get_serializable_dict method

@thomass-dev thomass-dev changed the title Notebook widgets : to discuss feat: use widgets in notebooks - PoC Dec 12, 2024
@rouk1 rouk1 changed the title feat: use widgets in notebooks - PoC feat: Use skore-ui widgets in notebooks Dec 16, 2024
Copy link
Contributor

github-actions bot commented Dec 16, 2024

Coverage Report for ./skore-ui

Status Category Percentage Covered / Total
🔵 Lines 85.24% 3305 / 3877
🔵 Statements 85.24% 3305 / 3877
🔵 Functions 45.8% 60 / 131
🔵 Branches 82.19% 240 / 292
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
skore-ui/src/StandaloneWidget.vue 0% 0% 0% 0% 1-31
skore-ui/src/main.ts 0% 0% 0% 0% 1-26
skore-ui/src/router.ts 87.8% 100% 0% 87.8% 43-47
skore-ui/src/components/DataFrameWidget.vue 85.82% 81.25% 33.33% 85.82% 28-29, 45, 68-69, 79-88, 93-96, 156
skore-ui/src/components/LoadingBars.vue 0% 0% 0% 0% 1-2
skore-ui/src/components/PlotlyWidget.vue 100% 100% 100% 100%
skore-ui/src/components/VegaWidget.vue 100% 100% 100% 100%
Generated in workflow #1674 for commit 96c751a by the Vitest Coverage Report Action

Copy link
Contributor

github-actions bot commented Dec 16, 2024

Coverage

pytest coverage report
FileStmtsMissCoverMissing
src/skore
   __init__.py180100% 
   __main__.py811 80%
   exceptions.py40100% 
src/skore/cli
   __init__.py80100% 
   cli.py320100% 
   launch_dashboard.py22120 42%
   quickstart_command.py1220 83%
src/skore/item
   __init__.py210100% 
   cross_validation_item.py125112 92%
   item.py41130 68%
   item_repository.py4221 93%
   media_item.py7041 94%
   numpy_array_item.py2511 93%
   pandas_dataframe_item.py3411 95%
   pandas_series_item.py3411 95%
   polars_dataframe_item.py3211 94%
   polars_series_item.py2711 94%
   primitive_item.py2721 92%
   sklearn_base_estimator_item.py3311 95%
   skrub_table_report_item.py1011 86%
src/skore/persistence
   __init__.py00100% 
   abstract_storage.py2210 95%
   disk_cache_storage.py3311 95%
   in_memory_storage.py200100% 
src/skore/project
   __init__.py40100% 
   create.py5080 88%
   load.py2330 89%
   project.py6244 91%
src/skore/sklearn
   __init__.py30100% 
   find_ml_task.py1923 85%
   types.py20100% 
src/skore/sklearn/cross_validation
   __init__.py20100% 
   cross_validation_helpers.py4141 89%
   cross_validation_reporter.py2811 94%
   plot.py3814 90%
src/skore/sklearn/train_test_split
   __init__.py00100% 
   train_test_split.py3421 94%
src/skore/sklearn/train_test_split/warning
   __init__.py80100% 
   high_class_imbalance_too_few_examples_warning.py1732 78%
   high_class_imbalance_warning.py1821 88%
   random_state_unset_warning.py1111 87%
   shuffle_true_warning.py901 91%
   stratify_is_set_warning.py1111 87%
   time_based_column_warning.py2212 89%
   train_test_split_warning.py510 80%
src/skore/ui
   __init__.py00100% 
   app.py2552 71%
   dependencies.py710 86%
   project_routes.py500100% 
src/skore/utils
   __init__.py00100% 
   _show_versions.py290100% 
src/skore/view
   __init__.py00100% 
   view.py50100% 
   view_repository.py1621 83%
TOTAL12399890% 

Tests Skipped Failures Errors Time
187 0 💤 0 ❌ 0 🔥 43.082s ⏱️

@rouk1 rouk1 marked this pull request as ready for review December 17, 2024 10:00
@tuscland
Copy link
Member

Ping @koaning

@koaning
Copy link
Contributor

koaning commented Dec 17, 2024

If we just support Jupyter for now that sure seems fine. While I am a fan of Marimo I would argue that this is always possible as an add-on feature later.

Looking at the video though ... it seems that the altair chart does not show the axes? @rouk1 might that be a bug?

@rouk1
Copy link
Contributor Author

rouk1 commented Dec 17, 2024

Looking at the video though ... it seems that the altair chart does not show the axes? @rouk1 might that be a bug?

Nice catch I need to look at this.

skore/src/skore/item/item.py Outdated Show resolved Hide resolved
skore/src/skore/item/item.py Outdated Show resolved Hide resolved
skore/src/skore/item/item.py Outdated Show resolved Hide resolved
skore/src/skore/item/media_item.py Outdated Show resolved Hide resolved
skore/src/skore/ui/project_routes.py Outdated Show resolved Hide resolved
skore/src/skore/ui/project_routes.py Outdated Show resolved Hide resolved
skore/src/skore/ui/project_routes.py Outdated Show resolved Hide resolved
skore/src/skore/item/cross_validation_item.py Outdated Show resolved Hide resolved
skore-ui/src/router.ts Outdated Show resolved Hide resolved
skore/src/skore/item/cross_validation_item.py Outdated Show resolved Hide resolved
@rouk1 rouk1 mentioned this pull request Dec 17, 2024
@rouk1
Copy link
Contributor Author

rouk1 commented Dec 18, 2024

Looking at the video though ... it seems that the altair chart does not show the axes? @rouk1 might that be a bug?

@koaning bug has been fixed !
Screenshot 2024-12-18 at 18 05 49

@rouk1 rouk1 marked this pull request as draft December 18, 2024 17:14
@rouk1 rouk1 marked this pull request as ready for review December 18, 2024 17:47
thomass-dev pushed a commit that referenced this pull request Dec 19, 2024
This PR introduces a theme toggle that overwrites user preferences.
Depends on #926 that introduces class based theme management.
@rouk1 rouk1 mentioned this pull request Dec 19, 2024
@thomass-dev thomass-dev merged commit 6b58cf3 into main Dec 20, 2024
21 checks passed
@thomass-dev thomass-dev deleted the notebook-widgets branch December 20, 2024 09:08
thomass-dev pushed a commit that referenced this pull request Dec 20, 2024
This PR introduces a theme toggle that overwrites user preferences.
Depends on #926 that introduces class based theme management.

# UI preview


https://github.com/user-attachments/assets/5a220d2b-d201-4787-98a2-db0b5c9917f7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants