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

WARNING 'werkzeug.local.LocalProxy' is not mapped #29403

Open
2 of 3 tasks
Habeeb556 opened this issue Jun 28, 2024 · 3 comments
Open
2 of 3 tasks

WARNING 'werkzeug.local.LocalProxy' is not mapped #29403

Habeeb556 opened this issue Jun 28, 2024 · 3 comments
Labels
validation:validated A committer has validated / submitted the issue or it was reported by multiple users

Comments

@Habeeb556
Copy link
Contributor

Bug description

I got the below error in logs:

WARNING:root:Class 'werkzeug.local.LocalProxy' is not mapped
WARNING:root:Class 'werkzeug.local.LocalProxy' is not mapped
WARNING:root:Class 'werkzeug.local.LocalProxy' is not mapped
WARNING:root:Class 'werkzeug.local.LocalProxy' is not mapped

How to reproduce the bug

Noting

Screenshots/recordings

No response

Superset version

4.0.1

Python version

3.11

Node version

I don't know

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Copy link

dosubot bot commented Jun 28, 2024

The warning "Class 'werkzeug.local.LocalProxy' is not mapped" in your logs while using Superset version 4.0.1 with Python 3.11 is likely due to the use of LocalProxy objects in the Superset code. This warning typically occurs when SQLAlchemy or another ORM tool tries to map or interact with a class that it doesn't recognize as a mapped entity.

In the superset/__init__.py file, LocalProxy is used to create proxies for various configurations and caches:

from werkzeug.local import LocalProxy

conf = LocalProxy(lambda: current_app.config)
results_backend = LocalProxy(lambda: results_backend_manager.results_backend)
results_backend_use_msgpack = LocalProxy(lambda: results_backend_manager.should_use_msgpack)
data_cache = LocalProxy(lambda: cache_manager.data_cache)
thumbnail_cache = LocalProxy(lambda: cache_manager.thumbnail_cache)

To resolve this warning, you can ensure that these LocalProxy objects are not being inadvertently passed to SQLAlchemy or any other ORM that expects a mapped class. If these proxies are being used in a context where they might be interpreted as entities, you might need to refactor the code to avoid such usage.

For example, you can access the actual object behind the proxy before passing it to SQLAlchemy:

# Instead of passing the proxy directly, access the underlying object
actual_results_backend = results_backend._get_current_object()
# Use actual_results_backend in your ORM operations

This approach ensures that the ORM interacts with the actual object rather than the proxy, thus avoiding the warning [1].

Additionally, there has been a recent update in the Superset codebase that addresses this warning. The update is mentioned in the CHANGELOG/4.0.0.md file under the version 4.0.0 section:

- [#27164](https://github.com/apache/superset/pull/27164) fix: unlock and bump werkzeug (@dpgaspar)

This update includes changes that address the warning related to werkzeug.local.LocalProxy [2][3].

To continue talking to Dosu, mention @dosu.

@sfirke
Copy link
Member

sfirke commented Jul 29, 2024

I get this in my logs as well. I'm running 4.0.2 so while Dosu says a relevant PR was merged in 4.0.0, I confirm it did not quiet this warning. I believe this warning has existed as far back as 2.0.0, if not farther - I don't think it indicates a warning but it clutters the logs.

@sfirke sfirke added the validation:validated A committer has validated / submitted the issue or it was reported by multiple users label Jul 29, 2024
@Habeeb556
Copy link
Contributor Author

Habeeb556 commented Aug 9, 2024

Yes, it’s the same. Do you have any suggestions for avoiding this clutter in the logs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validation:validated A committer has validated / submitted the issue or it was reported by multiple users
Projects
None yet
Development

No branches or pull requests

2 participants