-
Notifications
You must be signed in to change notification settings - Fork 20
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
Check for QGIS version & path changes; update messages #110
Conversation
…thout cache usage
…ache rebuild if so
Instead, make a distinction between cache usage and no cache usage which function to use for more information. But do point at qgis_configure() when the user needs another installed version of QGIS.
…configure(quiet=FALSE)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cacheing is complicated! I did a local checkout and I can confirm that this works on MacOS (although on MacOS the path changes so linux is a better check as you've done above. Thanks!
Before, the message was: "Using 'qgis_process' at 'qgis_process'." Which is a bit odd.
170dfbd avoids the odd message: The silly aspect in below reprex is that switching from PATH to library(qgisprocess)
#> Using 'qgis_process' in the system PATH.
#> QGIS version: 3.26.1-Buenos Aires
#> Configuration loaded from '~/.cache/R-qgisprocess/cache-0.0.0.9000.rds'
#> Run `qgis_configure(use_cached_data = TRUE)` to reload cache and get more details.
#> >>> If you need another installed QGIS version, run `qgis_configure()`;
#> see its documentation if you need to preset the path of qgis_process.
#> - Using JSON for input serialization.
#> - Using JSON for output serialization.
detach("package:qgisprocess", unload = TRUE)
oldopt <- options("qgisprocess.path" = "/usr/bin/qgis_process")
library(qgisprocess)
#> The user's qgisprocess.path option or the R_QGISPROCESS_PATH environment variable specify a different qgis_process path (/usr/bin/qgis_process) than the cache did (qgis_process).
#> Hence rebuilding cache to reflect this change.
#> Using 'qgis_process' at '/usr/bin/qgis_process'.
#> QGIS version: 3.26.1-Buenos Aires
#> Metadata of 1024 algorithms successfully cached.
#> Run `qgis_algorithms()` to see them.
#> >>> If you need another installed QGIS version, run `qgis_configure()`;
#> see its documentation if you need to preset the path of qgis_process.
#> - Using JSON for input serialization.
#> - Using JSON for output serialization.
detach("package:qgisprocess", unload = TRUE)
options(oldopt)
suppressPackageStartupMessages(
library(qgisprocess) # keeps using /usr/bin/qgis_process since that works
)
qgis_configure() # reconfigures to using PATH
#> getOption('qgisprocess.path') was not found.
#> Sys.getenv('R_QGISPROCESS_PATH') was not found.
#> Trying 'qgis_process' on PATH...
#> Success!
#> QGIS version: 3.26.1-Buenos Aires
#> Saving configuration to '~/.cache/R-qgisprocess/cache-0.0.0.9000.rds'
#> Metadata of 1024 algorithms queried and stored in cache.
#> Run `qgis_algorithms()` to see them.
#> - Using JSON for input serialization.
#> - Using JSON for output serialization. Created on 2022-08-19 by the reprex package (v2.0.1) |
I had been postponing the merge since I wondered what is the possible overhead of checking the version of the cached It turns out that at least the OSGeo4W installation (Windows) has a version-agnostic path, so it's worthwile to have the same procedure in place in Windows. We could however drop this check in the case of MacOS, on condition that Further, about the version-specific filepaths in Windows & MacOS:
|
I appreciate the concern, although I think the overhead of one additional call is OK (I barely noticed). The main thing that takes a long time is all generating a cache of all the algorithms and that's still skipped opportunistically. I think it's better to be safe up front! |
Thanks. Further, the idea of notifying that a newer installed version is available but not in use could be tricky since it would rely on regexes to extract version numbers from different possible paths in Win & Mac, although it's doable (but is it worth the effort?). As an alternative, individual calls to each installed EDIT: there appear to be cases in MacOS where the path is version-agnostic too, e.g. the path outputted in #68 (comment). |
Fixes #94, fixes #109.
Please feel free to suggest improvements.
Checking for QGIS version change in
qgisprocess_cache$path
when loading cacheWhen a cache is going to be used, the QGIS version is first compared between the cache version and that of the program in the path defined by the cache. It makes the package take a little more time to load, but this seems worth it, since conflicts are expected (outdated cached algorithms) if a version change at the same location is not captured.
If versions differ, the cache will not be used and a new cache is built. Startup messages make this clear. The reprex below first overwrites an existing cache rds file, in order to mimic an outdated cache upon loading qgisprocess.
Created on 2022-08-19 by the reprex package (v2.0.1)
Further tweaks of messages
qgis_configure()
when a cache has been rebuilt; insteadqgis_algorithms()
is referred.qgis_configure(use_cached_data = TRUE)
is referred for more details:Created on 2022-08-19 by the reprex package (v2.0.1)
qgis_configure()
is called with argumentquiet=TRUE
(this was and remains so). Its default isFALSE
; if the user callsqgis_configure(use_cached_data = TRUE)
, the version check is reported:Created on 2022-08-19 by the reprex package (v2.0.1)
qgisprocess.path
option orR_QGISPROCESS_PATH
environmental variable contain a different path than the cache, this is reported at startup, just like the case of a version change:Created on 2022-08-19 by the reprex package (v2.0.1)
qgis_process
program as referred by the cached path is queried to do the cache-version check, the program must be available. This is checked first and if this errors, it is reported and reconfiguration is triggered:Created on 2022-08-19 by the reprex package (v2.0.1)
Session info