Skip to content

Commit 582bd53

Browse files
authored
StashCalculation: throw a warning if the computer node mismatches with the one of source_node (#6862)
We don't raise an error, but a warning. Because there could be a situation that a user's computer will be faulty for whatever reason (migrating transport plugins, etc.). Therefore it should still be possible to stash data from a different computer as long as they share access to the RemoteData path.
1 parent 5168032 commit 582bd53

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

src/aiida/calculations/stash.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
""""""
1010

1111
from aiida import orm
12+
from aiida.common import AIIDA_LOGGER
1213
from aiida.common.datastructures import CalcInfo
1314
from aiida.engine import CalcJob
1415

16+
EXEC_LOGGER = AIIDA_LOGGER.getChild('StashCalculation')
17+
1518

1619
class StashCalculation(CalcJob):
1720
"""
@@ -69,6 +72,17 @@ def define(cls, spec):
6972
}
7073

7174
def prepare_for_submission(self, folder):
75+
if self.inputs.source_node.computer.uuid != self.inputs.metadata.computer.uuid:
76+
EXEC_LOGGER.warning(
77+
'YOUR SETTING MIGHT RESULT IN A SILENT FAILURE!'
78+
' The computer of the source node and the computer of the calculation are strongly advised be the same.'
79+
' However, it is not mandatory,'
80+
' in order to support the case that original computer somehow is not usable, anymore.'
81+
' E.g. the original computer was configured for ``core.torque``, but the HPC has move to SLURM,'
82+
' so you had to create a new computer configured with ``core.slurm``,'
83+
" and you'll need a job submission to do this."
84+
)
85+
7286
calc_info = CalcInfo()
7387
calc_info.skip_submit = True
7488

tests/calculations/test_stash.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,45 @@ def test_stash_calculation_basic(fixture_sandbox, aiida_localhost, generate_calc
5050
assert calc_info.local_copy_list == []
5151
assert calc_info.remote_copy_list == []
5252
assert calc_info.remote_symlink_list == []
53+
54+
55+
@pytest.mark.requires_rmq
56+
def test_stash_calculation_different_computer(
57+
fixture_sandbox, aiida_computer_local, generate_calc_job, tmp_path, caplog
58+
):
59+
"""Test it emits a warning if the source node is on a different computer."""
60+
61+
target_base = tmp_path / 'target'
62+
source = tmp_path / 'source'
63+
source.mkdir()
64+
65+
a_computer = aiida_computer_local()
66+
a_different_computer = aiida_computer_local()
67+
assert a_computer.uuid != a_different_computer.uuid
68+
69+
inputs = {
70+
'metadata': {
71+
'computer': a_computer,
72+
'options': {
73+
'resources': {'num_machines': 1},
74+
'stash': {
75+
'stash_mode': StashMode.COPY.value,
76+
'target_base': str(target_base),
77+
'source_list': ['*'],
78+
},
79+
},
80+
},
81+
'source_node': orm.RemoteData(computer=a_different_computer, remote_path=str(source)),
82+
}
83+
entry_point_name = 'core.stash'
84+
generate_calc_job(fixture_sandbox, entry_point_name, inputs)
85+
86+
import logging
87+
88+
with caplog.at_level(logging.WARNING):
89+
assert any(
90+
'YOUR SETTING MIGHT RESULT IN A SILENT FAILURE!'
91+
' The computer of the source node and the computer of the calculation are strongly advised be the same.'
92+
in message
93+
for message in caplog.messages
94+
)

0 commit comments

Comments
 (0)