-
Notifications
You must be signed in to change notification settings - Fork 192
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
Allow passing directory path in FolderData
constructor
#3359
Allow passing directory path in FolderData
constructor
#3359
Conversation
This will initialize the node and copy over the tree pointed to by the `tree` keyword argument into the node's repository.
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.
@sphuber Thanks for the lightning-fast implementation, this is great!
I have some minor change requests for the docstring
aiida/orm/nodes/data/folder.py
Outdated
|
||
Alternatively, in order to simply wrap a directory, the `path` keyword can be used in the constructor: | ||
|
||
folder = FolderData(tree='/absolute/path/to/directory') |
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.
Would it make sense to add an explicit documentation of the tree
argument as well?
:param tree: Absolute path to a folder to wrap.
:type tree: str
@@ -19,3 +19,22 @@ | |||
|
|||
class FolderData(Data): | |||
"""`Data` sub class to represent a folder on a file system.""" | |||
|
|||
def __init__(self, **kwargs): | |||
"""Construct a new `FolderData` to which any files and folders can be added. |
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.
"""Construct a new `FolderData` to which any files and folders can be added. | |
"""Construct a new `FolderData` to which files and folders can be added. |
aiida/orm/nodes/data/folder.py
Outdated
folder.put_object_from_filepath('/absolute/path/to/file.txt') | ||
folder.put_object_from_filelike(filelike_object) | ||
|
||
Alternatively, in order to simply wrap a directory, the `path` keyword can be used in the constructor: |
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 would put this first, and then mention the other methods.
Alternatively, in order to simply wrap a directory, the `path` keyword can be used in the constructor: | |
Use the `tree` keyword in order to simply wrap a directory: |
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.
great, thanks a lot!
Fixes #3357
This will initialize the node and copy over the tree pointed to by the
tree
keyword argument into the node's repository.