Skip to content

Conversation

@hc2p
Copy link

@hc2p hc2p commented Nov 14, 2025

Summary

Adds opt-in debug logging configuration for the Jupyter server to help troubleshoot kernel communication and server issues without impacting production performance.

Changes

  • Conditional Application.log_level: Now defaults to INFO (20) and only enables DEBUG (10) when DEEPNOTE_ENABLE_DEBUG_LOGGING=true
  • Enhanced logging configuration: Adds configurable log levels for tornado, jupyter_server, and jupyter_client
  • ZMQ message debugging: Adds opt-in Session.debug via DEEPNOTE_ENABLE_ZMQ_DEBUG for detailed ZMQ message flow logging
  • Documentation: Added comprehensive environment variable documentation to README.md

Environment Variables

DEEPNOTE_ENABLE_DEBUG_LOGGING

  • Default: false (INFO level)
  • When enabled: Enables DEBUG-level logs for tornado, jupyter_server, and jupyter_client
  • Use case: Troubleshooting server-related issues

DEEPNOTE_ENABLE_ZMQ_DEBUG

  • Default: false
  • When enabled: Logs all ZMQ messages between Jupyter server and kernel
  • Use case: Diagnosing stuck execution or kernel communication issues

Production Safety

  • Both features are opt-in via environment variables
  • Defaults to INFO level logging (no performance impact)
  • Debug logging only enabled when explicitly requested
  • Prevents accidental verbose logging in production

Testing

To test debug logging:
```bash
DEEPNOTE_ENABLE_DEBUG_LOGGING=true deepnote-toolkit server
```

To test ZMQ debugging:
```bash
DEEPNOTE_ENABLE_ZMQ_DEBUG=true deepnote-toolkit server
```

Related

This PR provides the logging foundation for the execution tracking PR (coming next) which will help debug stuck executions.

Files Modified

  • `deepnote_core/resources/jupyter/jupyter_server_config.py`: Added conditional logging configuration
  • `README.md`: Added environment variable documentation

Checklist

  • Code follows project style guidelines
  • Pre-commit hooks pass (flake8, isort)
  • Documentation updated
  • Production-safe (opt-in, defaults to INFO level)
  • No performance impact when disabled

Summary by CodeRabbit

  • Documentation

    • Updated README with Environment Variables subsection describing new debugging and logging controls, including configuration examples and performance notes.
  • New Features

    • Added environment variable controls to enable debug logging with configurable log levels.
    • Added optional ZMQ debugging capability via environment variable configuration.

Adds configurable debug logging to help troubleshoot kernel communication
and server issues without impacting production performance.

Changes:
- Add environment variable-based debug logging configuration
- Make Application.log_level conditional (DEBUG or INFO)
- Add enhanced logging_config for tornado, jupyter_server, and jupyter_client
- Add opt-in Session.debug for ZMQ message flow logging
- Add environment variable documentation to README.md

All features are opt-in via environment variables:
- DEEPNOTE_ENABLE_DEBUG_LOGGING: Enables DEBUG-level logs (default: false/INFO)
- DEEPNOTE_ENABLE_ZMQ_DEBUG: Enables ZMQ message debugging (default: false)

This ensures production-safe defaults with no performance impact when disabled.
@hc2p hc2p requested a review from a team as a code owner November 14, 2025 19:10
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

📝 Walkthrough

Walkthrough

Documentation and configuration for environment-driven debug logging are added. The README documents two new environment variables: DEEPNOTE_ENABLE_DEBUG_LOGGING and DEEPNOTE_ENABLE_ZMQ_DEBUG. The Jupyter server config file reads these variables and conditionally sets the application log level to DEBUG (10) or INFO (20), applying this level to tornado.access, jupyter_server.serverapp, and jupyter_client.session loggers. Optional ZMQ session debugging is enabled when the corresponding environment variable is true.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding opt-in debug logging configuration for Jupyter server, which aligns with both file modifications and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

📦 Python package built successfully!

  • Version: 1.1.3.dev4+b762828
  • Wheel: deepnote_toolkit-1.1.3.dev4+b762828-py3-none-any.whl
  • Install:
    pip install "deepnote-toolkit @ https://deepnote-staging-runtime-artifactory.s3.amazonaws.com/deepnote-toolkit-packages/1.1.3.dev4%2Bb762828/deepnote_toolkit-1.1.3.dev4%2Bb762828-py3-none-any.whl"

@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.88%. Comparing base (9994c8f) to head (153ce69).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #31   +/-   ##
=======================================
  Coverage   72.88%   72.88%           
=======================================
  Files          93       93           
  Lines        5142     5142           
  Branches      754      754           
