Closed hcorson-dosch-usgs closed 2 years ago
First part of this doesn't require us to make the decision as to where we solve the problem (this repo vs the GLM3r
pkg itself). We need to figure out how to extract "3.1.0a4"
from " | General Lake Model (GLM) Version 3.1.0a4 |"
After that we'll check back in with GLM3r devs/users to see if this feature would be useful to others and welcomed as an update to the pkg. I think it may be easier to do there because it already handles issues with different OS's and env variables.
Oh ok - I can tackle that regex, then, if you like.
Sorry, I was just stating how I'd approach the problem. I'm good with taking it on.
stringr::str_extract(" | General Lake Model (GLM) Version 3.1.0a4 |", '(?<=Version\\ ).+?(?=\\ )')
[1] "3.1.0a4"
Seems to do it. That would be a solution for the pipeline since we don't care about the stringr dependency. But that won't work for GLM3r
pkg since we don't want to add other dependencies without a really good reason.
strcapture('(?<=Version\\ ).+?(?=\\ )', " | General Lake Model (GLM) Version 3.1.0a4 |", proto = data.frame(version = character(0)), perl = TRUE)
Error in strcapture("(?<=Version\\ ).+?(?=\\ )", " | General Lake Model (GLM) Version 3.1.0a4 |", :
The number of captures in 'pattern' != 'length(proto)'
Fails for me but not sure why it is capturing more or less than one thing
In base R:
regmatches(" | General Lake Model (GLM) Version 3.1.0a4 |", regexec("(?<=Version\ ).+?(?=\ )", " | General Lake Model (GLM) Version 3.1.0a4 |", perl = TRUE))[[1]]
[1] "3.1.0a4"
@hcorson-dosch this seems to be what we'd want: https://github.com/jread-usgs/GLM3r/commit/830d04ac5b29ca831cbea8ec98026190c331acd8
glm_version()
-------------------------------------------------------
| General Lake Model (GLM) Version 3.2.0a3 |
-------------------------------------------------------
glm built using gcc version 4.2.1
glm_version(as_char = TRUE)
[1] "3.2.0a3"
Great! should I go ahead and add this into my PR?
Sure - would you be adding the glm_version(as_char = TRUE)
to your PR in that tibble
and suggesting a GH install, or would you add the whole GLM3r change to the PR? I think I'd recommend the former, keeping this in GLM3r, and I can do a PR on that repo and also up the package version so it is clear what needs to be installed (and eventually, what needs to be in the shifter container). But let me know if you were thinking of pulling that whole change and backing code in here.
Oh, gosh, I'm sorry. I was referring to adding the regex only, but I was forgetting my own note about the glm path 🤦♀️.
I can add either a) add glm_version(as_char = TRUE)
and suggest a GH install, or b) leave my PR as is, and we can wait to add that to the tibble once the change is PR'd into GLM3r.
I think keeping your PR as-is and leaving this issue open until we resolve it would be good. We'll get a sense if others are interested in this functionality soon
Merged here https://github.com/GLEON/GLM3r/pull/24
We'd like to be able to programmatically extract the GLM version and include it in the diagnostic tble we return from our model runs.
the function
GLM3r::glm_version()
returns a message, and the value0
:Jordan did some digging, and realized we could set
stdout=TRUE
to have the output go to the assignment value. That gets us the following:That almost gets us there, but there's two issues: 1) we'd need to parse that line with regex (not a big deal) 2) I'm having to manually provide my path to GLM, despite it being set with
Sys.setenv(GLM_PATH = "C:/Users/hcorson-dosch/Documents/R/AquaticEcoDynamics/GLM/glm")
, so we'd either needsystem2
to recognize that path or pass the path as an argument to our execution function (more of a pain).In light of these issues, Jordan is recommending solving this issue at the
GLM3r
package level, by solving this issue he created and putting it in a PR to the package and then updating the package version.