-
Notifications
You must be signed in to change notification settings - Fork 632
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
[AL-1619][AL-1586] Removes cachable, makes Info more dict like #1469
Conversation
@@ -41,13 +42,14 @@ def test_dataset(local_ds_generator): | |||
assert len(ds.info) == 7 | |||
assert ds.info.test == [99] | |||
|
|||
ds.info.delete("test") | |||
ds.info.pop("test") |
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.
Since this change doesn't look to be backward compatible, hub version needs to be appropriately bumped.
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.
This is a slight change in API for info, delete is barely used atm, we should be fine.
assert ds.info[0] == "yo" | ||
assert ds.info[1] == "world" | ||
|
||
ds.info.popitem() |
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.
Separate tests for some of these methods (like popitem) might be better -- LIFO popitem not obvious here :)
|
||
def popitem(self): | ||
with self: | ||
popped = self._info.popitem() |
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.
In python < 3.7, popitem()
pops and returns an arbitrary entry while in 3.7+ it returns LIFO. Have you taken that into account wherever popitem
is called? (Not just info, but lru_sizes.popitem etc as well)
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.
For info, it shouldn't matter, it will behave like the corresponding version's dictionary.
For LRUCache, I don't think it should be an issue even in 3.6 as the Cpython implementation retains order.
From StackOverflow (https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6):-
"They are insertion ordered. As of Python 3.6, for the CPython implementation of Python, dictionaries remember the order of items inserted. This is considered an implementation detail in Python 3.6; you need to use OrderedDict if you want insertion ordering that's guaranteed across other implementations of Python (and other ordered behavior).
As of Python 3.7, this is no longer an implementation detail and instead becomes a language feature."
🚀 🚀 Pull Request
Checklist:
coverage-rate
upChanges