Skip to content

Commit 82bf35c

Browse files
committed
remove make_source_manifest in favor of Manifest class
1 parent f8e2cac commit 82bf35c

File tree

5 files changed

+250
-219
lines changed

5 files changed

+250
-219
lines changed

rsconnect/actions.py

+52-19
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from typing import IO
1515
from warnings import warn
1616
from os.path import abspath, basename, dirname, exists, isdir, join, relpath, splitext
17+
18+
from .bundle import Manifest
1719
from .exception import RSConnectException
1820
from . import api
1921
from .bundle import (
@@ -32,9 +34,6 @@
3234
make_notebook_source_bundle,
3335
make_quarto_source_bundle,
3436
make_quarto_manifest,
35-
make_source_manifest,
36-
manifest_add_buffer,
37-
manifest_add_file,
3837
read_manifest_app_mode,
3938
read_manifest_file,
4039
)
@@ -1295,8 +1294,9 @@ def create_api_deployment_bundle(
12951294
if app_mode is None:
12961295
app_mode = AppModes.PYTHON_API
12971296

1298-
return make_api_bundle(directory, entry_point, app_mode, environment, extra_files, excludes,
1299-
image, env_management_py, env_management_r)
1297+
return make_api_bundle(
1298+
directory, entry_point, app_mode, environment, extra_files, excludes, image, env_management_py, env_management_r
1299+
)
13001300

13011301

13021302
def create_quarto_deployment_bundle(
@@ -1333,8 +1333,17 @@ def create_quarto_deployment_bundle(
13331333
if app_mode is None:
13341334
app_mode = AppModes.STATIC_QUARTO
13351335

1336-
return make_quarto_source_bundle(file_or_directory, inspect, app_mode, environment, extra_files, excludes,
1337-
image, env_management_py, env_management_r)
1336+
return make_quarto_source_bundle(
1337+
file_or_directory,
1338+
inspect,
1339+
app_mode,
1340+
environment,
1341+
extra_files,
1342+
excludes,
1343+
image,
1344+
env_management_py,
1345+
env_management_r,
1346+
)
13381347

13391348

13401349
def deploy_bundle(
@@ -1442,8 +1451,15 @@ def create_notebook_manifest_and_environment_file(
14421451
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
14431452
if (
14441453
not write_notebook_manifest_json(
1445-
entry_point_file, environment, app_mode, extra_files, hide_all_input, hide_tagged_input,
1446-
image, env_management_py, env_management_r,
1454+
entry_point_file,
1455+
environment,
1456+
app_mode,
1457+
extra_files,
1458+
hide_all_input,
1459+
hide_tagged_input,
1460+
image,
1461+
env_management_py,
1462+
env_management_r,
14471463
)
14481464
or force
14491465
):
@@ -1496,15 +1512,22 @@ def write_notebook_manifest_json(
14961512
if app_mode == AppModes.UNKNOWN:
14971513
raise RSConnectException('Could not determine the app mode from "%s"; please specify one.' % extension)
14981514

1499-
manifest_data = make_source_manifest(app_mode, environment, file_name, None,
1500-
image, env_management_py, env_management_r)
1501-
manifest_add_file(manifest_data, file_name, directory)
1502-
manifest_add_buffer(manifest_data, environment.filename, environment.contents)
1515+
manifest = Manifest(
1516+
app_mode=app_mode,
1517+
environment=environment,
1518+
entrypoint=file_name,
1519+
quarto_inspection=None,
1520+
image=image,
1521+
env_management_py=env_management_py,
1522+
env_management_r=env_management_r,
1523+
)
1524+
manifest.add_file_relative(file_name, directory)
1525+
manifest.add_buffer(environment.filename, environment.contents)
15031526

15041527
for rel_path in extra_files:
1505-
manifest_add_file(manifest_data, rel_path, directory)
1528+
manifest.add_file_relative(rel_path, directory)
15061529

1507-
write_manifest_json(manifest_path, manifest_data)
1530+
write_manifest_json(manifest_path, manifest.data)
15081531

15091532
return exists(join(directory, environment.filename))
15101533

@@ -1544,8 +1567,17 @@ def create_api_manifest_and_environment_file(
15441567
"""
15451568
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
15461569
if (
1547-
not write_api_manifest_json(directory, entry_point, environment, app_mode, extra_files, excludes,
1548-
image, env_management_py, env_management_r)
1570+
not write_api_manifest_json(
1571+
directory,
1572+
entry_point,
1573+
environment,
1574+
app_mode,
1575+
extra_files,
1576+
excludes,
1577+
image,
1578+
env_management_py,
1579+
env_management_r,
1580+
)
15491581
or force
15501582
):
15511583
write_environment_file(environment, directory)
@@ -1584,8 +1616,9 @@ def write_api_manifest_json(
15841616
"""
15851617
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
15861618
extra_files = validate_extra_files(directory, extra_files)
1587-
manifest, _ = make_api_manifest(directory, entry_point, app_mode, environment, extra_files, excludes,
1588-
image, env_management_py, env_management_r)
1619+
manifest, _ = make_api_manifest(
1620+
directory, entry_point, app_mode, environment, extra_files, excludes, image, env_management_py, env_management_r
1621+
)
15891622
manifest_path = join(directory, "manifest.json")
15901623

15911624
write_manifest_json(manifest_path, manifest)

rsconnect/api.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -1121,14 +1121,9 @@ def create_application(self, account_id, application_name):
11211121
return response
11221122

11231123
def create_output(self, name: str, application_type: str, project_id=None, space_id=None, render_by=None):
1124-
data = {
1125-
"name": name,
1126-
"space": space_id,
1127-
"project": project_id,
1128-
"application_type": application_type
1129-
}
1124+
data = {"name": name, "space": space_id, "project": project_id, "application_type": application_type}
11301125
if render_by:
1131-
data['render_by'] = render_by
1126+
data["render_by"] = render_by
11321127
response = self.post("/v1/outputs/", body=data)
11331128
self._server.handle_bad_response(response)
11341129
return response
@@ -1342,9 +1337,7 @@ def prepare_deploy(
13421337
app_store_version: typing.Optional[int],
13431338
) -> PrepareDeployOutputResult:
13441339

1345-
application_type = "static" if app_mode in [
1346-
AppModes.STATIC,
1347-
AppModes.STATIC_QUARTO] else "connect"
1340+
application_type = "static" if app_mode in [AppModes.STATIC, AppModes.STATIC_QUARTO] else "connect"
13481341
logger.debug(f"application_type: {application_type}")
13491342

13501343
render_by = "server" if app_mode == AppModes.STATIC_QUARTO else None
@@ -1362,11 +1355,13 @@ def prepare_deploy(
13621355
space_id = None
13631356

13641357
# create the new output and associate it with the current Posit Cloud project and space
1365-
output = self._rstudio_client.create_output(name=app_name,
1366-
application_type=application_type,
1367-
project_id=project_id,
1368-
space_id=space_id,
1369-
render_by=render_by)
1358+
output = self._rstudio_client.create_output(
1359+
name=app_name,
1360+
application_type=application_type,
1361+
project_id=project_id,
1362+
space_id=space_id,
1363+
render_by=render_by,
1364+
)
13701365
app_id_int = output["source_id"]
13711366
else:
13721367
# this is a redeployment of an existing output

0 commit comments

Comments
 (0)