Skip to content

fix: Don't resolve dependencies for deploy notebook --static - #924

Merged
jmwoliver merged 6 commits into
mainfrom
fix/static-notebook-no-requirements
Nov 6, 2026
Merged

jmwoliver merged 6 commits into
mainfrom
fix/static-notebook-no-requirements

Conversation

@jmwoliver

Copy link
Copy Markdown
Contributor

Fixes #923.

Problem

rsconnect deploy notebook --static renders the notebook locally with nbconvert and uploads a bundle containing only the HTML and a manifest.json with no python section. But deploy_notebook set up the deployment environment before checking --static, so a static deploy:

  • failed without a requirements.txt unless given --force-generate, which ran pip freeze and discarded the output;
  • failed on an renv.lock that R dependency detection rejects (renv.lock is not compatible: missing Repositories section), even though nothing from R goes into the bundle;
  • required rsconnect to be installed in the --python interpreter, because environment inspection runs python -m rsconnect.subprocesses.inspect_environment there. Rendering only needs nbconvert.

Fix

With --static, deploy_notebook now only calls which_python(python) to find the interpreter that runs nbconvert. It skips resolve_requirements_file, Environment.create_python_environment and REnvironment.create. Deploys without --static don't change.

Tests

The existing static tests mocked create_python_environment and used a fixture directory with a requirements.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 with requirements.txt plus an incompatible renv.lock. Asserts the deploy succeeds, make_notebook_html_bundle gets the current interpreter (covering When deploying Jupyter notebooks --static doesn't work. #721 as well), and no files are written into the directory.
  • test_deploy_notebook_static_renders_with_python_option: --python is passed through as the rendering interpreter.
  • test_deploy_static_notebook_render_failure passes its interpreter with --python instead of a mocked environment. Its missing_nbconvert case uses a bare venv without rsconnect, which previously could not get past environment inspection.

All six tests fail on main for 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.

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.
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-11-06 20:27 UTC

@jmwoliver
jmwoliver requested a review from tdstein November 6, 2026 15:45
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
11187 9961 89% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/main.py 89% 🟢
TOTAL 89% 🟢

updated for commit: 439a675 by action🐍

Comment thread docs/CHANGELOG.md Resolved
Comment thread rsconnect/main.py Resolved

@joshyam-k joshyam-k 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.

defer to @tdstein here, but at a high level this looks like an obviously correct fix.

@tdstein

tdstein commented Nov 6, 2026

Copy link
Copy Markdown
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.

tdstein and others added 2 commits November 6, 2026 12:09
…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>
jmwoliver and others added 3 commits November 6, 2026 14:35
…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
jmwoliver enabled auto-merge (squash) November 6, 2026 20:23
@jmwoliver
jmwoliver disabled auto-merge November 6, 2026 20:27
@jmwoliver
jmwoliver merged commit 5b6181a into main Nov 6, 2026
28 checks passed
@jmwoliver
jmwoliver deleted the fix/static-notebook-no-requirements branch November 6, 2026 20:27
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.

deploy notebook --static requires a requirements file it never uses

4 participants