Skip to content

Commit 2a128ef

Browse files
committed
bug fix
1 parent b3e783e commit 2a128ef

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/aiida/transports/plugins/ssh_async.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ async def copy_async(
618618
:type preserve: bool
619619
620620
:raises: OSError, src does not exist or if the copy execution failed.
621+
:raises: FileNotFoundError, if either remotesource does not exists
622+
or remotedestination's parent path does not exists
621623
"""
622624

623625
remotesource = str(remotesource)
@@ -648,7 +650,8 @@ async def copy_async(
648650
)
649651
else:
650652
if not await self.path_exists_async(remotesource):
651-
raise OSError(f'The remote path {remotesource} does not exist')
653+
raise FileNotFoundError(f'The remote path {remotesource} does not exist')
654+
652655
await self._sftp.copy(
653656
remotesource,
654657
remotedestination,
@@ -657,6 +660,13 @@ async def copy_async(
657660
follow_symlinks=dereference,
658661
remote_only=True,
659662
)
663+
except asyncssh.sftp.SFTPNoSuchFile as exc:
664+
# note: one could just create directories, but aiida engine expects this behavior
665+
# see `execmanager.py`::_copy_remote_files for more details
666+
raise FileNotFoundError(
667+
f'The remote path {remotedestination} is not reachable,'
668+
f'perhaps the parent folder does not exists: {exc}'
669+
)
660670
except asyncssh.sftp.SFTPFailure as exc:
661671
raise OSError(f'Error while copying {remotesource} to {remotedestination}: {exc}')
662672
else:

tests/engine/daemon/test_execmanager.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,19 @@ def file_hierarchy_simple():
4242
}
4343

4444

45-
@pytest.fixture(params=entry_point.get_entry_point_names('aiida.transports'))
46-
def node_and_calc_info(aiida_localhost, aiida_computer_ssh, aiida_code_installed, request):
45+
@pytest.fixture(
46+
scope='function',
47+
params=[name for name in entry_point.get_entry_point_names('aiida.transports') if name.startswith('core.')],
48+
)
49+
def node_and_calc_info(aiida_localhost, aiida_computer_ssh, aiida_computer_ssh_async, aiida_code_installed, request):
4750
"""Return a ``CalcJobNode`` and associated ``CalcInfo`` instance."""
4851

4952
if request.param == 'core.local':
5053
node = CalcJobNode(computer=aiida_localhost)
5154
elif request.param == 'core.ssh':
5255
node = CalcJobNode(computer=aiida_computer_ssh())
56+
elif request.param == 'core.ssh_async':
57+
node = CalcJobNode(computer=aiida_computer_ssh_async())
5358
else:
5459
raise ValueError(f'unsupported transport: {request.param}')
5560

@@ -378,6 +383,7 @@ def test_upload_file_copy_operation_order(node_and_calc_info, tmp_path, order, e
378383
),
379384
# Only remote copy of a single file to the "pseudo" directory
380385
# -> Copy fails silently since target directory does not exist: final directory structure is empty
386+
# COUNTER-INTUITIVE: the silent behavior is expected. See `execmanager.py`::_copy_remote_files for more details
381387
(
382388
{},
383389
(),
@@ -386,6 +392,7 @@ def test_upload_file_copy_operation_order(node_and_calc_info, tmp_path, order, e
386392
None,
387393
),
388394
# -> Copy fails silently since target directory does not exist: final directory structure is empty
395+
# COUNTER-INTUITIVE: the silent behavior is expected. See `execmanager.py`::_copy_remote_files for more details
389396
(
390397
{},
391398
(),

tests/transports/test_all_plugins.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def tmp_path_local(tmp_path_factory):
5959
)
6060
def custom_transport(request, tmp_path_factory, monkeypatch) -> Transport:
6161
"""Fixture that parametrizes over all the registered implementations of the ``CommonRelaxWorkChain``."""
62+
plugin = TransportFactory(request.param)
63+
6264
if request.param == 'core.ssh':
6365
kwargs = {'machine': 'localhost', 'timeout': 30, 'load_system_host_keys': True, 'key_policy': 'AutoAddPolicy'}
6466
elif request.param == 'core.ssh_async':
@@ -68,7 +70,7 @@ def custom_transport(request, tmp_path_factory, monkeypatch) -> Transport:
6870
else:
6971
kwargs = {}
7072

71-
return TransportFactory(request.param)(**kwargs)
73+
return plugin(**kwargs)
7274

7375

7476
def test_is_open(custom_transport):

0 commit comments

Comments
 (0)