Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove make_source_manifest in favor of Manifest class #477

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 52 additions & 19 deletions rsconnect/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from typing import IO
from warnings import warn
from os.path import abspath, basename, dirname, exists, isdir, join, relpath, splitext

from .bundle import Manifest
from .exception import RSConnectException
from . import api
from .bundle import (
Expand All @@ -32,9 +34,6 @@
make_notebook_source_bundle,
make_quarto_source_bundle,
make_quarto_manifest,
make_source_manifest,
manifest_add_buffer,
manifest_add_file,
read_manifest_app_mode,
read_manifest_file,
)
Expand Down Expand Up @@ -1295,8 +1294,9 @@ def create_api_deployment_bundle(
if app_mode is None:
app_mode = AppModes.PYTHON_API

return make_api_bundle(directory, entry_point, app_mode, environment, extra_files, excludes,
image, env_management_py, env_management_r)
return make_api_bundle(
directory, entry_point, app_mode, environment, extra_files, excludes, image, env_management_py, env_management_r
)


def create_quarto_deployment_bundle(
Expand Down Expand Up @@ -1333,8 +1333,17 @@ def create_quarto_deployment_bundle(
if app_mode is None:
app_mode = AppModes.STATIC_QUARTO

return make_quarto_source_bundle(file_or_directory, inspect, app_mode, environment, extra_files, excludes,
image, env_management_py, env_management_r)
return make_quarto_source_bundle(
file_or_directory,
inspect,
app_mode,
environment,
extra_files,
excludes,
image,
env_management_py,
env_management_r,
)


def deploy_bundle(
Expand Down Expand Up @@ -1442,8 +1451,15 @@ def create_notebook_manifest_and_environment_file(
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
if (
not write_notebook_manifest_json(
entry_point_file, environment, app_mode, extra_files, hide_all_input, hide_tagged_input,
image, env_management_py, env_management_r,
entry_point_file,
environment,
app_mode,
extra_files,
hide_all_input,
hide_tagged_input,
image,
env_management_py,
env_management_r,
)
or force
):
Expand Down Expand Up @@ -1496,15 +1512,22 @@ def write_notebook_manifest_json(
if app_mode == AppModes.UNKNOWN:
raise RSConnectException('Could not determine the app mode from "%s"; please specify one.' % extension)

manifest_data = make_source_manifest(app_mode, environment, file_name, None,
image, env_management_py, env_management_r)
manifest_add_file(manifest_data, file_name, directory)
manifest_add_buffer(manifest_data, environment.filename, environment.contents)
manifest = Manifest(
app_mode=app_mode,
environment=environment,
entrypoint=file_name,
quarto_inspection=None,
image=image,
env_management_py=env_management_py,
env_management_r=env_management_r,
)
manifest.add_file_relative(file_name, directory)
manifest.add_buffer(environment.filename, environment.contents)

for rel_path in extra_files:
manifest_add_file(manifest_data, rel_path, directory)
manifest.add_file_relative(rel_path, directory)

write_manifest_json(manifest_path, manifest_data)
write_manifest_json(manifest_path, manifest.data)

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

Expand Down Expand Up @@ -1544,8 +1567,17 @@ def create_api_manifest_and_environment_file(
"""
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
if (
not write_api_manifest_json(directory, entry_point, environment, app_mode, extra_files, excludes,
image, env_management_py, env_management_r)
not write_api_manifest_json(
directory,
entry_point,
environment,
app_mode,
extra_files,
excludes,
image,
env_management_py,
env_management_r,
)
or force
):
write_environment_file(environment, directory)
Expand Down Expand Up @@ -1584,8 +1616,9 @@ def write_api_manifest_json(
"""
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
extra_files = validate_extra_files(directory, extra_files)
manifest, _ = make_api_manifest(directory, entry_point, app_mode, environment, extra_files, excludes,
image, env_management_py, env_management_r)
manifest, _ = make_api_manifest(
directory, entry_point, app_mode, environment, extra_files, excludes, image, env_management_py, env_management_r
)
manifest_path = join(directory, "manifest.json")

write_manifest_json(manifest_path, manifest)
Expand Down
25 changes: 10 additions & 15 deletions rsconnect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,14 +1121,9 @@ def create_application(self, account_id, application_name):
return response

def create_output(self, name: str, application_type: str, project_id=None, space_id=None, render_by=None):
data = {
"name": name,
"space": space_id,
"project": project_id,
"application_type": application_type
}
data = {"name": name, "space": space_id, "project": project_id, "application_type": application_type}
if render_by:
data['render_by'] = render_by
data["render_by"] = render_by
response = self.post("/v1/outputs/", body=data)
self._server.handle_bad_response(response)
return response
Expand Down Expand Up @@ -1342,9 +1337,7 @@ def prepare_deploy(
app_store_version: typing.Optional[int],
) -> PrepareDeployOutputResult:

application_type = "static" if app_mode in [
AppModes.STATIC,
AppModes.STATIC_QUARTO] else "connect"
application_type = "static" if app_mode in [AppModes.STATIC, AppModes.STATIC_QUARTO] else "connect"
logger.debug(f"application_type: {application_type}")

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

# create the new output and associate it with the current Posit Cloud project and space
output = self._rstudio_client.create_output(name=app_name,
application_type=application_type,
project_id=project_id,
space_id=space_id,
render_by=render_by)
output = self._rstudio_client.create_output(
name=app_name,
application_type=application_type,
project_id=project_id,
space_id=space_id,
render_by=render_by,
)
app_id_int = output["source_id"]
else:
# this is a redeployment of an existing output
Expand Down
Loading
Loading