-
Notifications
You must be signed in to change notification settings - Fork 201
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
Several tests write to node.open
#4721
Comments
The issue is that here we are hacking into an already stored node ( The solution I'm implementing is the following. First, I don't have a pre-stored node @classmethod
def get_unstored_folder_node(cls):
"""Get a "default" folder node with some data.
The node is unstored so one can add more content to it before storing it.
"""
folder_node = orm.FolderData()
cls.content_file1 = 'nobody expects'
cls.content_file2 = 'the minister of silly walks'
cls.key_file1 = 'some/nested/folder/filename.txt'
cls.key_file2 = 'some_other_file.txt'
folder_node.put_object_from_filelike(io.StringIO(cls.content_file1), cls.key_file1)
folder_node.put_object_from_filelike(io.StringIO(cls.content_file2), cls.key_file2)
return folder_node Then:
|
A few tests were writing directly to a node's repository folder, after this got stored. While this still works, this is now deprecated and will not work anymore in 2.0. Here I'm replacing all times we use `.open` with `'w'` or `'wb'` mode with a correct call to `put_object_from_filelike`, calling it *before* the node is stored. In one case, the data comes from a small archive file. In this case, I recreated the (zipped) .aiida file adding two additional (binary) files obtained by gzipping a short string. This was used to ensure that `inputcat` and `outputcat` work also when binary data was requested. Actually, this is better than before, where the actual input or output of the calculation were overwritten and then replaced back. This commit fixes aiidateam#4721
Just came back to this issue due to a I have to say that
is quite a bit less intuitive than
In retrospect it would have been useful to at least point out in the warning how users are supposed to replace existing Perhaps the example in this comment can be useful to googling AiiDA users. |
The place to add this note is here: https://github.com/aiidateam/aiida-core/wiki/AiiDA-2.0-plugin-migration-guide |
(if you want you can also clarify the docstring: aiida-core/aiida/orm/nodes/repository.py Lines 114 to 115 in 7f84b53
|
Thanks, done! |
E.g.
Resulting in warnings
How should these tests be rewritten?
The text was updated successfully, but these errors were encountered: