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

CalcJob: Extend retrieve_list syntax with depth=None #5651

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Sep 21, 2022

Fixes #5650

There is currently no way to retrieve files using glob patterns while maintaining the exact file hierarchy of the remote working directory. The only supported syntaxes are:

  • Single string: some/path/with/glob/*.txt
  • Three-element tuple: ('glob/*.txt', '.', 1)

For the former, the matched file will be retrieved without any subfolders. For the latter, the levels of nesting to be kept is indicated by the final depth integer, but it has to be specified and needs to be 0 or larger.

It would be far easier if one didn't have to specify the depth and the file hierarchy would be kept as is. This functionality is added, so it is now possible to specify

retrieve_list = [('some/*.txt', '.', None)]

which will copy the files matched by the glob with the exact same file hierarchy, creating the nested directories where needed.

@sphuber
Copy link
Contributor Author

sphuber commented Sep 21, 2022

Will add documentation once decided on the new syntax.

Documentation is now added.

@sphuber sphuber force-pushed the fix/5650/retrieve-list-single-element-glob branch 2 times, most recently from cdd9146 to d94c5a3 Compare October 7, 2022 12:47
@sphuber sphuber force-pushed the fix/5650/retrieve-list-single-element-glob branch from d94c5a3 to 3cb5da7 Compare October 21, 2022 18:11
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.

Thanks @sphuber , this is a great improvement

@@ -460,15 +460,27 @@ Pattern matching

If the exact file or folder name is not known beforehand, glob patterns can be used.
In the following examples, all files that match ``*c.txt`` in the directory ``path/sub`` will be retrieved.
Since ``depth=0`` the files will be copied without the ``path/sub`` subdirectory.

If the exact folder hierarchy should be maintained, the ``depth`` should be disabled by setting it ``None``:
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
If the exact folder hierarchy should be maintained, the ``depth`` should be disabled by setting it ``None``:
In order to maintain the folder structure, set ``depth`` to ``None``:

@sphuber sphuber force-pushed the fix/5650/retrieve-list-single-element-glob branch from 3cb5da7 to 6a44b1c Compare October 27, 2022 10:47
There is currently no way to retrieve files using glob patterns while
maintaining the exact file hierarchy of the remote working directory.
The only supported syntaxes are:

 * Single string: `some/path/with/glob/*.txt
 * Three-element tuple: ('glob/*.txt', '.', 1)

For the former, the matched file will be retrieved without any
subfolders. For the latter, the levels of nesting to be kept is
indicated by the final `depth` integer, but it has to be specified and
needs to be 0 or larger.

It would be far easier if one didn't have to specify the depth and the
file hierarchy would be kept as is. This functionality is added, so it
is now possible to specify

 retrieve_list = [('some/*.txt', '.', None)]

which will copy the files matched by the glob with the exact same file
hierarchy, creating the nested directories where needed.
@sphuber sphuber force-pushed the fix/5650/retrieve-list-single-element-glob branch from 6a44b1c to c7512f5 Compare October 27, 2022 11:25
@sphuber sphuber merged commit a1b9f79 into aiidateam:main Oct 27, 2022
@sphuber sphuber deleted the fix/5650/retrieve-list-single-element-glob branch October 27, 2022 11:54
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.

CalcJob: add support to retrieve_list to use globbing that maintain source file hierarchy
2 participants