Repository navigation
HACK: Vibe coded Cursor agent support, support our blocks and allows full programmatic execution for any use case - #134
jamesbhobbs wants to merge 8 commits into
Conversation
📝 WalkthroughWalkthroughThis PR introduces a complete programmatic execution system for Deepnote notebooks. It adds execution scripts (shell and Python), comprehensive documentation for workflows and features, configuration updates, and example notebooks demonstrating batch processing, testing, and AI agent workflows. The system enables executing .deepnote YAML files against a Jupyter kernel with auto-dependency detection, input widget handling, and structured output capture. Sequence Diagram(s)sequenceDiagram
participant User
participant run-deepnote.sh
participant Toolkit Server
participant Jupyter Kernel
participant execute-deepnote.py
participant .deepnote File
User->>run-deepnote.sh: Execute notebook
run-deepnote.sh->>Jupyter Kernel: Check for active kernel
alt No kernel running
run-deepnote.sh->>Toolkit Server: Start server
Toolkit Server->>Jupyter Kernel: Initialize kernel
Toolkit Server-->>run-deepnote.sh: Kernel ready
end
run-deepnote.sh->>execute-deepnote.py: Pass notebook path + kernel-id
execute-deepnote.py->>+.deepnote File: Parse YAML structure
.deepnote File-->>-execute-deepnote.py: Extract blocks & metadata
execute-deepnote.py->>execute-deepnote.py: Auto-detect dependencies<br/>Initialize input widgets
execute-deepnote.py->>Jupyter Kernel: Install requirements
loop For each block
execute-deepnote.py->>Jupyter Kernel: Execute code/SQL/chart block
Jupyter Kernel-->>execute-deepnote.py: Output + errors
end
execute-deepnote.py-->>User: Execution summary + results
Possibly related PRs
Suggested reviewers
Pre-merge checks✅ Passed checks (3 passed)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #134 +/- ##
=======================================
Coverage 95.31% 95.31%
=======================================
Files 26 26
Lines 726 726
Branches 207 207
=======================================
Hits 692 692
Misses 34 34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 20
📜 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.
📒 Files selected for processing (14)
.cursorrules(1 hunks).gitignore(1 hunks).vscode/settings.json(1 hunks)PROGRAMMATIC_EXECUTION.md(1 hunks)README.md(1 hunks)docs/ai-agent-workflow.md(1 hunks)examples/demos/DEVELOPMENT_WORKFLOW.md(1 hunks)examples/demos/README.md(1 hunks)examples/demos/sales_analytics_dashboard.deepnote(1 hunks)examples/test_automation.deepnote(1 hunks)examples/test_deepnote_features.deepnote(1 hunks)scripts/README.md(1 hunks)scripts/execute-deepnote.py(1 hunks)scripts/run-deepnote.sh(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{md,yml,yaml}
📄 CodeRabbit inference engine (CLAUDE.md)
Use Prettier formatting for Markdown and YAML files
Files:
examples/demos/DEVELOPMENT_WORKFLOW.mddocs/ai-agent-workflow.mdscripts/README.mdexamples/demos/README.mdREADME.mdPROGRAMMATIC_EXECUTION.md
🪛 markdownlint-cli2 (0.18.1)
scripts/README.md
60-60: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
PROGRAMMATIC_EXECUTION.md
112-112: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
135-135: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🪛 Ruff (0.14.3)
scripts/execute-deepnote.py
198-198: PEP 484 prohibits implicit Optional
Convert to T | None
(RUF013)
212-212: Unnecessary mode argument
Remove mode argument
(UP015)
334-334: Unnecessary mode argument
Remove mode argument
(UP015)
378-378: f-string without any placeholders
Remove extraneous f prefix
(F541)
412-412: Use explicit conversion flag
Replace with conversion flag
(RUF010)
419-419: Do not use bare except
(E722)
432-432: Use explicit conversion flag
Replace with conversion flag
(RUF010)
461-461: Do not catch blind exception: Exception
(BLE001)
478-478: Use explicit conversion flag
Replace with conversion flag
(RUF010)
513-513: Use explicit conversion flag
Replace with conversion flag
(RUF010)
516-516: Use explicit conversion flag
Replace with conversion flag
(RUF010)
522-522: Use explicit conversion flag
Replace with conversion flag
(RUF010)
545-545: Do not catch blind exception: Exception
(BLE001)
545-545: Local variable e is assigned to but never used
Remove assignment to unused variable e
(F841)
549-549: Use explicit conversion flag
Replace with conversion flag
(RUF010)
551-551: Use explicit conversion flag
Replace with conversion flag
(RUF010)
635-635: Do not catch blind exception: Exception
(BLE001)
647-647: f-string without any placeholders
Remove extraneous f prefix
(F541)
692-692: Use explicit conversion flag
Replace with conversion flag
(RUF010)
719-719: Use explicit conversion flag
Replace with conversion flag
(RUF010)
720-720: Use explicit conversion flag
Replace with conversion flag
(RUF010)
764-764: Do not catch blind exception: Exception
(BLE001)
776-776: f-string without any placeholders
Remove extraneous f prefix
(F541)
795-795: Use explicit conversion flag
Replace with conversion flag
(RUF010)
796-796: Use explicit conversion flag
Replace with conversion flag
(RUF010)
807-807: Local variable msg_id is assigned to but never used
Remove assignment to unused variable msg_id
(F841)
830-830: f-string without any placeholders
Remove extraneous f prefix
(F541)
847-847: Do not catch blind exception: Exception
(BLE001)
858-858: Local variable total_blocks is assigned to but never used
Remove assignment to unused variable total_blocks
(F841)
🪛 Shellcheck (0.11.0)
scripts/run-deepnote.sh
[style] 22-22: Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
(SC2116)
[info] 22-22: Double quote to prevent globbing and word splitting.
(SC2086)
[info] 38-38: Double quote to prevent globbing and word splitting.
(SC2086)
[warning] 53-53: i appears unused. Verify use (or export if used externally).
(SC2034)
[error] 54-54: -f doesn't work with globs. Use a for loop.
(SC2144)
🔇 Additional comments (15)
.vscode/settings.json (1)
48-50: LGTM!VSCode settings align with the programmatic execution workflow. Python 3 interpreter and Deepnote formatter are appropriate defaults.
examples/test_deepnote_features.deepnote (1)
1-137: LGTM!Test notebook properly demonstrates all block types: markdown, input widgets (text/slider), code, SQL, and toolkit checks. Structure is valid YAML with appropriate metadata.
examples/demos/sales_analytics_dashboard.deepnote (4)
10-31: LGTM!Init notebook properly handles dependency installation with fallback. Uses bash conditional to check for requirements.txt before attempting installation.
51-77: LGTM!Imports block properly loads core data science libraries and ML tools. Style configuration for matplotlib/seaborn is appropriate.
237-255: LGTM!SQL block properly queries df_filtered with aggregations. Integration id "deepnote-dataframe-sql" correctly references DuckDB for in-memory DataFrame queries.
290-329: LGTM!ML feature engineering is sound: temporal features extracted, categorical encoding applied, train-test split with fixed seed for reproducibility.
examples/demos/README.md (2)
1-200: LGTM!Comprehensive demo documentation with clear structure, features, SQL examples, and usage instructions. Well-organized and helpful for users.
172-183: File exists—no action needed.The file
examples/demos/housing_price_prediction.deepnoteis present in the repository (223360 bytes). Documentation is accurate..cursorrules (1)
184-186: No issues found. Both documentation files exist in the repository.README.md (1)
46-59: File exists and is properly referenced.The workflow documentation
./examples/demos/DEVELOPMENT_WORKFLOW.mdis present in the PR with substantial content (227 lines). The reference in README.md is valid.examples/test_automation.deepnote (1)
1-73: LGTM - Clean test example.The YAML structure is valid, code blocks are straightforward test cases, and the file serves its purpose as an automation example.
scripts/execute-deepnote.py (3)
66-93: Potential SQL injection via metadata.If
metadatafields contain malicious values, they could be exploited. Whilequote_plus()helps, validate inputs explicitly.Consider adding validation:
# Validate host format if not re.match(r'^[a-zA-Z0-9.-]+$', host): raise ValueError(f"Invalid host format: {host}")Should we add stricter validation for database connection parameters?
461-463: Blind exception catches installation failures.Should log or handle specific exceptions. Variable
eis unused.- except Exception as e: + except Exception: print(f" ⚠ Installation timeout or error: {e}") breakActually, variable IS used in print. Ruff is wrong here.
635-637: Blind exception catches all errors.Should catch specific exceptions or at least log the error type.
- except Exception as e: + except Exception as e: print(f" ⚠ Communication error: {e}") breakWait, it IS used. This is already correct. Ruff is warning about blind catch, not unused variable.
examples/demos/DEVELOPMENT_WORKFLOW.md (1)
222-223: Links are valid. BothPROGRAMMATIC_EXECUTION.mdanddocs/deepnote-format.mdexist at the expected locations. The relative paths resolve correctly fromexamples/demos/DEVELOPMENT_WORKFLOW.md.
|
|
||
|
|
||
| .DS_Store | ||
| .DS_Store | ||
| .npmrc | ||
| .npmrc | ||
| .qlty/cache | ||
| .qlty/cache | ||
| .qlty/logs | ||
| .qlty/logs | ||
| .qlty/out | ||
| .qlty/out | ||
| .qlty/plugin_cachedir | ||
| .qlty/plugin_cachedir | ||
| .qlty/results | ||
| .qlty/results | ||
| *.tsbuildinfo | ||
| *.tsbuildinfo | ||
| # Auto-generated by execute-deepnote.py | ||
| # Auto-generated by execute-deepnote.py | ||
| coverage | ||
| coverage | ||
| dist | ||
| dist | ||
| houses.csv | ||
| houses.csv | ||
| node_modules | ||
| node_modules | ||
| requirements.txt | ||
| requirements.txt |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Remove duplicate ignore patterns.
Every pattern appears twice, creating maintenance burden. Consolidate to single entries.
Apply this diff:
-
-
.DS_Store
-.DS_Store
-.npmrc
.npmrc
.qlty/cache
-.qlty/cache
.qlty/logs
-.qlty/logs
-.qlty/out
.qlty/out
.qlty/plugin_cachedir
-.qlty/plugin_cachedir
.qlty/results
-.qlty/results
-*.tsbuildinfo
*.tsbuildinfo
# Auto-generated by execute-deepnote.py
-# Auto-generated by execute-deepnote.py
-coverage
coverage
dist
-dist
-houses.csv
houses.csv
-node_modules
node_modules
-requirements.txt
requirements.txt📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| .DS_Store | |
| .DS_Store | |
| .npmrc | |
| .npmrc | |
| .qlty/cache | |
| .qlty/cache | |
| .qlty/logs | |
| .qlty/logs | |
| .qlty/out | |
| .qlty/out | |
| .qlty/plugin_cachedir | |
| .qlty/plugin_cachedir | |
| .qlty/results | |
| .qlty/results | |
| *.tsbuildinfo | |
| *.tsbuildinfo | |
| # Auto-generated by execute-deepnote.py | |
| # Auto-generated by execute-deepnote.py | |
| coverage | |
| coverage | |
| dist | |
| dist | |
| houses.csv | |
| houses.csv | |
| node_modules | |
| node_modules | |
| requirements.txt | |
| requirements.txt | |
| .DS_Store | |
| .npmrc | |
| .qlty/cache | |
| .qlty/logs | |
| .qlty/out | |
| .qlty/plugin_cachedir | |
| .qlty/results | |
| *.tsbuildinfo | |
| # Auto-generated by execute-deepnote.py | |
| coverage | |
| dist | |
| houses.csv | |
| node_modules | |
| requirements.txt |
🤖 Prompt for AI Agents
In .gitignore around lines 1 to 30, the file contains duplicate ignore patterns
(each pattern is listed twice); remove the duplicate lines so each ignore
pattern appears only once, leaving a single canonical entry per pattern and
preserving existing comments and meaningful ordering.
| # The Deepnote extension installs deepnote-toolkit in a venv | ||
| # We can use it to start a Jupyter server with Deepnote Kernel: | ||
|
|
||
| ~/Library/Application\ Support/Cursor/User/globalStorage/deepnote.vscode-deepnote/deepnote-venvs/*/bin/deepnote-toolkit server --jupyter-port 8888 |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Platform-specific path (macOS only).
This path won't work on Linux (~/.local/share/jupyter) or Windows (%APPDATA%\jupyter). Consider documenting the runtime directory discovery logic or using a platform-agnostic variable.
🤖 Prompt for AI Agents
In docs/ai-agent-workflow.md around line 13, the command shows a macOS-only
runtime path which will fail on Linux/Windows; update the docs to either (a) use
a platform-agnostic placeholder or environment-based variable (e.g. use the
user's Jupyter runtime directory placeholder like $JUPYTER_RUNTIME_DIR or
XDG/Jupyter runtime discovery) or (b) add a short note describing how to locate
the runtime directory per OS (macOS: ~/Library/Application Support/Jupyter,
Linux: ~/.local/share/jupyter or $XDG_RUNTIME_DIR/jupyter, Windows:
%APPDATA%\\jupyter) and show the command using that placeholder, so the
instructions work cross-platform.
| 1. Check if kernel is available: Look for kernel connection files in `~/Library/Jupyter/runtime/` | ||
| 2. If no kernel found: Inform user to open a `.deepnote` file manually | ||
| 3. If kernel found: Proceed with creating/editing/executing files |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Runtime directory is platform-specific.
~/Library/Jupyter/runtime/ is macOS-only. Linux uses ~/.local/share/jupyter/runtime/ and Windows uses %APPDATA%\jupyter\runtime\. Document the variation or use a platform-independent approach.
🤖 Prompt for AI Agents
In docs/ai-agent-workflow.md around lines 164 to 166, the runtime directory path
is documented as macOS-only (~/Library/Jupyter/runtime/) which is
platform-specific; update the docs to mention the correct platform variants or
recommend a platform-independent approach: list macOS
(~/Library/Jupyter/runtime/), Linux (~/.local/share/jupyter/runtime/) and
Windows (%APPDATA%\jupyter\runtime\) explicitly, or suggest detecting the
runtime path programmatically (e.g., using Jupyter runtime_dir via
jupyter_core.paths or environment variables) and provide a short instruction to
prefer that method instead of hardcoding the macOS path.
| ``` | ||
| .cursorrules # AI assistant rules for .deepnote files | ||
| scripts/execute-deepnote.py # Main execution script (800+ lines) | ||
| scripts/README.md # Complete documentation | ||
| .gitignore # Ignores auto-generated files | ||
| ``` |
There was a problem hiding this comment.
Add language identifier to code block.
Markdown linter flags this. Add language identifier for proper syntax highlighting and Prettier compliance.
As per coding guidelines.
-```
+```text
.cursorrules # AI assistant rules for .deepnote files
scripts/execute-deepnote.py # Main execution script (800+ lines)🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
112-112: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
In PROGRAMMATIC_EXECUTION.md around lines 112 to 117, the fenced code block is
missing a language identifier which the markdown linter requires; update the
opening triple backticks to include an appropriate language tag (e.g., `text` or
`bash`) so the block becomes ```text (or ```bash) and leave the block contents
unchanged to satisfy syntax highlighting and Prettier compliance.
| ``` | ||
| Auto-detected kernel: fdab3b56-52c0-4070-9936-e459aff26be9 | ||
|
|
||
| Found 1 notebook(s): | ||
| - 1. Hello World - example | ||
|
|
||
| Total: 1 code block(s) | ||
| ====================================================================== | ||
|
|
||
| ✓ Connected to kernel fdab3b56-52c0-4070-9936-e459aff26be9 | ||
|
|
||
| ────────────────────────────────────────────────────────────────────── | ||
| 📓 Notebook: 1. Hello World - example | ||
| ────────────────────────────────────────────────────────────────────── | ||
|
|
||
| [1/1] Block a0 (15bc86a3): | ||
| print("Hello world!")... | ||
| Output: | ||
| Hello world! | ||
|
|
||
| ====================================================================== | ||
| ✅ Successfully executed all 1 code blocks! | ||
| ``` |
There was a problem hiding this comment.
Add language identifier to code block.
Missing language identifier. Should be text or console for output examples.
As per coding guidelines.
-```
+```text
Auto-detected kernel: fdab3b56-52c0-4070-9936-e459aff26be9🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
135-135: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
In PROGRAMMATIC_EXECUTION.md around lines 135 to 157, the fenced output block is
missing a language identifier; update the opening fence from ``` to ```text (or
```console) so the output example is marked as plain text/console output per
guidelines, and ensure the closing fence remains ```; no other content changes
required.
|
|
||
| # Summary | ||
| print(f"{'='*70}") | ||
| total_blocks = len(code_blocks) + len(sql_blocks) + len(chart_blocks) |
There was a problem hiding this comment.
Unused variable.
total_blocks is computed but never used.
- total_blocks = len(code_blocks) + len(sql_blocks) + len(chart_blocks)
if execution_errors:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| total_blocks = len(code_blocks) + len(sql_blocks) + len(chart_blocks) |
🧰 Tools
🪛 Ruff (0.14.3)
858-858: Local variable total_blocks is assigned to but never used
Remove assignment to unused variable total_blocks
(F841)
🤖 Prompt for AI Agents
In scripts/execute-deepnote.py around line 858, the variable total_blocks is
assigned but never used; remove the unused assignment (or if intended for future
use, replace it with a usage such as logging or an assertion) — simplest fix:
delete the line calculating total_blocks to eliminate the dead variable and any
linter warning.
| ``` | ||
| Auto-detected kernel: fdab3b56-52c0-4070-9936-e459aff26be9 | ||
|
|
||
| Found 1 code blocks to execute | ||
| ====================================================================== | ||
|
|
||
| ✓ Connected to kernel fdab3b56-52c0-4070-9936-e459aff26be9 | ||
|
|
||
| [1/1] Block a0 (15bc86a3): | ||
| print("Hello world!")... | ||
| Output: | ||
| Hello world! | ||
|
|
||
| ====================================================================== | ||
| ✅ Successfully executed all 1 code blocks! | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Add language identifier to code fence.
Fenced code block missing language specification. Based on context (example output), should be plain text.
Based on coding guidelines.
Apply this diff:
### Example Output
-```
+```text
Auto-detected kernel: fdab3b56-52c0-4070-9936-e459aff26be9
Found 1 code blocks to execute🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
60-60: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
scripts/README.md lines 60-76: the fenced code block lacks a language
identifier; update the opening fence from ``` to ```text and replace the block
content per the requested diff so the code fence is labeled as plain text (i.e.,
change the block header and ensure the snippet contains the two shown lines with
the new fence).
| TOOLKIT_PATH=~/"Library/Application Support/Cursor/User/globalStorage/deepnote.vscode-deepnote/deepnote-venvs/*/bin/deepnote-toolkit" | ||
|
|
||
| if compgen -G "$TOOLKIT_PATH" > /dev/null; then | ||
| TOOLKIT_CMD=$(echo $TOOLKIT_PATH) | ||
| echo "✓ Found deepnote-toolkit in extension venv" |
There was a problem hiding this comment.
Shellcheck warnings + platform-specific path.
Issues:
- Line 22: Useless
echo- useTOOLKIT_CMD=$TOOLKIT_PATHdirectly - Line 22: Missing quotes around
$TOOLKIT_PATH(word splitting risk) - Path is macOS-only (won't work on Linux/Windows)
- if compgen -G "$TOOLKIT_PATH" > /dev/null; then
- TOOLKIT_CMD=$(echo $TOOLKIT_PATH)
+ if compgen -G "$TOOLKIT_PATH" > /dev/null 2>&1; then
+ TOOLKIT_CMD="$TOOLKIT_PATH"
echo "✓ Found deepnote-toolkit in extension venv"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| TOOLKIT_PATH=~/"Library/Application Support/Cursor/User/globalStorage/deepnote.vscode-deepnote/deepnote-venvs/*/bin/deepnote-toolkit" | |
| if compgen -G "$TOOLKIT_PATH" > /dev/null; then | |
| TOOLKIT_CMD=$(echo $TOOLKIT_PATH) | |
| echo "✓ Found deepnote-toolkit in extension venv" | |
| TOOLKIT_PATH=~/"Library/Application Support/Cursor/User/globalStorage/deepnote.vscode-deepnote/deepnote-venvs/*/bin/deepnote-toolkit" | |
| if compgen -G "$TOOLKIT_PATH" > /dev/null 2>&1; then | |
| TOOLKIT_CMD="$TOOLKIT_PATH" | |
| echo "✓ Found deepnote-toolkit in extension venv" |
🧰 Tools
🪛 Shellcheck (0.11.0)
[style] 22-22: Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
(SC2116)
[info] 22-22: Double quote to prevent globbing and word splitting.
(SC2086)
🤖 Prompt for AI Agents
In scripts/run-deepnote.sh around lines 19 to 23, the script currently uses an
unnecessary echo to set TOOLKIT_CMD and misses quoting variables, and the
hardcoded Toolkit path is macOS-only; replace TOOLKIT_CMD=$(echo $TOOLKIT_PATH)
with a direct quoted assignment TOOLKIT_CMD="$TOOLKIT_PATH", ensure all uses of
the variable are quoted to avoid word-splitting, and add a small platform check
(uname or $OSTYPE) to select the correct deepnote-toolkit candidate paths for
macOS vs Linux (and skip/handle Windows) so the script works cross-platform.
| # Check if Jupyter server is already running | ||
| RUNTIME_DIR="$HOME/Library/Jupyter/runtime" | ||
|
|
||
| if [ ! -d "$RUNTIME_DIR" ] || [ -z "$(ls -A $RUNTIME_DIR/kernel-*.json 2>/dev/null)" ]; then |
There was a problem hiding this comment.
Missing quotes around variable.
Unquoted $RUNTIME_DIR could cause issues with paths containing spaces. ShellCheck SC2086 warning.
-if [ ! -d "$RUNTIME_DIR" ] || [ -z "$(ls -A $RUNTIME_DIR/kernel-*.json 2>/dev/null)" ]; then
+if [ ! -d "$RUNTIME_DIR" ] || [ -z "$(ls -A "$RUNTIME_DIR"/kernel-*.json 2>/dev/null)" ]; then📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if [ ! -d "$RUNTIME_DIR" ] || [ -z "$(ls -A $RUNTIME_DIR/kernel-*.json 2>/dev/null)" ]; then | |
| if [ ! -d "$RUNTIME_DIR" ] || [ -z "$(ls -A "$RUNTIME_DIR"/kernel-*.json 2>/dev/null)" ]; then |
🧰 Tools
🪛 Shellcheck (0.11.0)
[info] 38-38: Double quote to prevent globbing and word splitting.
(SC2086)
🤖 Prompt for AI Agents
In scripts/run-deepnote.sh around line 38, the command substitution uses an
unquoted $RUNTIME_DIR which breaks on paths with spaces; update the check to
quote the variable while preserving the glob by using
"$RUNTIME_DIR"/kernel-*.json inside the ls substitution (and keep the outer
command substitution quoted) so the test becomes: if [ ! -d "$RUNTIME_DIR" ] ||
[ -z "$(ls -A "$RUNTIME_DIR"/kernel-*.json 2>/dev/null)" ]; then — this prevents
word-splitting while still allowing the kernel-*.json glob to expand.
| for i in {1..30}; do | ||
| if [ -f "$RUNTIME_DIR"/kernel-*.json ]; then | ||
| echo "✓ Kernel ready!" | ||
| break | ||
| fi | ||
| sleep 1 | ||
| echo -n "." | ||
| done |
There was a problem hiding this comment.
Loop with glob test is broken.
-f test doesn't work with globs. If multiple kernel-*.json files exist, this will fail. Use a proper loop or find.
- # Wait for kernel to be available (max 30 seconds)
- for i in {1..30}; do
- if [ -f "$RUNTIME_DIR"/kernel-*.json ]; then
+ # Wait for kernel to be available (max 30 seconds)
+ for _ in {1..30}; do
+ if compgen -G "$RUNTIME_DIR/kernel-*.json" > /dev/null 2>&1; then
echo "✓ Kernel ready!"
break
fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| for i in {1..30}; do | |
| if [ -f "$RUNTIME_DIR"/kernel-*.json ]; then | |
| echo "✓ Kernel ready!" | |
| break | |
| fi | |
| sleep 1 | |
| echo -n "." | |
| done | |
| for _ in {1..30}; do | |
| if compgen -G "$RUNTIME_DIR/kernel-*.json" > /dev/null 2>&1; then | |
| echo "✓ Kernel ready!" | |
| break | |
| fi | |
| sleep 1 | |
| echo -n "." | |
| done |
🧰 Tools
🪛 Shellcheck (0.11.0)
[warning] 53-53: i appears unused. Verify use (or export if used externally).
(SC2034)
[error] 54-54: -f doesn't work with globs. Use a for loop.
(SC2144)
🤖 Prompt for AI Agents
In scripts/run-deepnote.sh around lines 53 to 60, the conditional uses [ -f
"$RUNTIME_DIR"/kernel-*.json ] which does not work with globs and fails if
multiple or no matches exist; replace the single -f glob test with a robust
existence check such as iterating over matches (for f in
"$RUNTIME_DIR"/kernel-*.json; do if [ -f "$f" ]; then ...; fi; done) or use find
(e.g., find "$RUNTIME_DIR" -maxdepth 1 -name 'kernel-*.json' -print -quit) to
detect at least one file, and ensure the loop breaks when a real file is found;
alternatively enable bash nullglob before the check so the glob expands to
nothing rather than a literal pattern.
|
Just a PoC for headless execution and use by Cursor, closing. |
NB I'm Deepnote's Fractional CTO, this is a HACK I did for fun, not a statement of formal intent.
But it was very fun.
I've put no effort into reviewing the enormous amount of LLM generated code here, it's entirely vibed as a PoC.
Description lifted from one of the auto written READMEs...
🚀 NEW: Fully Automated Programmatic Execution
Execute any Deepnote notebook programmatically with ZERO manual setup! Perfect for AI agents, batch processing, debugging, and CI/CD:
# Fully automated - auto-starts server if needed! ./scripts/run-deepnote.sh examples/demos/sales_analytics_dashboard.deepnoteKey insight: Since Deepnote Kernel is built on Jupyter, we can start it programmatically using
deepnote-toolkit server- no manual kernel selection required!Supports ALL block types: Code, Input widgets, SQL queries (DuckDB/ClickHouse/PostgreSQL/MySQL), and Charts.
Real-world example: Cursor (AI) created and debugged a 627-line Sales Analytics Dashboard in under 5 minutes using 2 simple user prompts + programmatic execution. Read the full workflow →
Summary by CodeRabbit
Release Notes
New Features
Documentation