fix static notebook deploy passing python version string instead of interpreter path#820
Merged
Conversation
…nterpreter path deploy_notebook passed environment.python (the manifest Python version string, e.g. 3.12.1) to make_notebook_html_bundle instead of environment.python_interpreter (the resolved executable path), so nbconvert was invoked as a subprocess named 3.12.1 and failed with ENOENT. Fixes #721
|
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
cgraham-rs
approved these changes
Jul 14, 2026
Collaborator
|
I was having some difficulty discerning the intent of the tests relative to the fix, 🤖 suggested something like: import sys
from os.path import join
from types import SimpleNamespace
from unittest import mock
from click.testing import CliRunner
from rsconnect.main import cli, make_notebook_html_bundle
from tests.utils import apply_common_args, get_dir
def test_deploy_notebook_static_passes_interpreter_not_version():
# Regression test for #721. For a static notebook deploy, deploy_notebook must
# hand make_notebook_html_bundle the local interpreter *path* (used to run
# nbconvert), not environment.python, which is only a version string and would
# make nbconvert fail with "No such file or directory".
#
# In practice these always diverge: environment.python comes from
# sys.version_info ("3.12.1"), environment.python_interpreter from sys.executable.
fake_env = SimpleNamespace(python="3.12.1", python_interpreter=sys.executable)
with mock.patch(
"rsconnect.main.Environment.create_python_environment", return_value=fake_env
), mock.patch("rsconnect.main.RSConnectExecutor") as MockExecutor:
ce = MockExecutor.return_value
runner = CliRunner()
args = apply_common_args(
["deploy", "notebook", get_dir(join("pip1", "dummy.ipynb"))],
server="http://fake_server",
key="FAKE_API_KEY",
)
args += ["--static", "--no-verify"]
result = runner.invoke(cli, args)
assert result.exit_code == 0, result.output
# make_bundle(make_notebook_html_bundle, file, <python>, hide_all, hide_tagged)
bundle_args = ce.make_bundle.call_args.args
assert bundle_args[0] is make_notebook_html_bundle
assert bundle_args[2] == sys.executable |
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.
Intent
rsconnect deploy notebook --staticrunsnbconvertlocally to render the notebook before bundling it. Since #648, that call was passedenvironment.python, which is the Python version string recorded for the manifest (e.g.3.12.1), not an interpreter path.nbconvertwas invoked as a subprocess named3.12.1, so every static notebook deploy failed withUnable to include the file 3.12.1 in the bundle: No such file or directory.Fixes #721
Approach
Use
environment.python_interpreter(the resolved executable path, defaulting tosys.executable) instead ofenvironment.python.Automated Tests
Added a regression test that deploys a static notebook with
--override-python-versionset to a value that would visibly diverge from the real interpreter path, and assertsnbconvertis invoked with the real path. Confirmed it fails without the fix.Directions for Reviewers
Checklist
rsconnect-python-tests-at-nightworkflow in Connect against this feature branch.