Skip to content

Conversation

@wch
Copy link
Collaborator

@wch wch commented Mar 20, 2024

This PR does the following:

  • Adds support for Shiny Express apps when writing manifest files.
  • When deploying apps via rsconnect deploy, only try to detect Shiny Express for Shiny apps. (Previously it would attempt the detection for other types of apps as well, including api, streamlit, voila, etc.)
  • Adds and corrects type annotations. (This was a helpful step before modifying the code to do the things above.) These changes only modify type annotations and should have no run-time effect.

Intent

This addresses item (2) in posit-dev/py-shiny#1232: rsconnect write-manifest shiny does not support Shiny Express apps.

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change

Approach

Automated Tests

Directions for Reviewers

Checklist

  • I have updated CHANGELOG.md to cover notable changes.
  • I have updated all related GitHub issues to reflect their current state.

@wch wch force-pushed the shiny-express-manifest branch from cfb2840 to a638e5d Compare March 21, 2024 00:04
@wch wch force-pushed the shiny-express-manifest branch from a638e5d to 14fd553 Compare March 21, 2024 15:35
@wch wch force-pushed the shiny-express-manifest branch from 7dc0290 to 96e243a Compare March 21, 2024 16:22
@github-actions
Copy link

github-actions bot commented Mar 21, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
4543 3238 71% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/actions.py 35% 🟢
rsconnect/actions_content.py 66% 🟢
rsconnect/api.py 71% 🟢
rsconnect/bundle.py 80% 🟢
rsconnect/main.py 62% 🟢
TOTAL 63% 🟢

updated for commit: 6267897 by action🐍

failed("Error: " + str(exc))
except Exception as exc:
if click.get_current_context("verbose"):
if click.get_current_context(True):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was an existing bug, which mypy started noticing after I made some other changes.

According to the docs, click.get_current_context wants a boolean, not a string. If False, it will throw an error if there's no context; if True, it'll return None in that situation. I set it to True because I think the intent here was not to throw another error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop the if condition entirely and always print the traceback in this case. It looks like the original intent was to check the verbose flag from the command line and only print the traceback in verbose mode. The checks for RSConnectException and EnvironmentException suppress tracebacks for known kinds of exceptions (where we provide meaningful error messages); the rest can have trackbacks for debugging.

@wch wch marked this pull request as ready for review March 21, 2024 17:03
Comment on lines +14 to +17
if sys.version_info >= (3, 10):
from typing import ParamSpec
else:
from typing_extensions import ParamSpec
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to just import from typing_extensions, even for newer versions of Python, but I made this import conditional on version so that it'll be clear that the condition can be removed in the future when 3.10 support is dropped.

Comment on lines +902 to +922
name: Optional[str],
server: Optional[str],
api_key: Optional[str],
insecure: bool,
cacert: str,
cacert: Optional[str],
static: bool,
new: bool,
app_id: str,
title: str,
python,
force_generate,
app_id: Optional[str],
title: Optional[str],
python: Optional[str],
force_generate: bool,
verbose: int,
file: str,
extra_files,
extra_files: Sequence[str],
hide_all_input: bool,
hide_tagged_input: bool,
env_vars: typing.Dict[str, str],
image: str,
disable_env_management: bool,
env_management_py: bool,
env_management_r: bool,
env_vars: dict[str, str],
image: Optional[str],
disable_env_management: Optional[bool],
env_management_py: Optional[bool],
env_management_r: Optional[bool],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I've changed these annotations to reflect the actual possible values of what click will pass to the function. This is true here and with the other functions.

Comment on lines +2009 to +2013
if app_mode == AppModes.PYTHON_SHINY:
with cli_feedback("Inspecting Shiny for Python app"):
if is_express_app(entrypoint + ".py", directory):
entrypoint = "shiny.express.app:" + escape_to_var_name(entrypoint + ".py")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part that adds support for Shiny Express when writing manifest files.

failed("Error: " + str(exc))
except Exception as exc:
if click.get_current_context("verbose"):
if click.get_current_context(True):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop the if condition entirely and always print the traceback in this case. It looks like the original intent was to check the verbose flag from the command line and only print the traceback in verbose mode. The checks for RSConnectException and EnvironmentException suppress tracebacks for known kinds of exceptions (where we provide meaningful error messages); the rest can have trackbacks for debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants