-
Notifications
You must be signed in to change notification settings - Fork 74
[_795] allow options to be accessed as attrs of metadata obj #796
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -131,6 +131,12 @@ | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| class iRODSMetaCollection: | ||||||||||||||||||||||||||
| def __getattr__(self,n): | ||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider changing |
||||||||||||||||||||||||||
| from irods.manager.metadata_manager import _default_MetadataManager_opts | ||||||||||||||||||||||||||
| if n in _default_MetadataManager_opts: | ||||||||||||||||||||||||||
| return self._manager._opts[n] | ||||||||||||||||||||||||||
| raise AttributeError | ||||||||||||||||||||||||||
|
Comment on lines
+136
to
+138
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of Does something like this improve the situation, or make it worse?
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried it that way and got a never-ending recursion, unfortunately : (
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I wonder if it has to do with the fact that Does this work?
Suggested change
I'm mostly trying to see if we can avoid having to use
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's how I originally tried it. Or, similar. When these infinite loopings happen, it's a pain to figure out why. I'll give it another go.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (py3) daniel@yuggoth:~/python-irodsclient$ python try.py
Traceback (most recent call last):
File "/home/daniel/python-irodsclient/try.py", line 4, in <module>
d.metadata(admin=True).admin
^^^^^^^^^^^^^^^^^^^^^^
File "/home/daniel/python-irodsclient/irods/meta.py", line 151, in __call__
x = copy.copy(self)
^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/copy.py", line 97, in copy
return _reconstruct(x, None, *rv)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/copy.py", line 260, in _reconstruct
if hasattr(y, '__setstate__'):
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/daniel/python-irodsclient/irods/meta.py", line 139, in __getattr__
if n in self._manager._opts:
^^^^^^^^^^^^^
File "/home/daniel/python-irodsclient/irods/meta.py", line 139, in __getattr__
if n in self._manager._opts:
^^^^^^^^^^^^^
File "/home/daniel/python-irodsclient/irods/meta.py", line 139, in __getattr__
if n in self._manager._opts:
^^^^^^^^^^^^^
[Previous line repeated 993 more times]
RecursionError: maximum recursion depth exceeded
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The above dump is the result. That's why I changed the code to be what it currently is.... I don't know why the one It's a mystery....
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, that stinks. Okay, please leave a comment regarding this situation above the usage of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem appears to be that the new object |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| def __call__(self, **opts): | ||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||
| Optional parameters in **opts are: | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.
What does this buy us over just... adding the new option to
self._opts?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.
Somehow doing it this way avoided a bottomless recursion. I do not know why....
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.
Please leave a comment above this explaining why it is necessary, and we can resolve this.
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.
I know you said you don't know why, but at least describe what we are trying to prevent by doing it this way even if we don't know why the situation is happening.
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.
OK.
Found a link that might provide insight.
https://nedbatchelder.com/blog/201010/surprising_getattr_recursion
I'm still going to try tracking it down because the
copy.copy()has already happened in this case, so it... shouldn't be happening but is.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.
Sounds good.