You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We discovered during the SINTEF tutorial that it is quite difficult to figure out how to create a FolderData from an existing folder (I figured it out by searching the aiida-core source code, which is not something a regular user can do).
When creating fd = FolderData in verdi shell and doing fd. + you see lots of methods, but the relevant one ( .put_object_from_tree) was not even visible (you would have to scroll to the end)
When you just want to create a FolderData to wrap a folder on your file system, "put_object_from_tree" is maybe not what you are thinking...
In my opinion, the FolderData should have a constructor argument folder to which you can pass an absolute path to a folder that will make the FolderData wrap this folder.
I think this would cover the majority of cases with a simple user interface.
The way this works in aiida-core==1.0.0 is that the constructor of Data sub classes can define the keywords they want to accept in the constructor to initialize the node. In this case this would look like:
class FolderData(Data):
def __init__(self, **kwargs):
"""Construct a new `FolderData` to which any files and folders can be added.
To add files to a new node use the various repository methods:
folder = FolderData()
folder.put_object_from_tree('/absolute/path/to/directory')
folder.put_object_from_filepath('/absolute/path/to/file.txt')
Alternatively, in order to simply wrap a directory, the `path` keyword can be used in the constructor:
folder = FolderData(path='/absolute/path/to/directory')
"""
path = kwargs.pop('path', None)
super(FolderData, self).__init__(**kwargs)
if path:
self.put_file_from_tree(path)
I can make a PR for this if we are happy with the interface. Since it is a FolderData I now only added option to add a directory. Should we also add one for adding a single file? Of course after construction, one can add as many other things as one wants
We discovered during the SINTEF tutorial that it is quite difficult to figure out how to create a
FolderData
from an existing folder (I figured it out by searching the aiida-core source code, which is not something a regular user can do).fd = FolderData
in verdi shell and doingfd.
+ you see lots of methods, but the relevant one (.put_object_from_tree
) was not even visible (you would have to scroll to the end)In my opinion, the
FolderData
should have a constructor argumentfolder
to which you can pass an absolute path to a folder that will make theFolderData
wrap this folder.I think this would cover the majority of cases with a simple user interface.
Mentioning @sphuber and @giovannipizzi for comment
The text was updated successfully, but these errors were encountered: