Skip to content

feat(packaging): include managed-spark-cell-monitoring in interactive extra - #246

Merged
dborowitz merged 1 commit into
mainfrom
dborowitz-cell-monitoring-dep
Dec 2, 2026
Merged

dborowitz merged 1 commit into
mainfrom
dborowitz-cell-monitoring-dep

Conversation

@dborowitz

@dborowitz dborowitz commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add managed-spark-cell-monitoring[connect]>=1.1.0,<2.0 to extras_require["interactive"] in setup.py so installing google-cloud-spark-connect[client,interactive] (or [spark,interactive] / [interactive]) automatically installs and enables %cellmonitor and Spark Connect cell monitoring in IPython/Jupyter notebooks.
  • Fix two edge cases in google/cloud/managed_spark_connect/_ipython.py discovered when testing with managed-spark-cell-monitoring==1.1.0:
    • Magic package prefix on unload: managed-spark-cell-monitoring defines %cellmonitor in managed_spark_cell_monitoring rather than managed_spark_cell_monitoring.spark_connect, so _unload_extras_for_shell previously failed _is_from_module(..., ext_name) and left %cellmonitor behind when disabling ManagedSparkConnect.enable_extras. _EXTRAS_EXTENSIONS now specifies the magic package prefix (managed_spark_cell_monitoring) so disable/re-enable toggles cleanly.
    • Hook attachment when %cellmonitor already exists: _is_extension_loaded previously skipped loading an extension if all of its magics were already registered. That shortcut only makes sense for pure-magic extensions (managed_spark_magics), not managed_spark_cell_monitoring.spark_connect, which must still load to attach SparkConnectCellController cell hooks when %cellmonitor was already registered (for example by classic managed_spark_cell_monitoring or a user override). _EXTRAS_EXTENSIONS now marks magics_only=False for managed_spark_cell_monitoring.spark_connect while preserving any pre-existing %cellmonitor magic.
  • Update README.md and DEVELOPING.md to reflect that managed-spark-cell-monitoring / %cellmonitor is included in [interactive].
  • Expand unit tests in tests/unit/test_init.py and tests/unit/test_cell_monitoring.py covering dependency availability, import order (cellmonitor_load_ext_first), pre-existing %cellmonitor, user-overwritten %cellmonitor across disable/re-enable, and pre-loaded %load_ext managed_spark_cell_monitoring.spark_connect.

Testing

  • Built wheel and installed google_cloud_spark_connect-2.3.1-py3-none-any.whl[interactive,client] into a fresh Python 3.13 venv (pip check clean; verified auto-load, %cellmonitor, ipykernel, and enable_extras toggling)
  • Verified end-to-end in a VS Code Jupyter notebook against Serverless Spark runtime 4.0 (Spark 4.2.0): importing ManagedSparkSession auto-loaded %cellmonitor without manual %load_ext and rendered live ManagedSparkCellWidget progress

Screenshots

Auto-enabled extension on load:
Auto-enabled extension on load

Clicking through different widget features:
live executor chart
live job table
completed output

@dborowitz
dborowitz requested a review from tim-u December 2, 2026 05:40

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates managed-spark-cell-monitoring directly into the interactive extra dependencies, making %cellmonitor available automatically. It updates the IPython extension loading logic in _ipython.py to support hook-attaching extensions (like cell monitoring) even when their magics are already present, and adds comprehensive unit tests to verify loading, unloading, and coexistence behaviors. I have no feedback to provide as there are no review comments.

@ptch314
ptch314 self-requested a review December 2, 2026 16:35
@dborowitz
dborowitz merged commit f8d5f6e into main Dec 2, 2026
44 of 47 checks passed
@dborowitz
dborowitz deleted the dborowitz-cell-monitoring-dep branch December 2, 2026 16:42
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.

2 participants