-
Notifications
You must be signed in to change notification settings - Fork 158
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: preserve original keys after key_builder transformation #564
FIX: preserve original keys after key_builder transformation #564
Conversation
Looks right to me, but can you add a test to demonstrate the problem (and merge master). Sorry for the delay. |
Hmmm, there still seems to be some ambiguity regarding the dict keys that are returned by the decorated function and the role of Interpretation 1The values of the iterable passed to This appears to be aligned with the changes made by this PR. Interpretation 2The dict keys returned by the decorated function correspond 1-to-1 with the values of the iterable passed to This was the context for my earlier comments on this PR. |
Agree with @pshafer-als on need for clarification about intended use case for |
If I'm understanding correctly, you're suggesting in interpretation 2, that a function can return keys which don't match the input? Like:
That's not my understanding of the documentation.
So, the primary purpose is to avoid cache key collisions with other functions. Not so sure why you'd use it over namespace though...
So, we use key_builder for the key to request from cache.
And we use key_builder on the returned keys to set them in the cache. In other words, it seems like key_builder just transforms keys to deal with the cache. The function should have no knowledge of the caching details, and the transformed keys should not be visible outside of the caching code. Which means something like this should work:
|
So, I think the changes here are still correct. If we can get a new test for this (in tests/ut/test_decorators.py using a mock cache should work), then we can merge this. |
Co-authored-by: Sam Bull <[email protected]>
@haizhou There are 6 failing tests, due to the change of return value in .get_cache_keys(). Can you enable write access to your branch or update those tests? All the failing tests are under tests/ut/test_decorators.py::TestMultiCached |
Co-authored-by: Sam Bull <[email protected]>
@Dreamsorcerer thanks for the collaboration. I'm not sure if we have enough seats left for adding an outside collaborator to our repos, but I made an attempt to fix the tests |
No problem. I think there's usually a checkbox to enable maintainer write access when opening a PR (not sure how to find it after opening though). That shouldn't affect those seats (and probably only applies to the branch, rather than the entire repo). |
Codecov Report
@@ Coverage Diff @@
## master #564 +/- ##
=======================================
Coverage 99.67% 99.67%
=======================================
Files 35 35
Lines 3712 3713 +1
=======================================
+ Hits 3700 3701 +1
Misses 12 12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Co-authored-by: Sam Bull <[email protected]>
What do these changes do?
Preserve original keys with the underlying function call after
key_builder
transformation takes place inmulti_cached
Are there changes in behavior for the user?
There shouldn't be if the intention is to allow differently formatted cache keys than the original keys passed in.
Related issue number
#563
Checklist
CHANGES
folder<issue_id>.<type>
(e.g.588.bugfix
)issue_id
change it to the pr id after creating the PR.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.Fix issue with non-ascii contents in doctest text files.