Skip to content

Conversation

@MichaelChirico
Copy link
Contributor

What changes were proposed in this pull request?

Some tidying of sh scripts in R/

Why are the changes needed?

Not strictly needed, but the 'devtools' %in% installed.packages() line in particular is "improper" / proabbly slow

Does this PR introduce any user-facing change?

No

How was this patch tested?

Not

@SparkQA
Copy link

SparkQA commented Apr 30, 2020

Test build #122116 has finished for PR 28419 at commit fb355ea.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Apr 30, 2020

Test build #122125 has finished for PR 28419 at commit c396869.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

devtools::install_github("jimhester/[email protected]")
# Installs lintr if needed
if (!requireNamespace("lintr")) {
install.packages('lintr')
Copy link
Member

Choose a reason for hiding this comment

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

Looks like there was sort of a reason for installing a particular version: #26564 (comment) But the logic seems to be "use the new 2.0.0 version". This would always pick up the latest. I'm guessing that's OK, @dongjoon-hyun ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the comment said the CRAN version wasn't recent enough so I assumed >= 2.0.0 would be fine. & we're passing so that's a good sign.

Anyway, yes, would be good to confirm on this.

Copy link
Member

Choose a reason for hiding this comment

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

Ya. It looks okay since this seems to install lintr 2.0.1 as of today.


# Generate Rd files if devtools is installed
"$R_SCRIPT_PATH/Rscript" -e ' if("devtools" %in% rownames(installed.packages())) { library(devtools); setwd("'$FWDIR'"); devtools::document(pkg="./pkg", roclets=c("rd")) }'
"$R_SCRIPT_PATH/Rscript" -e ' if(requireNamespace("devtools", quietly=TRUE)) { setwd("'$FWDIR'"); devtools::document(pkg="./pkg", roclets="rd") }'
Copy link
Member

Choose a reason for hiding this comment

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

It seems fine but I don't know these commands; any potential behavior change here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

requireNamespace is a more minimal test to be sure devtools:: will work correctly.

This is the more common route to check for available functionality, e.g. for Suggested (not required) packages. this is how the suggested arrow dependency is handled, for example:

grep -r "requireNamespace" R/pkg/R -n
R/pkg/R/types.R:91:  if (!requireNamespace("arrow", quietly = TRUE)) {
R/pkg/R/deserialize.R:235:  if (requireNamespace("arrow", quietly = TRUE)) {
R/pkg/R/SQLContext.R:152:  if (requireNamespace("arrow", quietly = TRUE)) {
R/pkg/R/serialize.R:225:  if (requireNamespace("arrow", quietly = TRUE)) {
R/pkg/R/DataFrame.R:1229:              if (requireNamespace("arrow", quietly = TRUE)) {

The installed.packages is much more cumbersome -- it looks up the full set of available packages, then searches to see if this particular one is there.

@srowen srowen changed the title [R] small tidying of sh scripts for R [MINOR][R] small tidying of sh scripts for R Apr 30, 2020
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM. Merged to master. Thank you, @MichaelChirico and @srowen .

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants