question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a cache keyword to read parameter values from disk

See original GitHub issue

It 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:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
HagaiHargilcommented, Feb 14, 2021

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.

1reaction
tlambert03commented, Feb 14, 2021

makes sense! good feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DiskCache Tutorial - Grant Jenks
Additional keyword parameters are discussed below. Cache objects are thread-safe and may be shared between threads. Two Cache objects may also reference the ......
Read more >
Improving read performance with dm-cache - Red Hat
These values represent the baseline performance. Hopefully, by putting a cache disk in place, these values can be improved.
Read more >
Caching in GitLab CI/CD
A cache is one or more files a job downloads and saves. Subsequent jobs that use the same cache don't have to download...
Read more >
Best practices for caching in Spark SQL - Towards Data Science
In Spark SQL caching is a common technique for reusing some computation. It has the potential to speedup other queries that are using...
Read more >
Caching and Pooling - Oracle
This fact gives rise to caching: the process of storing data in memory instead of disks. Caching is a common principle of Oracle...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found