Skip to content

Commit

Permalink
Merge pull request #535 from rstudio/aron-issue-534
Browse files Browse the repository at this point in the history
quarto: address inconsistencies between deprecated and live implementations
  • Loading branch information
aronatkins committed Jan 19, 2024
2 parents 1f6f75d + 1d23067 commit 55a730d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
should help prevent users from getting stuck a "build already running" state.
See [#467](https://github.com/rstudio/rsconnect-python/issues/467) for details.

- Addressed an error which occurred when attempting to create manifests for
Quarto documents. (#534)

## [1.21.0] - 2023-10-26

### Fixed
Expand Down
14 changes: 2 additions & 12 deletions rsconnect/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
make_notebook_html_bundle,
make_notebook_source_bundle,
make_quarto_source_bundle,
make_quarto_manifest,
make_source_manifest,
manifest_add_buffer,
manifest_add_file,
Expand Down Expand Up @@ -518,8 +517,7 @@ def write_quarto_manifest_json(
The server administrator is responsible for installing packages in the runtime environment. Default = None.
"""
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)

manifest, _ = make_quarto_manifest(
bundle.write_quarto_manifest_json(
file_or_directory,
inspect,
app_mode,
Expand All @@ -531,21 +529,13 @@ def write_quarto_manifest_json(
env_management_r,
)

base_dir = file_or_directory
if not isdir(file_or_directory):
base_dir = dirname(file_or_directory)
manifest_path = join(base_dir, "manifest.json")
write_manifest_json(manifest_path, manifest)


def write_manifest_json(manifest_path, manifest):
"""
Write the manifest data as JSON to the named manifest.json with a trailing newline.
"""
warn("This method has been moved and will be deprecated.", DeprecationWarning, stacklevel=2)
with open(manifest_path, "w") as f:
json.dump(manifest, f, indent=2)
f.write("\n")
bundle.write_manifest_json(manifest_path, manifest)


def deploy_html(
Expand Down
20 changes: 14 additions & 6 deletions rsconnect/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ def make_quarto_manifest(
# Standalone Quarto document
base_dir = dirname(file_or_directory)
file_name = basename(file_or_directory)
relevant_files = [file_name] + extra_files
relevant_files = [file_name] + list(extra_files or [])

manifest = make_source_manifest(
app_mode,
Expand Down Expand Up @@ -2015,7 +2015,7 @@ def describe_manifest(


def write_quarto_manifest_json(
directory: str,
file_or_directory: str,
inspect: typing.Any,
app_mode: AppMode,
environment: Environment,
Expand All @@ -2028,7 +2028,7 @@ def write_quarto_manifest_json(
"""
Creates and writes a manifest.json file for the given Quarto project.
:param directory: The directory containing the Quarto project.
:param file_or_directory: The Quarto document or the directory containing the Quarto project.
:param inspect: The parsed JSON from a 'quarto inspect' against the project.
:param app_mode: The application mode to assume (such as AppModes.STATIC_QUARTO)
:param environment: The (optional) Python environment to use.
Expand All @@ -2041,12 +2041,20 @@ def write_quarto_manifest_json(
The server administrator is responsible for installing packages in the runtime environment. Default = None.
"""

extra_files = validate_extra_files(directory, extra_files)
manifest, _ = make_quarto_manifest(
directory, inspect, app_mode, environment, extra_files, excludes, image, env_management_py, env_management_r
file_or_directory,
inspect,
app_mode,
environment,
extra_files,
excludes,
image,
)
manifest_path = join(directory, "manifest.json")

base_dir = file_or_directory
if not isdir(file_or_directory):
base_dir = dirname(file_or_directory)
manifest_path = join(base_dir, "manifest.json")
write_manifest_json(manifest_path, manifest)


Expand Down
6 changes: 3 additions & 3 deletions tests/test_main_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# For some reason setup and teardown aren't enough to fully reset the state
# between tests. Overriding the env var CONNECT_CONTENT_BUILD_DIR to be a tempdir
# would be preferable but this is fine for now.
TEMP_DIR="rsconnect-build-test"
TEMP_DIR = "rsconnect-build-test"

def register_uris(connect_server: str):
def register_content_endpoints(i: int, guid: str):
Expand All @@ -39,8 +39,8 @@ def register_content_endpoints(i: int, guid: str):
httpretty.GET,
f"{connect_server}/__api__/applications/{guid}/config",
body='{' +
f'"config_url": "{connect_server}/connect/#/apps/{guid}",' +
f'"logs_url": "{connect_server}/connect/#/apps/{guid}"' +
f'"config_url": "{connect_server}/connect/#/apps/{guid}",' +
f'"logs_url": "{connect_server}/connect/#/apps/{guid}"' +
'}',
adding_headers={"Content-Type": "application/json"},
)
Expand Down

0 comments on commit 55a730d

Please sign in to comment.