-
Notifications
You must be signed in to change notification settings - Fork 204
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
Node
: add the copy_tree
method
#5114
Node
: add the copy_tree
method
#5114
Conversation
@ltalirz @chrisjsewell @ramirezfranciscof any takers? On a side note, this PR made me think whether we need to add the possibility to create an empty directory in the virtual hierarchy of nodes. Currently this is not possible. |
Codecov Report
@@ Coverage Diff @@
## develop #5114 +/- ##
===========================================
+ Coverage 80.83% 80.84% +0.02%
===========================================
Files 534 534
Lines 36951 36974 +23
===========================================
+ Hits 29865 29889 +24
+ Misses 7086 7085 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
88d6b29
to
7d6f3c3
Compare
7d6f3c3
to
3b76ab3
Compare
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.
All looks good! I just have 3 small comments/questions before approving.
Eurgh, yeh it needs to be exposed in some fashion, but you are adding way too many methods on to This is why I've already looked into refactoring all this as e.g. |
Basically I would point you towards: https://python-patterns.guide/gang-of-four/composition-over-inheritance/#dodge-mixins: Using "Composition over inheritance", is something we do ok in some areas of aiida, but poor in others |
I am not against improving the interface and I see the point for exposing all repository related methods under the Also very happy to have suggestions for the name of this method. I am not at all married to it. I simply took it as that is the name that is used in Finally, I agree that too many methods at some point makes things difficult to oversee and in that respect it would be good to cleanup the |
This method allows to easily copy the entire repository tree, or a subdirectory, of a `Node` to a place on the local file system. The method simply forwards to the `aiida.repository.Repository` class, where the functionality is actually implemented using the `Repository.walk` method, recursively looping over all the files contained within the node's repository.
3b76ab3
to
62040f5
Compare
Thanks for the review @ramirezfranciscof . I have added the additional tests and included the changes that had snuck into the other PR. |
This is actually a super interesting concept I came across somewhat recently while reading Head First Design Patterns (highly recommended if you can get past the silly tone 😅). I would find it really exciting to have these kind of design concepts come up more when discussing and deploying implementations and refactors in the code! More practically, it would also be very helpful when doing improvements like #4938 if there was a bit more explanation on how these kind of principles affect the decisions on making the specific changes, and how these influence the technical aspects of the implementation. I mean, I understand these might seem obvious being the author, but it is sometimes very hard to just look at the changes and deduce what one is trying to achieve, specially since in implementations these concepts can't be usually applied in "pure" form. For example, while it is true that the In any case, it is true what @sphuber says that this is more a long term concern and not something we can resolve before 2.0, so maybe we can continue this discussion in other more specific issues and accept for now that this PR will have to construct on what is already there. |
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.
This is good to go for me! (it is out-of-date though, not sure if that means you need approval once again after updating)
Fixes #4928
This method allows to easily copy the entire repository tree, or a
subdirectory, of a
Node
to a place on the local file system. Themethod simply forwards to the
aiida.repository.Repository
class, wherethe functionality is actually implemented using the
Repository.walk
method, recursively looping over all the files contained within the
node's repository.