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

Fix copy local files to remote target folder with sub-folder #6768

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/aiida/engine/daemon/execmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ async def _copy_local_files(logger, node, transport, inputs, local_copy_list, wo
# If the source object is a directory, we copy its entire contents
data_node.base.repository.copy_tree(filepath_target, filename_source)
await transport.put_async(
f'{dirpath}/*',
Copy link
Member Author

Choose a reason for hiding this comment

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

This will copy everything inside dirpath to workdir. If filename_target is a out/HP, then the dirpath will have out/HP, then it will copy them into the workdir target out/HP, result folders as reported in #6767

f'{filepath_target}/.',
workdir.joinpath(target) if target else workdir.joinpath('.'),
overwrite=True,
)
Expand Down
6 changes: 6 additions & 0 deletions src/aiida/transports/plugins/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,12 @@ def mkdir(self, path: TransportPath, ignore_existing: bool = False):
if ignore_existing and self.isdir(path):
return

# check and create the parent directories recursively
parent_path = os.path.dirname(path)

if not self.isdir(parent_path):
self.mkdir(parent_path, ignore_existing=True)
Copy link
Contributor

@khsrali khsrali Feb 24, 2025

Choose a reason for hiding this comment

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

Also please note, we already have this functionality in the same file, search for def makedirs


try:
self.sftp.mkdir(path)
except OSError as exc:
Expand Down
1 change: 1 addition & 0 deletions tests/engine/daemon/test_execmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def test_retrieve_files_from_list(
(['sub', None], {'b': 'file_b'}),
([None, 'target'], {'target': {'sub': {'b': 'file_b'}, 'a': 'file_a'}}),
(['sub', 'target'], {'target': {'b': 'file_b'}}),
(['sub', 'target/another-sub'], {'target': {'another-sub': {'b': 'file_b'}}}),
),
)
def test_upload_local_copy_list(
Expand Down
Loading