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

Fix: serialization regression with sqlmesh.core.dialect.normalize_model_name #3025

Merged
merged 3 commits into from
Aug 19, 2024

Conversation

z3z1ma
Copy link
Contributor

@z3z1ma z3z1ma commented Aug 19, 2024

sqlmesh.core.dialect.normalize_model_name uses lru_cache.

https://github.com/z3z1ma/sqlmesh/blob/0b3aeac041b280cb79bee51613648a9fce4c5646/sqlmesh/core/dialect.py#L960-L981

Serialization fails on this object when calling inspect.getfile
This is a common import. This bug would've been introduced by #3008 as I don't think there was an lru cache there before

I added a failing test by simply referencing the function in question in the main_func in test_metaprogramming

image

I fixed it by using inspect.unwrap to safely unwrap to func specifically in the getfile call. This returns the correct file path.
https://docs.python.org/3/library/inspect.html#inspect.unwrap

I have confirmed tests pass and this works on my production project too (whereas before it was bugged/un-runnable).


In the future, due to the fact that getfile can throw at all, we should probably add a try except unless we think our builtin guard is good enough (though this obviously slipped through).

@tobymao tobymao merged commit bf1c6bc into TobikoData:main Aug 19, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants