Skip to content

Commit 71bb885

Browse files
authored
Merge pull request #383 from rstudio/bcwu-extrafiles-voila
fix voila extra files
2 parents 0c2708f + 115c685 commit 71bb885

File tree

4 files changed

+96
-2
lines changed

4 files changed

+96
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- The `CONNECT_REQUEST_TIMEOUT` environment variable, which configures the request timeout for all blocking HTTP and HTTPS operations. This value translates into seconds (e.g., `CONNECT_REQUEST_TIMEOUT=60` is equivalent to 60 seconds.) By default, this value is 300.
1111

12+
### Fixed
13+
14+
- Extra files were not being included in deploy Voila.
15+
16+
- Error message to indicate the Python also has to be configured in Connect.
17+
1218
## [1.15.0] - 2023-03-15
1319

1420
### Added

rsconnect/bundle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ def create_voila_manifest(
16861686
raise RSConnectException(MULTI_NOTEBOOK_EXC_MSG)
16871687
_warn_on_ignored_entrypoint(entrypoint)
16881688
deploy_dir = entrypoint = abspath(path)
1689-
extra_files = validate_extra_files(deploy_dir, extra_files)
1689+
extra_files = validate_extra_files(deploy_dir, extra_files, use_abspath=True)
16901690
excludes = list(excludes) if excludes else []
16911691
excludes.extend([environment.filename, "manifest.json"])
16921692
excludes.extend(list_environment_dirs(deploy_dir))

rsconnect/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,6 @@ def deploy_voila(
927927
kwargs = locals()
928928
set_verbosity(verbose)
929929
app_mode = AppModes.JUPYTER_VOILA
930-
kwargs["extra_files"] = extra_files = validate_extra_files(dirname(path), extra_files)
931930
environment = create_python_environment(
932931
path if isdir(path) else dirname(path),
933932
force_generate,

tests/test_bundle.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ def test_is_not_executable(self):
814814
bqplot_ipynb = os.path.join(bqplot_dir, "bqplot.ipynb")
815815
dashboard_dir = os.path.join(cur_dir, "./testdata/voila/dashboard/")
816816
dashboard_ipynb = os.path.join(dashboard_dir, "dashboard.ipynb")
817+
dashboard_extra_ipynb = os.path.join(dashboard_dir, "bqplot.ipynb")
817818
multivoila_dir = os.path.join(cur_dir, "./testdata/voila/multi-voila/")
818819
nonexistent_dir = os.path.join(cur_dir, "./testdata/nonexistent/")
819820
nonexistent_file = os.path.join(cur_dir, "nonexistent.txt")
@@ -985,6 +986,46 @@ def test_create_voila_manifest_2(path, entrypoint):
985986
assert ans == json.loads(manifest.flattened_copy.json)
986987

987988

989+
def test_create_voila_manifest_extra():
990+
environment = Environment(
991+
conda=None,
992+
contents="numpy\nipywidgets\nbqplot\n",
993+
error=None,
994+
filename="requirements.txt",
995+
locale="en_US.UTF-8",
996+
package_manager="pip",
997+
pip="23.0.1",
998+
python="3.8.12",
999+
source="file",
1000+
)
1001+
ans = {
1002+
"version": 1,
1003+
"locale": "en_US.UTF-8",
1004+
"metadata": {"appmode": "jupyter-voila", "entrypoint": "dashboard.ipynb"},
1005+
"python": {
1006+
"version": "3.8.12",
1007+
"package_manager": {"name": "pip", "version": "23.0.1", "package_file": "requirements.txt"},
1008+
},
1009+
"files": {
1010+
"requirements.txt": {"checksum": "d51994456975ff487749acc247ae6d63"},
1011+
"bqplot.ipynb": {"checksum": "79f8622228eded646a3038848de5ffd9"},
1012+
"dashboard.ipynb": {"checksum": "6b42a0730d61e5344a3e734f5bbeec25"},
1013+
},
1014+
}
1015+
manifest = create_voila_manifest(
1016+
dashboard_ipynb,
1017+
None,
1018+
environment,
1019+
app_mode=AppModes.JUPYTER_VOILA,
1020+
extra_files=[dashboard_extra_ipynb],
1021+
excludes=None,
1022+
force_generate=True,
1023+
image=None,
1024+
multi_notebook=False,
1025+
)
1026+
assert ans == json.loads(manifest.flattened_copy.json)
1027+
1028+
9881029
@pytest.mark.parametrize(
9891030
(
9901031
"path",
@@ -1353,6 +1394,54 @@ def test_make_voila_bundle_2(
13531394
assert ans == json.loads(tar.extractfile("manifest.json").read().decode("utf-8"))
13541395

13551396

1397+
def test_make_voila_bundle_extra():
1398+
environment = Environment(
1399+
conda=None,
1400+
contents="numpy\nipywidgets\nbqplot\n",
1401+
error=None,
1402+
filename="requirements.txt",
1403+
locale="en_US.UTF-8",
1404+
package_manager="pip",
1405+
pip="23.0.1",
1406+
python="3.8.12",
1407+
source="file",
1408+
)
1409+
ans = {
1410+
"version": 1,
1411+
"locale": "en_US.UTF-8",
1412+
"metadata": {"appmode": "jupyter-voila", "entrypoint": "dashboard.ipynb"},
1413+
"python": {
1414+
"version": "3.8.12",
1415+
"package_manager": {"name": "pip", "version": "23.0.1", "package_file": "requirements.txt"},
1416+
},
1417+
"files": {
1418+
"requirements.txt": {"checksum": "d51994456975ff487749acc247ae6d63"},
1419+
"bqplot.ipynb": {"checksum": "79f8622228eded646a3038848de5ffd9"},
1420+
"dashboard.ipynb": {"checksum": "6b42a0730d61e5344a3e734f5bbeec25"},
1421+
},
1422+
}
1423+
with make_voila_bundle(
1424+
dashboard_ipynb,
1425+
None,
1426+
extra_files=[dashboard_extra_ipynb],
1427+
excludes=None,
1428+
force_generate=True,
1429+
environment=environment,
1430+
image=None,
1431+
multi_notebook=False,
1432+
) as bundle, tarfile.open(mode="r:gz", fileobj=bundle) as tar:
1433+
names = sorted(tar.getnames())
1434+
assert names == [
1435+
"bqplot.ipynb",
1436+
"dashboard.ipynb",
1437+
"manifest.json",
1438+
"requirements.txt",
1439+
]
1440+
reqs = tar.extractfile("requirements.txt").read()
1441+
assert reqs == b"numpy\nipywidgets\nbqplot\n"
1442+
assert ans == json.loads(tar.extractfile("manifest.json").read().decode("utf-8"))
1443+
1444+
13561445
single_file_index_dir = os.path.join(cur_dir, "./testdata/html_tests/single_file_index")
13571446
single_file_index_file = os.path.join(cur_dir, "./testdata/html_tests/single_file_index/index.html")
13581447
single_file_nonindex_dir = os.path.join(cur_dir, "./testdata/html_tests/single_file_nonindex")

0 commit comments

Comments
 (0)