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

Updating to Gradio 4.18.0 causing TypeError: cannot pickle 'dict_keys' object #7412

Closed
1 task done
samadwar opened this issue Feb 14, 2024 · 1 comment · Fixed by #7415
Closed
1 task done

Updating to Gradio 4.18.0 causing TypeError: cannot pickle 'dict_keys' object #7412

samadwar opened this issue Feb 14, 2024 · 1 comment · Fixed by #7415
Assignees
Labels
bug Something isn't working

Comments

@samadwar
Copy link

Describe the bug

It seems Gadrio 4.18.0 is causing an issue where I get the below error, same code works with v4.17.0.

As I work around I had to pin gradio version to 4.17.0. It seems the issue is related to adding deepcopy in routers.py (see here)

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

Full code can be found here

Screenshot

No response

Logs

2024-02-14T00:21:39.815Z ERROR:    Exception in ASGI application
2024-02-14T00:21:39.815Z Traceback (most recent call last):
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 412, in run_asgi
2024-02-14T00:21:39.815Z     result = await app(  # type: ignore[func-returns-value]
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
2024-02-14T00:21:39.815Z     return await self.app(scope, receive, send)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
2024-02-14T00:21:39.815Z     await super().__call__(scope, receive, send)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
2024-02-14T00:21:39.815Z     await self.middleware_stack(scope, receive, send)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
2024-02-14T00:21:39.815Z     raise exc
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
2024-02-14T00:21:39.815Z     await self.app(scope, receive, _send)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/cors.py", line 83, in __call__
2024-02-14T00:21:39.815Z     await self.app(scope, receive, send)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
2024-02-14T00:21:39.815Z     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
2024-02-14T00:21:39.815Z     raise exc
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
2024-02-14T00:21:39.815Z     await app(scope, receive, sender)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 758, in __call__
2024-02-14T00:21:39.815Z     await self.middleware_stack(scope, receive, send)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 778, in app
2024-02-14T00:21:39.815Z     await route.handle(scope, receive, send)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 299, in handle
2024-02-14T00:21:39.815Z     await self.app(scope, receive, send)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 79, in app
2024-02-14T00:21:39.815Z     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
2024-02-14T00:21:39.815Z     raise exc
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
2024-02-14T00:21:39.815Z     await app(scope, receive, sender)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 74, in app
2024-02-14T00:21:39.815Z     response = await func(request)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 299, in app
2024-02-14T00:21:39.815Z     raise e
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 294, in app
2024-02-14T00:21:39.815Z     raw_response = await run_endpoint_function(
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 193, in run_endpoint_function
2024-02-14T00:21:39.815Z     return await run_in_threadpool(dependant.call, **values)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/starlette/concurrency.py", line 42, in run_in_threadpool
2024-02-14T00:21:39.815Z     return await anyio.to_thread.run_sync(func, *args)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync
2024-02-14T00:21:39.815Z     return await get_async_backend().run_sync_in_worker_thread(
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2134, in run_sync_in_worker_thread
2024-02-14T00:21:39.815Z     return await future
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 851, in run
2024-02-14T00:21:39.815Z     result = context.run(func, *args)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/site-packages/gradio/routes.py", line 316, in main
2024-02-14T00:21:39.815Z     config = copy.deepcopy(app.get_blocks().config)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 146, in deepcopy
2024-02-14T00:21:39.815Z     y = copier(x, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 231, in _deepcopy_dict
2024-02-14T00:21:39.815Z     y[deepcopy(key, memo)] = deepcopy(value, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 146, in deepcopy
2024-02-14T00:21:39.815Z     y = copier(x, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 206, in _deepcopy_list
2024-02-14T00:21:39.815Z     append(deepcopy(a, memo))
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 146, in deepcopy
2024-02-14T00:21:39.815Z     y = copier(x, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 231, in _deepcopy_dict
2024-02-14T00:21:39.815Z     y[deepcopy(key, memo)] = deepcopy(value, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 172, in deepcopy
2024-02-14T00:21:39.815Z     y = _reconstruct(x, memo, *rv)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 271, in _reconstruct
2024-02-14T00:21:39.815Z     state = deepcopy(state, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 146, in deepcopy
2024-02-14T00:21:39.815Z     y = copier(x, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 231, in _deepcopy_dict
2024-02-14T00:21:39.815Z     y[deepcopy(key, memo)] = deepcopy(value, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 172, in deepcopy
2024-02-14T00:21:39.815Z     y = _reconstruct(x, memo, *rv)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 271, in _reconstruct
2024-02-14T00:21:39.815Z     state = deepcopy(state, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 146, in deepcopy
2024-02-14T00:21:39.815Z     y = copier(x, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 231, in _deepcopy_dict
2024-02-14T00:21:39.815Z     y[deepcopy(key, memo)] = deepcopy(value, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 146, in deepcopy
2024-02-14T00:21:39.815Z     y = copier(x, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 206, in _deepcopy_list
2024-02-14T00:21:39.815Z     append(deepcopy(a, memo))
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 172, in deepcopy
2024-02-14T00:21:39.815Z     y = _reconstruct(x, memo, *rv)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 271, in _reconstruct
2024-02-14T00:21:39.815Z     state = deepcopy(state, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 146, in deepcopy
2024-02-14T00:21:39.815Z     y = copier(x, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 231, in _deepcopy_dict
2024-02-14T00:21:39.815Z     y[deepcopy(key, memo)] = deepcopy(value, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 146, in deepcopy
2024-02-14T00:21:39.815Z     y = copier(x, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 206, in _deepcopy_list
2024-02-14T00:21:39.815Z     append(deepcopy(a, memo))
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 146, in deepcopy
2024-02-14T00:21:39.815Z     y = copier(x, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 231, in _deepcopy_dict
2024-02-14T00:21:39.815Z     y[deepcopy(key, memo)] = deepcopy(value, memo)
2024-02-14T00:21:39.815Z   File "/usr/local/lib/python3.10/copy.py", line 161, in deepcopy
2024-02-14T00:21:39.815Z     rv = reductor(4)
2024-02-14T00:21:39.815Z TypeError: cannot pickle 'dict_keys' object

System Info

Gradio app is running in docker container in AWS ECS environment

Severity

I can work around it

@abidlabs
Copy link
Member

Agh I was worried about this. I have an idea for a workaround. I’ll try it tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants