-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Small changes to caching #9438
Merged
Merged
Small changes to caching #9438
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
95ec3b4
caching changes
abidlabs 3929437
add changeset
gradio-pr-bot f1d3b24
typo
abidlabs 9561424
Merge branch 'caching-changes' of github.com:gradio-app/gradio into c…
abidlabs bc77a3b
typo
abidlabs 63be0dc
Merge branch '5.0-dev' into caching-changes
abidlabs b340684
changes
abidlabs 579644d
fix
abidlabs 91b1c70
fix
abidlabs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,23 +139,23 @@ def __init__( | |
) | ||
|
||
if cache_examples is None: | ||
if cache_examples_env := os.getenv("GRADIO_CACHE_EXAMPLES"): | ||
if cache_examples_env.lower() == "true": | ||
if fn is not None and outputs is not None: | ||
self.cache_examples = True | ||
else: | ||
self.cache_examples = False | ||
elif utils.get_space() and fn is not None and outputs is not None: | ||
self.cache_examples = True | ||
else: | ||
self.cache_examples = cache_examples or False | ||
else: | ||
if cache_examples not in [True, False]: | ||
raise ValueError( | ||
"The `cache_examples` parameter must either: True or False." | ||
) | ||
if os.getenv("GRADIO_CACHE_EXAMPLES", "").lower() == "true": | ||
if fn is not None and outputs is not None: | ||
self.cache_examples = True | ||
else: | ||
self.cache_examples = False | ||
elif cache_examples == "lazy": | ||
warnings.warn( | ||
"The `cache_examples` parameter no longer accepts a value of 'lazy'. To enable lazy caching in " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not enable lazy caching in this case instead of not caching at all since we're soft deprecating? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that's fair actually, I'll make the change |
||
"Gradio, you should set `cache_examples=True`, and `cache_mode='lazy'. Defaulting to cache_examples=False" | ||
) | ||
self.cache_examples = False | ||
elif cache_examples in [True, False]: | ||
self.cache_examples = cache_examples | ||
|
||
else: | ||
raise ValueError( | ||
f"The `cache_exaples` parameter should be either True or False, not {cache_examples}" | ||
) | ||
if self.cache_examples and (fn is None or outputs is None): | ||
raise ValueError("If caching examples, `fn` and `outputs` must be provided") | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I also got rid of this logic and instead set the
GRADIO_CACHE_EXAMPLES
env in the Spaces Dockerfile: https://github.com/huggingface-internal/workloads/pull/2379