M2
M2 copied to clipboard
runProgram/findProgram wishlist
This is somehow the first time I've ever had to deal with these two methods, so here are some thoughts about what I expected before reading the documentation:
normaliz = findProgram "normaliz"should work (e.g. if I'm just prototyping)runProgram("normaliz", "--version")should also work (e.g. if I'm just lazy)status runProgram(normaliz, "--version")should give the return codetoString runProgram(normaliz, "--version")should give the string outputnormaliz << inputshould do the obvious thing, which is to run with that inputMinimumVersionwould be useless if I didn't know bash-fu. Why not take the minimum version and then a regex rule for getting the version from the output:
normaliz = findProgram("normaliz", "--version", "2.8", "Normaliz ([0-9.]+)")
Otherwise it would be simpler to just use get "!normaliz --version" (which is impossible to find in the documentation unless you already know about it!). Alternatively, if the version has to be extracted from a file, I would expect something like:
ver = select("NMZ_VERSION *([0-9.]+)", "$1", get "libnormaliz/version.h")
normaliz = findProgram("normaliz", "--version", ver)
That is, if there are only three arguments, the third argument is the stated version, but if there are four arguments, the 3rd one is the minimum version and the 4th is the regex for extracting it.
cc: @d-torrance
Great suggestions!
Just to clarify -- is this the behavior you were suggesting for Program << Thing?
i1 : M2 = findProgram "M2"
o1 = M2
o1 : Program
i2 : M2 << "2 + 2"
o2 = 0
o2 : ProgramRun
i3 : toString oo
o3 =
i1 : 2 + 2
o1 = 4
Exactly! It may be too much syntactic sugar, but easy to remember syntax gets used more :) We can think about this longer also, because perhaps something like this would also be nice:
runProgram(M2, "-q") << "2 + 2"
but that might require non-superficial changes.
Updates:
msolve = findProgram "msolve"doesn't work because runningmsolvealone prints help and returns code 1, which is not an uncommon choice. As long as the program is found and it is executable, I think this should return aProgramobject (i.e. the user chose not to provide a test command, so no need to test!)- after running the above,
msolve(args)should just work. - moreover
msolve_args << stdinputshould also work. - running
findProgram("msolve", MinimumVersion => ("0.6.7", "msolve -V"), RaiseError => false)returns null if the version is too low. I think it should still return aProgramobject, but either with a warning orrunProgramshould then give an error. program#"version"should beprogram.Versionperhaps.runProgramshould also accept a list/sequence/hashtable/optiontable of args and insert spaces.
runProgramshould have an option to display the stdout or at least stderr live, rather than keeping it for the end. It's important to know that status of some program (e.g. msolve) if it's going to take hours/days.
@d-torrance do you think you could implement this one soon? I actually think without this I would prefer to not use runProgram in Msolve.