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

Include the SVN revision in the r-devel package cache key #699

Merged
merged 7 commits into from
Apr 1, 2023

Conversation

schloerke
Copy link
Contributor

When testing on r-devel, breaking internal core R code changes can happen within the same day. It would be good to try to allow for rapid GHA development with a consistent cache key while busting the cache if the internal core R code changes. To bust this cache, the SVN revision number has been included (in addition to make formatting similar with regular r-version values).

Existing output of non-devel r-version value:

[1] "R version 4.1.3 (2022-03-10)"

Existing output of an r-devel r-version value:

[1] "4.3.0"

Proposed output of an r-devel r-version value:

[1] "R version 4.3.0 (r83776)"

Recent motivation:

cc @jcheng5

@gaborcsardi
Copy link
Member

Thanks! Including the SVN revision there is not great, because the graphics API only changes ~ once a year, and the SVN revision changes practically every day.

So maybe we could query the graphics API version instead, plus maybe .Internal(internalsID())?

@schloerke
Copy link
Contributor Author

I like the idea of using the internalsID(), but https://github.com/r-devel/r-svn/blame/bbf4b924e66dbe097b0570ce549f9b77698dba7c/src/include/Defn.h#L95 hasn't changed in two years. However the install error happened recently.

I'm not familiar enough on the internals to suggest a better value 😢 . (I did not know about internalsID()). And using a collection of internal version values (like the multiple graphics version values) seems incomplete and error prone.

the SVN revision changes practically every day

Fair. There were ~15 commits just today. This would bust the cache quite often.


I'll defer to you if we can enhance the cache key. But finding the error message while testing was quite confusing and I'd rather err on longer compute times than confusing errors.

@gaborcsardi
Copy link
Member

hasn't changed in two years. However the install error happened recently.

I meant the graphics api version + the internal ID. There is only one graphics api version number, an integer number. Those are just symbolic names for the various (recent) versions.

Fair. There were ~15 commits just today. This would bust the cache quite often.

But we only have at most one R-devel build per day, so it is once a day at most. But that's not ideal, either.

Anyway, I think the graphics api version + the internal ID would work.

@jcheng5
Copy link
Member

jcheng5 commented Feb 16, 2023

Anyway, I think the graphics api version + the internal ID would work.

That sounds reasonable to me. There's value in these workflows completing quickly.

@schloerke
Copy link
Contributor Author

Graphics API Version + Internal ID sounds good then!

@gaborcsardi Do you have another incantation to expose this value? I could not find a way without making/compiling/calling a C function. Thank you!

@gaborcsardi
Copy link
Member

Yeah, one is .Internal(internalsID()), and the other one needs C code. It goes roughly like this, I haven't tested it much:

lines <- c(
  "#include <Rinternals.h>",
  "#include <R_ext/GraphicsEngine.h>",
  "SEXP ghapi_version() {",
  "return ScalarInteger(R_GE_getVersion());",
  "}"
)

dir.create(tmp <- tempfile())
src <- file.path(tmp, "ghapi.c")
writeLines(lines, src)
so <- file.path(tmp, paste0("ghapi", .Platform$dynlib.ext))

rbin <- file.path(R.home("bin"), "R")
tools:::.shlib_internal(c("-o", so, src))
dl <- dyn.load(so)

ghapi_version <- getNativeSymbolInfo("ghapi_version", dl)
cat(.Call(ghapi_version))

and you need to look at the last line of the output only. IDK if there is a way to discard the rest of the output.

@jcheng5
Copy link
Member

jcheng5 commented Feb 16, 2023

Looks like you can get it by calling dev.new(); recordPlot() and then it’s one of the attributes on the returned object.

@schloerke
Copy link
Contributor Author

Running the devel code path on R 4.1.3:

[1] "R version 4.1.3 (ge14:2fdf6c18-697a-4ba7-b8ef-11c0d92f1327)"

@codecov-commenter
Copy link

Codecov Report

Merging #699 (730d281) into v2-branch (9611ec5) will not change coverage.
The diff coverage is n/a.

❗ Current head 730d281 differs from pull request most recent head fc529f1. Consider uploading reports for the commit fc529f1 to get more accurate results

@@             Coverage Diff             @@
##           v2-branch      #699   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
===========================================
  Files              2         2           
  Lines             10        10           
===========================================
  Hits              10        10           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@gaborcsardi gaborcsardi merged commit 9e545e6 into r-lib:v2-branch Apr 1, 2023
@gaborcsardi
Copy link
Member

Thanks!

@github-actions
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2023
@schloerke schloerke deleted the devel_lib_cache_key branch April 18, 2023 13:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants