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
Allow config to include non-pickle-able values #7415
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/5301c417716020bf57c52beefc48de10c4254993/gradio-4.18.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@5301c417716020bf57c52beefc48de10c4254993#subdirectory=client/python" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
gradio/routes.py
Outdated
config = add_root_url(config, root_path) | ||
config = app.get_blocks().config | ||
previous_root = config.get("root", None) | ||
if previous_root is None or previous_root != root: |
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.
The main change in this PR being that we no longer need to traverse the config if the root
has not change
config = copy.deepcopy(app.get_blocks().config) | ||
config["root"] = root_path | ||
config = add_root_url(config, root_path) | ||
config = app.get_blocks().config |
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 think it would be worth abstracting this into a helper function with docstring explaining the logix even though it's only used in two places to make the code more "documentable". Nit though.
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.
Can do
Thanks @freddyaboulton for the review! I've made the suggested changes and am putting this on auto-merge |
Closes: #7412
As part of the recent changes around
root
, I added a step which deep-copied the config. This prevented the config from including any objects that could not be pickled. I've refactored the code so that we do not need to deepcopy the config any more. As an added bonus, this should mostly eliminate the performance issues caused by #7374Simple repro: