Repository navigation
fix: Don't resolve dependencies for deploy notebook --static - #924
Merged
Merged
Conversation
The static bundle contains only the HTML rendered locally by nbconvert, but deploy_notebook resolved a requirements file, inspected the Python environment and read renv.lock before branching on --static, then threw all of it away. This required a requirements file (or --force-generate), failed on an incompatible renv.lock, and required rsconnect in the --python interpreter. With --static, only look up the interpreter that runs nbconvert.
|
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
mconflitti-pbc
approved these changes
Nov 6, 2026
Collaborator
|
There are some conflicts with #920, which I just merged. I'll go ahead and fix them since I have the branch pulled down. |
…o-requirements # Conflicts: # docs/CHANGELOG.md
…atic #920 added project environment discovery relative to the content directory, but the static path called which_python without one, so it searched from the current working directory instead of the notebook's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tdstein
approved these changes
Nov 6, 2026
…o-requirements # Conflicts: # docs/CHANGELOG.md
The rendering environment runs the notebook, so it needs ipykernel and the notebook's imports, not only nbconvert. Cover --python validation on the static path with a directory, which reaches which_python on every platform.
* feat: Warn about options that deploy notebook --static ignores A static notebook bundle contains only the rendered HTML, so options that shape a source bundle's Python or R environment (--requirements-file, --force-generate, --package-installer, --override-python-version, --image, the environment management options, --exclude-renv) and extra files have no effect. Warn when any of them is given explicitly instead of silently ignoring it. * review: Test that only --static warns, and ignore option order Cover deploy notebook without --static passing options --static ignores, so moving the warning out of the static branch fails a test. Compare the warned options as a set, since their order comes from the decorators.
jmwoliver
enabled auto-merge (squash)
November 6, 2026 20:23
jmwoliver
disabled auto-merge
November 6, 2026 20:27
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.
Fixes #923.
Problem
rsconnect deploy notebook --staticrenders the notebook locally withnbconvertand uploads a bundle containing only the HTML and amanifest.jsonwith nopythonsection. Butdeploy_notebookset up the deployment environment before checking--static, so a static deploy:requirements.txtunless given--force-generate, which ranpip freezeand discarded the output;renv.lockthat R dependency detection rejects (renv.lock is not compatible: missing Repositories section), even though nothing from R goes into the bundle;--pythoninterpreter, because environment inspection runspython -m rsconnect.subprocesses.inspect_environmentthere. Rendering only needsnbconvert.Fix
With
--static,deploy_notebooknow only callswhich_python(python)to find the interpreter that runsnbconvert. It skipsresolve_requirements_file,Environment.create_python_environmentandREnvironment.create. Deploys without--staticdon't change.Tests
The existing static tests mocked
create_python_environmentand used a fixture directory with arequirements.txt, which is how this was missed. They now run without mocking environment setup:test_deploy_notebook_static_needs_no_environment: a notebook alone in a temp directory, and one withrequirements.txtplus an incompatiblerenv.lock. Asserts the deploy succeeds,make_notebook_html_bundlegets the current interpreter (covering When deploying Jupyter notebooks--staticdoesn't work. #721 as well), and no files are written into the directory.test_deploy_notebook_static_renders_with_python_option:--pythonis passed through as the rendering interpreter.test_deploy_static_notebook_render_failurepasses its interpreter with--pythoninstead of a mocked environment. Itsmissing_nbconvertcase uses a bare venv without rsconnect, which previously could not get past environment inspection.All six tests fail on
mainfor the reasons above and pass with this change. The full suite passes locally (1850 passed, 15 skipped) and ruff is clean.Options that have no effect with
--static(--requirements-file,--force-generate, etc.) are still accepted silently. A stacked follow-up PR warns about them.