-
Notifications
You must be signed in to change notification settings - Fork 58
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
Debug mode? #129
Comments
I have the same problem. On repeated calls with the same arguments, the hash seems to change. I've already set So I tried to debug the hash computation, to see where the apparent difference comes in. I defined a custom hash function mhash <- function(x) {
print(str(x))
h <- rlang::hash(x)
print(h)
h
} and then used it. msimulation <- memoize(
simulation,
cache = cache_filesystem("cache"),
envir = NULL,
hash = mhash
) My function seems to be never called, or at least the printed information doesn't make it to stdout. In case the output from mhash <- function(x) {
sink("mhash.log")
print(str(x))
h <- rlang::hash(x)
print(h)
sink()
h
} Since the file is never created, I assume that |
Reading the code, I now found that for "old-style" caches incl. The README mentions old-style caches, but not this side effect. Anyway print-style debugging is possible by specifying msimulation <- memoize(
simulation,
cache = cachem::cache_disk("cache"),
envir = NULL,
hash = mhash
) |
I faced a similar problem and came up with the following PR (been stale for a while): #144 |
No response at all in over two years. :-( |
I've recently been writing a bunch of code using memoise to let me "skip" long computation steps on subsequent runs. However, in the process I have run into repeated issues where the arguments to my memoised functions were not identical on successive runs of the same code (and that code doesn't do RNG), and debugging these issues has been a challenge. It would be nice if there was a "verbose mode" that could at least show the hashes of individual arguments and the final hash computed as the key to look up in the cache, so I can at least figure out which argument is changing unexpectedly between runs. In addition, I've found the following functions useful for debugging caching issues, and they might be worth including in the package (with some cleanup, obviously):
The text was updated successfully, but these errors were encountered: