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

New strategy to retrieve DESCRIPTION if project uses renv #931

Merged
merged 3 commits into from
Jul 25, 2023

Conversation

hadley
Copy link
Member

@hadley hadley commented Jul 24, 2023

Previously we'd always restore the packages from the lockfile, which I had expected to be fast since I had expected the packages to be in the cache. However, this doesn't appear to always be the case, so I instead use a simpler approach where I just force the user to resolve the problem. This means that we can always use the DESCRIPTION present in the .libPaths() making the code much simpler.

Fixes #930

@edavidaja could you please confirm that this fixes your problem?

Previously we'd always restore the packages from the lockfile, which I had expected to be fast since I had expected the packages to be in the cache. However, this doesn't appear to always be the case, so I instead use a simpler approach where I just force the user to resolve the problem. This means that we can always use the `DESCRIPTION` present in the `.libPaths()` making the code much simpler.

Fixes #930
@edavidaja
Copy link

now it's faster to include the lockfile 😁

> bench::mark(
+         rsconnect::writeManifest(appFiles = c("index.qmd")),
+         rsconnect::writeManifest(appFiles = c("index.qmd", "renv.lock")), iterations = 3
+     )
ℹ Capturing R dependencies with renvFound 118 dependenciesCapturing R dependencies from renv.lockFound 121 dependencies
# A tibble: 2 × 13
  expression                                                       min median `itr/sec` mem_alloc `gc/sec` n_itr  n_gc total_time result memory     time       gc      
  <bch:expr>                                                     <bch> <bch:>     <dbl> <bch:byt>    <dbl> <int> <dbl>   <bch:tm> <list> <list>     <list>     <list>  
1 "rsconnect::writeManifest(appFiles = c(\"index.qmd\"))"        8.07s  8.49s     0.118     114MB    1.14      3    29      25.4s <NULL> <Rprofmem> <bench_tm> <tibble>
2 "rsconnect::writeManifest(appFiles = c(\"index.qmd\", \"renv.… 6.38s  6.49s     0.155     113MB    0.618     3    12      19.4s <NULL> <Rprofmem> <bench_tm> <tibble>

thanks!

Copy link
Contributor

@aronatkins aronatkins left a comment

Choose a reason for hiding this comment

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

I will re-test console and push-button deploys from renv projects before merging; the deploy-pane R environment was different than what @hadley was seeing (because I only use the system R library, not a user library).

NEWS.md Outdated
@@ -1,5 +1,10 @@
# rsconnect (development version)

* `deployApp()` and `writeManifest()` now error if your library and lockfile
Copy link
Contributor

Choose a reason for hiding this comment

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

renv.lock rather than "lockfile".

"should err" or "should error"? I prefer "err", but others see that as an "error". 😜

Copy link
Member Author

Choose a reason for hiding this comment

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

I feel like "err" means to make a mistake; whereas here we are erroring (or more technically correct, throwing an error).

lib_dir = c(lib_dir, .libPaths())
)
if (!snapshot) {
lib_versions <- unlist(lapply(deps$Package, packageDescription, fields = "Version"))
Copy link
Contributor

Choose a reason for hiding this comment

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

You are about to load all the package descriptions just below; what about validating against deps$description rather than loading the same information twice?

Copy link
Member Author

Choose a reason for hiding this comment

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

Doh

@hadley hadley changed the title New strategy toi retrieve DESCRIPTION if project uses renv New strategy to retrieve DESCRIPTION if project uses renv Jul 24, 2023
Copy link
Contributor

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

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

LGTM, but agree with the comment re: avoiding the need to read DESCRIPTION files twice.

@hadley hadley merged commit 02cada1 into main Jul 25, 2023
10 checks passed
@hadley hadley deleted the renv-descriptions branch July 25, 2023 21:53
@aronatkins
Copy link
Contributor

aronatkins commented Jul 26, 2023

Confirmed deployment for an renv project from an environment that does not have a user R library.

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.

including renv.lock in writeManifest degrades performance
4 participants