Skip to content
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

Merged
merged 2 commits into from
Sep 27, 2019

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Sep 27, 2019

Fixes #3357

This will initialize the node and copy over the tree pointed to by the
tree keyword argument into the node's repository.

This will initialize the node and copy over the tree pointed to by the
`tree` keyword argument into the node's repository.
Copy link
Member

@ltalirz ltalirz left a 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


Alternatively, in order to simply wrap a directory, the `path` keyword can be used in the constructor:

folder = FolderData(tree='/absolute/path/to/directory')
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""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.

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:
Copy link
Member

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.

Suggested change
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:

Copy link
Member

@ltalirz ltalirz left a 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!

@sphuber sphuber merged commit 954511f into aiidateam:develop Sep 27, 2019
@sphuber sphuber deleted the fix_3357_folder_data_constructor branch September 27, 2019 17:26
d-tomerini pushed a commit to d-tomerini/aiida_core that referenced this pull request Sep 30, 2019
)

This will initialize the node and copy over the tree pointed to by the
`tree` keyword argument into the node's repository.
d-tomerini pushed a commit to d-tomerini/aiida_core that referenced this pull request Oct 16, 2019
)

This will initialize the node and copy over the tree pointed to by the
`tree` keyword argument into the node's repository.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FolderData should take folder path as constructor argument
2 participants