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

GH-37907: [R] Setting rosetta variable is missing #37961

Merged
merged 7 commits into from
Oct 12, 2023

Conversation

fernandomayer
Copy link
Contributor

@fernandomayer fernandomayer commented Sep 30, 2023

Rationale for this change

The latest version of r/R/install-arrow.R was not working properly, since it was relying on the on_rosetta() function, which is not defined elsewhere. I just fixed the identification of rosetta in the script.

With the current code, the following gives an error

> source("https://raw.githubusercontent.com/apache/arrow/master/r/R/install-arrow.R") 
> install_arrow()
Error in on_rosetta() : could not find function "on_rosetta"

What changes are included in this PR?

It only removed the on_rosetta() function, which was not defined elsewhere, and reverted back to the rosetta object to identify if rosetta is present or not on a user's system.

Are these changes tested?

Yes. It was tested with the current code and the proposed PR. The proposed PR works as expected.

Are there any user-facing changes?

No.

@thisisnic thisisnic changed the title MINOR: [R] Failing installation script GH-37907: [R] Setting rosetta variable is missing Oct 2, 2023
@thisisnic
Copy link
Member

Thanks for making this PR! One small change, otherwise looks good to go :)

@@ -61,6 +61,7 @@ install_arrow <- function(nightly = FALSE,
verbose = Sys.getenv("ARROW_R_DEV", FALSE),
repos = getOption("repos"),
...) {
sysname <- tolower(Sys.info()[["sysname"]])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
sysname <- tolower(Sys.info()[["sysname"]])

Comment on lines 83 to 84
rosetta <- identical(sysname, "darwin") && identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")
if (rosetta) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
rosetta <- identical(sysname, "darwin") && identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")
if (rosetta) {
rosetta <- on_rosetta()
if (rosetta) {

Another PR implemented a function on_rosetta() that already does these checks, so we can simplify this bit here, and remove the creation of the sysname variable above.

Copy link
Contributor Author

@fernandomayer fernandomayer Oct 3, 2023

Choose a reason for hiding this comment

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

Hi @thisisnic

I believe that for the package this is fine. I saw that the on_rosetta() function was defined in r/R/arrow-package.R and that should work.

However, I'm thinking of the case where the user just uses the r/R/install-arrow.R as a standalone script, as suggested here (as it's the way I use, for example). In this way, the on_rosetta() function is not found, as the script is not self-contained anymore.

So my proposal would be to just change the on_rosetta() function from r/R/arrow-package.R to r/R/install-arrow.R, as this would not affect the former, but it would make the latter self-contained again.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see the standalone use being suggested, maybe we need to clarify the docs? As I understand it install_arrow is for use when you have the arrow package installed but want to do one of the following:

You have arrow installed and want to upgrade to a different version
You want to try to reinstall and fix issues with Linux C++ binaries
You want to install a development build

@thisisnic please correct me if my assessment on that is wrong?

Copy link
Member

Choose a reason for hiding this comment

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

@assignUser It's here: https://arrow.apache.org/docs/r/articles/install.html?q=install_arrow#using-install_arrow

Although this function is part of the arrow package, it is also available as a standalone script, so you can access it without first installing the package:

In the case of "You want to install a development build", folks may not already have arrow installed.

On a different note, there have been other PRs in this area of the codebase merged recently, so this PR may need a rebase to see how the changes affect it, and what needs doing.

Copy link
Member

Choose a reason for hiding this comment

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

So my proposal would be to just change the on_rosetta() function from r/R/arrow-package.R to r/R/install-arrow.R, as this would not affect the former, but it would make the latter self-contained again.

This is a good catch, I'm working on a review, but overall I'm pro moving this function to install-arrow.R so that it remains self-contained. Thank you for catching it!

In this way, the on_rosetta() function is not found, as the script is not self-contained anymore.

We don't have to do this here, but we should at least make an issue that we should write a test that tests that the script remains self-contained. It would have caught this bug, for example!

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Oct 2, 2023
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 3, 2023
@assignUser
Copy link
Member

@thisisnic should we merge this before the release?

@thisisnic
Copy link
Member

@jonkeane You most recently worked on the code that this PR touches and I'm not sure where is best for this function - I don't suppose you'd mind giving this a quick look over?

@thisisnic
Copy link
Member

@thisisnic should we merge this before the release?

Yes, but it'll need a final change before merging

Copy link
Member

@jonkeane jonkeane left a comment

Choose a reason for hiding this comment

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

Thanks @fernandomayer for the catch + the fix. Like I mentioned in a comment up above, I'm supportive of moving the function definition to arrow-install.R so that it can be self contained again.

Would you mind also moving the test for this from test-arrow-package.R (and delete that file since it's the only test there) and put the test in test-install-arrow.R ?

Thanks!


on_rosetta <- function() {
identical(tolower(Sys.info()[["sysname"]]), "darwin") &&
identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")
Copy link
Member

Choose a reason for hiding this comment

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

We do actually need / want to suppressWarnings() and ignore.stderr = TRUE here as well. On x86 machines this call will throw a warning + print to the console complaining that it can't find the proc_translated argument there.

Suggested change
identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")
identical(suppressWarnings(system("sysctl -n sysctl.proc_translated", intern = TRUE, ignore.stderr = TRUE), "1")

@@ -267,3 +268,8 @@ wslify_path <- function(path) {
end_path <- strsplit(path, drive_expr)[[1]][-1]
file.path(wslified_drive, end_path)
}

on_rosetta <- function() {
identical(tolower(Sys.info()[["sysname"]]), "darwin") &&
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to also keep this comment (though edited a bit for clarity):

Suggested change
identical(tolower(Sys.info()[["sysname"]]), "darwin") &&
# make sure to suppress warnings and ignore the stderr so that this is silent on x86
identical(tolower(Sys.info()[["sysname"]]), "darwin") &&

Comment on lines 83 to 84
rosetta <- identical(sysname, "darwin") && identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")
if (rosetta) {
Copy link
Member

Choose a reason for hiding this comment

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

So my proposal would be to just change the on_rosetta() function from r/R/arrow-package.R to r/R/install-arrow.R, as this would not affect the former, but it would make the latter self-contained again.

This is a good catch, I'm working on a review, but overall I'm pro moving this function to install-arrow.R so that it remains self-contained. Thank you for catching it!

In this way, the on_rosetta() function is not found, as the script is not self-contained anymore.

We don't have to do this here, but we should at least make an issue that we should write a test that tests that the script remains self-contained. It would have caught this bug, for example!

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Oct 10, 2023
@assignUser
Copy link
Member

It looks like this would also fix a nightly fail/cran warning: https://github.com/ursacomputing/crossbow/actions/runs/6463099167/job/17545762151#step:6:3794

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 12, 2023
@jonkeane
Copy link
Member

I hope you don't mind that I pushed those changes requested to this branch so that we can get this in before the upcoming release.

@jonkeane
Copy link
Member

@github-actions crossbow submit test-r-install-local

@jonkeane
Copy link
Member

Once the crossbow build is done I'm going to merge this, unless there are objections

@github-actions
Copy link

Revision: dfec06a

Submitted crossbow builds: ursacomputing/crossbow @ actions-efacb091fb

Task Status
test-r-install-local Github Actions

@jonkeane
Copy link
Member

I've also created #38251 to track adding a test for this self-containedness

r/R/install-arrow.R Outdated Show resolved Hide resolved
@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Oct 12, 2023
@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting changes Awaiting changes labels Oct 12, 2023
@thisisnic thisisnic merged commit 7b7bbdc into apache:main Oct 12, 2023
12 checks passed
@thisisnic thisisnic removed the awaiting merge Awaiting merge label Oct 12, 2023
raulcd pushed a commit that referenced this pull request Oct 13, 2023
### Rationale for this change

The latest version of `r/R/install-arrow.R`  was not working properly, since it was relying on the `on_rosetta()` function, which is not defined elsewhere. I just fixed the identification of rosetta in the script.

With the current code, the following gives an error

````r
> source("https://raw.githubusercontent.com/apache/arrow/master/r/R/install-arrow.R") 
> install_arrow()
Error in on_rosetta() : could not find function "on_rosetta"
````

### What changes are included in this PR?

It only removed the `on_rosetta()` function, which was not defined elsewhere, and reverted back to the `rosetta` object to identify if rosetta is present or not on a user's system.

### Are these changes tested?

Yes. It was tested with the current code and the proposed PR. The proposed PR works as expected.

### Are there any user-facing changes?

No.

* Closes: #37907

Lead-authored-by: Fernando Mayer <[email protected]>
Co-authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Nic Crane <[email protected]>
@fernandomayer
Copy link
Contributor Author

Thanks @jonkeane and @thisisnic

I can confirm that now the command

source("https://raw.githubusercontent.com/apache/arrow/main/r/R/install-arrow.R")
install_arrow()

works as expected again, as stated in the documentation https://arrow.apache.org/docs/r/articles/install.html?q=install_arrow#using-install_arrow

@jonkeane
Copy link
Member

Thanks again @fernandomayer for the issue + PR

@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit 7b7bbdc.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 6 possible false positives for unstable benchmarks that are known to sometimes produce them.

JerAguilon pushed a commit to JerAguilon/arrow that referenced this pull request Oct 23, 2023
### Rationale for this change

The latest version of `r/R/install-arrow.R`  was not working properly, since it was relying on the `on_rosetta()` function, which is not defined elsewhere. I just fixed the identification of rosetta in the script.

With the current code, the following gives an error

````r
> source("https://raw.githubusercontent.com/apache/arrow/master/r/R/install-arrow.R") 
> install_arrow()
Error in on_rosetta() : could not find function "on_rosetta"
````

### What changes are included in this PR?

It only removed the `on_rosetta()` function, which was not defined elsewhere, and reverted back to the `rosetta` object to identify if rosetta is present or not on a user's system.

### Are these changes tested?

Yes. It was tested with the current code and the proposed PR. The proposed PR works as expected.

### Are there any user-facing changes?

No.

* Closes: apache#37907

Lead-authored-by: Fernando Mayer <[email protected]>
Co-authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Nic Crane <[email protected]>
loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
### Rationale for this change

The latest version of `r/R/install-arrow.R`  was not working properly, since it was relying on the `on_rosetta()` function, which is not defined elsewhere. I just fixed the identification of rosetta in the script.

With the current code, the following gives an error

````r
> source("https://raw.githubusercontent.com/apache/arrow/master/r/R/install-arrow.R") 
> install_arrow()
Error in on_rosetta() : could not find function "on_rosetta"
````

### What changes are included in this PR?

It only removed the `on_rosetta()` function, which was not defined elsewhere, and reverted back to the `rosetta` object to identify if rosetta is present or not on a user's system.

### Are these changes tested?

Yes. It was tested with the current code and the proposed PR. The proposed PR works as expected.

### Are there any user-facing changes?

No.

* Closes: apache#37907

Lead-authored-by: Fernando Mayer <[email protected]>
Co-authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Nic Crane <[email protected]>
dgreiss pushed a commit to dgreiss/arrow that referenced this pull request Feb 19, 2024
### Rationale for this change

The latest version of `r/R/install-arrow.R`  was not working properly, since it was relying on the `on_rosetta()` function, which is not defined elsewhere. I just fixed the identification of rosetta in the script.

With the current code, the following gives an error

````r
> source("https://raw.githubusercontent.com/apache/arrow/master/r/R/install-arrow.R") 
> install_arrow()
Error in on_rosetta() : could not find function "on_rosetta"
````

### What changes are included in this PR?

It only removed the `on_rosetta()` function, which was not defined elsewhere, and reverted back to the `rosetta` object to identify if rosetta is present or not on a user's system.

### Are these changes tested?

Yes. It was tested with the current code and the proposed PR. The proposed PR works as expected.

### Are there any user-facing changes?

No.

* Closes: apache#37907

Lead-authored-by: Fernando Mayer <[email protected]>
Co-authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Nic Crane <[email protected]>
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.

[R] Setting rosetta variable is missing
4 participants