Add a cache keyword to read parameter values from disk
See original GitHub issueIt could be nice if I could decorate a function with a ‘cache’ keyword so that when this function is run it will write to disk the last parameter values used to run it. Later, when it’s re-run, these values will be read back and override any default keyword arguments that the function might have:
Example:
@magicgui(cache=True, call_button='Run')
def test(a: int, b: int = 0) -> int:
return a + b
On its first run, the values displayed will be ‘empty’ for a and 0 for b. If I run it with a = 2 magicgui will write to the user’s cache directory a snippet with a = 2, b = 0. This snippet will be looked-for and loaded during a consecutive call to test, as long as its run as a GUI (and not a standard function).
I tried implementing this behavior as a wrapper class but it became clear that I’ll have to redo it for each and every magicgui script I have, and the work itself was quite tedious. If you think that this cache keyword fits the overall idea of magicgui I might try doing it myself, but not in the immediate future.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)

Top Related StackOverflow Question
I’ll be happy to see it done however. I won’t have much spare time in the coming weeks, and this isn’t top priority for me, so I can’t help ATM.
makes sense! good feature.