=======================================
  Hits         3748     3748           
  Misses       1150     1150           
  Partials      244      244           
Flag Coverage Δ
combined 72.88% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9994c8f and 153ce69.

📒 Files selected for processing (2)
  • README.md (1 hunks)
  • deepnote_core/resources/jupyter/jupyter_server_config.py (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Build and push artifacts for Python 3.12
  • GitHub Check: Test - Python 3.13
  • GitHub Check: Test - Python 3.11
  • GitHub Check: Build and push artifacts for Python 3.11
  • GitHub Check: Build and push artifacts for Python 3.13
  • GitHub Check: Test - Python 3.10
  • GitHub Check: Build and push artifacts for Python 3.10
  • GitHub Check: Build and push artifacts for Python 3.9
  • GitHub Check: Typecheck - 3.9
🔇 Additional comments (3)
deepnote_core/resources/jupyter/jupyter_server_config.py (2)

13-17: LGTM!

Environment variable parsing and log level assignment are correct.


423-431: LGTM!

Logging configuration correctly uses the string log_level variable and targets appropriate loggers for Jupyter debugging.

README.md (1)

66-90: LGTM!

Documentation accurately describes the debug logging features, defaults, and usage. Examples are correct and the performance warning is appropriate.

Comment on lines +35 to +36
# Conditional based on DEEPNOTE_ENABLE_DEBUG_LOGGING environment variable
c.Application.log_level = 10 if debug_logging_enabled else 20 # DEBUG or INFO
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Inconsistency: log_level variable defined as string but integers used here.

Line 17 defines log_level = "DEBUG" if debug_logging_enabled else "INFO" (string), but this line uses integers directly. Either use the string variable consistently or define an integer variable.

Apply this diff for consistency:

-c.Application.log_level = 10 if debug_logging_enabled else 20  # DEBUG or INFO
+c.Application.log_level = log_level
🤖 Prompt for AI Agents
In deepnote_core/resources/jupyter/jupyter_server_config.py around lines 35-36,
the code sets c.Application.log_level using integer literals while earlier (line
17) a string variable log_level = "DEBUG" if debug_logging_enabled else "INFO"
is defined; update this line to use the existing log_level variable consistently
by mapping the string to the corresponding integer (e.g., DEBUG->10, INFO->20)
or change the earlier variable to an integer value and use that variable here so
both places use the same type and value source.

Comment on lines +837 to +840
# Enable ZMQ message flow debugging for troubleshooting kernel communication
# Set DEEPNOTE_ENABLE_ZMQ_DEBUG=true to enable detailed ZMQ message logging
if os.getenv("DEEPNOTE_ENABLE_ZMQ_DEBUG", "false").lower() == "true":
c.Session.debug = True
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Optional: Extract to variable for consistency.

This works correctly, but for consistency with lines 16-17, consider extracting the environment check to a variable.

 # Debug output in the Session
 #  Default: False
-# Enable ZMQ message flow debugging for troubleshooting kernel communication
-# Set DEEPNOTE_ENABLE_ZMQ_DEBUG=true to enable detailed ZMQ message logging
-if os.getenv("DEEPNOTE_ENABLE_ZMQ_DEBUG", "false").lower() == "true":
-    c.Session.debug = True
+# Enable ZMQ message flow debugging for troubleshooting kernel communication
+# Set DEEPNOTE_ENABLE_ZMQ_DEBUG=true to enable detailed ZMQ message logging
+zmq_debug_enabled = os.getenv("DEEPNOTE_ENABLE_ZMQ_DEBUG", "false").lower() == "true"
+if zmq_debug_enabled:
+    c.Session.debug = True

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In deepnote_core/resources/jupyter/jupyter_server_config.py around lines 837 to
840, extract the environment check into a named variable (e.g.,
enable_zmq_debug) for consistency with the earlier pattern (lines 16-17),
assigning it from os.getenv("DEEPNOTE_ENABLE_ZMQ_DEBUG", "false").lower() ==
"true", then use that variable in the if statement to set c.Session.debug =
True; keep the existing behavior and value comparison but centralize the env
read into the variable.

@deepnote-bot
Copy link

🚀 Review App Deployment Started

📝 Description 🌐 Link / Info
🌍 Review application ra-31
🔑 Sign-in URL Click to sign-in
📊 Application logs View logs
🔄 Actions Click to redeploy
🚀 ArgoCD deployment View deployment
Last deployed 2025-11-14 19:18:30 (UTC)
📜 Deployed commit afabcd53851702ab6ddc42b9bd082e3d772a0221
🛠️ Toolkit version b762828

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.

3 participants