Skip to content
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

Persist parameter values across sessions #160

Merged
merged 5 commits into from
Feb 25, 2021

Conversation

tlambert03
Copy link
Member

@tlambert03 tlambert03 commented Feb 23, 2021

closes #152.

This allows a user to save/restore the state of a FunctionGui by using the persist=True parameter either in FunctionGui or in the @magicgui decorator. Parameter values are stored to disk (in ~/.config/magicgui/cache) when they are changed, and reloaded upon future initialization (provided persist is still True the next time it is initialized):

@magicgui(persist=True)
def func(x, y, z):
    ...

@HagaiHargil, give this a spin when you have a chance and let me know if anything needs to be changed.

@codecov
Copy link

codecov bot commented Feb 23, 2021

Codecov Report

Merging #160 (7b445ed) into master (5b794f2) will decrease coverage by 0.34%.
The diff coverage is 79.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #160      +/-   ##
==========================================
- Coverage   90.85%   90.51%   -0.35%     
==========================================
  Files          28       29       +1     
  Lines        2723     2804      +81     
==========================================
+ Hits         2474     2538      +64     
- Misses        249      266      +17     
Impacted Files Coverage Δ
magicgui/_magicgui.py 96.22% <ø> (ø)
magicgui/_util.py 63.63% <63.63%> (ø)
magicgui/widgets/_bases/container_widget.py 94.57% <94.73%> (+0.02%) ⬆️
magicgui/widgets/_function_gui.py 96.95% <100.00%> (+0.37%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b794f2...cf8da32. Read the comment docs.

@HagaiHargil
Copy link
Contributor

I only now had a chance to use it and it works wonderfully! Thanks.

Wouldn't you prefer the cache to be in /home/user/.cache? Library like appdirs can take care of that, although pulling a dependency for this minor feature might be unwanted.

@tlambert03
Copy link
Member Author

yeah, i'd prefer to avoid the additional dependency, but I can certainly use the same destination folders as appdirs. will do, thanks for trying it out

@tlambert03 tlambert03 merged commit 0ae7f06 into pyapp-kit:master Feb 25, 2021
@tlambert03 tlambert03 deleted the persist branch February 25, 2021 23:09
@tlambert03 tlambert03 added the enhancement New feature or request label Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a cache keyword to read parameter values from disk
2 participants