-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…5184) A common problem is that the filepath of the executable for remote codes is mistyped by accident. The user often doesn't realize until they launch a calculation and it mysteriously fails with a non-descript error. They have to look into the output files to find that the executable could not be found. At that point, it is not trivial to correct the mistake because the `Code` cannot be edited nor can it be deleted, without first deleting the calculation that was just run first. Therefore, it would be nice to warn the user at the time of the code creation or storing. However, the check requires opening a connection to the associated computer which carries both significant overhead, and it may not always be available at time of the code creation. Setup scripts for automated environments may want to configure the computers and codes at a time when they cannot be necessarily reached. Therefore, preventing codes from being created in this case is not acceptable. The compromise is to implement the check in `validate_remote_exec_path` which can then freely be called by a user to check if the executable of the remote code is usable. The method is added to the CLI through the addition of the command `verdi code test`. Also here, we decide to not add the check by default to `verdi code setup` as that should be able to function without internet connection and with minimal overhead. The docs are updated to encourage the user to run `verdi code test` before using it in any calculations if they want to make sure it is functioning. In the future, additional checks can be added to this command.
- Loading branch information
Showing
6 changed files
with
114 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
########################################################################### | ||
# Copyright (c), The AiiDA team. All rights reserved. # | ||
# This file is part of the AiiDA code. # | ||
# # | ||
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # | ||
# For further information on the license, see the LICENSE.txt file # | ||
# For further information please visit http://www.aiida.net # | ||
########################################################################### | ||
# pylint: disable=redefined-outer-name | ||
"""Tests for :class:`aiida.orm.nodes.data.code.Code` class.""" | ||
import pytest | ||
|
||
from aiida.common.exceptions import ValidationError | ||
from aiida.orm import Code, Computer | ||
|
||
|
||
@pytest.mark.usefixtures('clear_database_before_test') | ||
def test_validate_remote_exec_path(): | ||
"""Test ``Code.validate_remote_exec_path``.""" | ||
computer = Computer( | ||
label='test-code-computer', transport_type='core.local', hostname='localhost', scheduler_type='core.slurm' | ||
).store() | ||
code = Code(remote_computer_exec=[computer, '/bin/invalid']) | ||
|
||
with pytest.raises(ValidationError, match=r'Could not connect to the configured computer.*'): | ||
code.validate_remote_exec_path() | ||
|
||
computer.configure() | ||
|
||
with pytest.raises(ValidationError, match=r'the provided remote absolute path `.*` does not exist.*'): | ||
code.validate_remote_exec_path() | ||
|
||
code = Code(remote_computer_exec=[computer, '/bin/bash']) | ||
code.validate_remote_exec_path() |