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

quarto: more flexible discovery #1055

Merged
merged 1 commit into from
Mar 25, 2024
Merged

quarto: more flexible discovery #1055

merged 1 commit into from
Mar 25, 2024

Conversation

aronatkins
Copy link
Contributor

  • script.R with _quarto.yml is identified as quarto-static.
  • script.R without _quarto.yml is identified as quarto-static assuming it is not identified as some other content type.
  • script.R can be identified as the primary quarto-static document.
  • bundling only renames the primary script.R for shiny content.

A rendered script script.R might look like:

#' ---
#' title: cats are cats
#' ---

cat("i am a cat\n")

It may or may not have an accompanying _quarto.yml file. A simple version of the Quarto configuration might look like:

project:
    type: default
  • A directory containing this script.R is identified as quarto-static by rsconnect::writeManifest() and rsconnect::deployApp().
  • A directory containing this script.R and _quarto.yml is identified as quarto-static by rsconnect::writeManifest() and rsconnect::deployApp().

Other changes

This work also necessitated a change to how we bundle content. In particular, RStudio is able to run and deploy Shiny single-file applications which are contained in files not named app.R. For example, if we create a project containing the default Geyser app and save it to notapp.R rather than app.R, RStudio can deploy that file. It is able to deploy the Shiny application because notapp.R is renamed to app.R when the content is bundled.

The action taken by RStudio is effectively:

rsconnect::deployApp(appPrimaryDoc = "notapp.R")

This forces rsconnect to treat the content as a Shiny application and also forces the rename of notapp.R to app.R.

Prior to this change, rsconnect would rewrite any appPrimaryDoc=*.R to app.R regardless of content type. Unfortunately, appPrimaryDoc is computed internally and used by Quarto content. Because that primary asset was an R script, bundling renamed it. To avoid this, the rename is now specific to Shiny content.

Test that RStudio can deploy a Shiny application in a notapp.R file. Download that deployed bundle and see that the application has been renamed to app.R.

Other types of content (e.g., Plumber APIs, Quarto rendered scripts) do not have their R scripts renamed when deployed.

* script.R with _quarto.yml is identified as quarto-static.
* script.R without _quarto.yml is identified as quarto-static assuming it is
  not identified as some other content type.
* script.R can be identified as the primary quarto-static document.
* bundling only renames the primary script.R for shiny content.
@aronatkins aronatkins requested a review from toph-allen March 22, 2024 18:34
Copy link
Contributor

@toph-allen toph-allen left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Out of curiosity: I have only been loosely following the Connect-side changes for Quarto R scripts. I know we have kicked around the idea of an "R script" content type; is this substantially different for how we think that'd function? I'm just idly curious about the use cases for this, but that's totally unrelated to this PR looking good at a read-through.

@aronatkins
Copy link
Contributor Author

Out of curiosity: I have only been loosely following the Connect-side changes for Quarto R scripts. I know we have kicked around the idea of an "R script" content type; is this substantially different for how we think that'd function?

This uses Quarto to run the script because that gives us very opinionated ways of capturing output, attaching resources, etc. This may not be enough for some folks, but is much less invasive than rewriting an R script into an R Markdown document, for example.

@aronatkins aronatkins merged commit 71d0f6d into main Mar 25, 2024
10 checks passed
@aronatkins aronatkins deleted the aron-quarto-play branch March 25, 2024 19:51
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.

2 participants