Repository navigation
Conversation
…de Deepnote Cloud runtime-core, which the VS Code extension and the deepnote CLI use, starts the toolkit in detached mode, with Jupyter and the kernel in the .deepnote file's folder. set_notebook_path still rewrote sys.path and the working directory against ~/work there. That removed the notebook's folder from sys.path, so a module next to the .deepnote file could not be imported. Imports only worked when parsing the project ID from the session name crashed first; a notebook name with two colons parsed into a garbage ID and broke them again. In detached mode, outside dev mode, and with neither paths.notebook_root nor paths.home_dir set, the kernel now keeps the working directory and sys.path it starts with. In detached or dev mode, runtime.project_id is exported as DEEPNOTE_PROJECT_ID before the Jupyter session lookup, so user code sees the same variable as in Cloud. In the detached case above, the session name is no longer parsed. Attached runs, dev mode and configs with explicit paths keep the rewrite. Closes #153
|
📦 Python package built successfully!
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #155 +/- ##
==========================================
+ Coverage 78.43% 78.54% +0.10%
==========================================
Files 121 121
Lines 6920 6927 +7
Branches 1005 1007 +2
==========================================
+ Hits 5428 5441 +13
+ Misses 1182 1179 -3
+ Partials 310 307 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
🚀 Review App Deployment Started
|
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.
@coderabbitai ignore
Closes #153.
Why
The VS Code extension and the
deepnoteCLI start the toolkit through runtime-core, in detached mode. Jupyter and the kernel start in the.deepnotefile's folder.set_notebook_pathstill rewrotesys.pathand the working directory against~/workthere. That removed the notebook's folder fromsys.path, so a module next to the.deepnotefile could not be imported.Imports only worked when parsing the project ID from the session name crashed first. A notebook name with two colons (
sales:q1:report) parsed into a garbage ID, and the rewrite broke imports again. Because of this, deepnote/vscode-deepnote#617 stopped settingDEEPNOTE_PROJECT_ID, so user code no longer saw it locally.What changes
set_notebook_pathnow reads the runtime config before the Jupyter session lookup:sys.pathwhen the toolkit runs detached, outside dev mode, and with neitherpaths.notebook_rootnorpaths.home_dirset. In that setup the session name is no longer parsed.runtime.project_idasDEEPNOTE_PROJECT_IDin detached or dev mode. The config loader already resolvesDEEPNOTE_PROJECT_IDandDEEPNOTE_RUNTIME__PROJECT_IDand ignores empty values. The session-name parse remains the fallback when no ID is configured.Attached runs (Deepnote Cloud), dev mode and configs with explicit paths keep the rewrite.
There is one intended change in dev mode: when
DEEPNOTE_RUNTIME__PROJECT_IDorDEEPNOTE_PROJECT_IDis set, the configured ID now takes priority over the ID parsed from the session name. That is the value every other reader of the project ID already uses.docs/user/configuration.mdand the function's docstring describe the new behavior.Tests
New tests in
tests/unit/test_set_notebook_path_config.pyload the config through the real loader:mainsys.pathkept, ID exportedsys.pathkept, nothing exported~/work/<dir>or/work/<dir>_cfg()intests/unit/test_set_notebook_path.pygainsproject_id=None, because the function now reads it.home_dir;tests/unitgives 1468 passed and 4 skipped, with the same 13 warnings asmain.python -m deepnote_toolkit serverlaunched the way runtime-core does it, with session namesales:q1:report. The kernel stays in the project folder,import helper_modworks, andDEEPNOTE_PROJECT_IDis the configured ID. Onmain, the import fails and the ID isreport.Follow-ups (not in this PR)
DEEPNOTE_PROJECT_IDfrom the integration env endpoint. Remove it no earlier, because kernels on the currently pinned toolkit rely on it.resolve_project_root()indeepnote_toolkit/artifacts/_dataframe_storage.pystill returns$HOME/workfor runtime-core kernels, not their working directory. Storage lands in the same place as onmain. Whether it should move to the kernel's folder is a separate decision.test_set_notebook_path_updates_chdir_and_envleavesDEEPNOTE_PROJECT_IDset after it runs. This is already the case onmain.