-
Notifications
You must be signed in to change notification settings - Fork 98
Add implemention of CalcJobImporter for pw.x calculations
#847
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
Open
sphuber
wants to merge
2
commits into
main
Choose a base branch
from
feature/809/calc-job-importer-pw
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Empty file.
This file contains hidden or 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,50 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """:class:`aiida.engine.processes.calcjobs.importer.CalcJobImporter` implementation for ``PwCalculation``.""" | ||
| from __future__ import annotations | ||
|
|
||
| import pathlib | ||
| import tempfile | ||
|
|
||
| from aiida.engine import CalcJobImporter | ||
| from aiida.orm import AbstractCode, Node, RemoteData | ||
|
|
||
|
|
||
| class PwCalculationImporter(CalcJobImporter): | ||
| """:class:`aiida.engine.processes.calcjobs.importer.CalcJobImporter` implementation for ``PwCalculation``. | ||
|
|
||
| This class allows to import a completed ``pw.x`` calculation that was executed without AiiDA, into an AiiDA profile. | ||
| """ | ||
|
|
||
| @staticmethod | ||
| def parse_remote_data( # pylint: disable=arguments-differ | ||
| remote_data: RemoteData, | ||
| input_file_name: str, | ||
| code: AbstractCode | None = None, | ||
| metadata: dict | None = None, | ||
| pseudo_folder_path: str | None = None, | ||
| ) -> dict[str, Node | dict]: | ||
| """Parse the input nodes from the files in the provided ``RemoteData``. | ||
|
|
||
| :param remote_data: the remote data node containing the raw input files. | ||
| :param input_file_name: the filename of the main Quantum ESPRESSO input file. | ||
| :param code: Optional ``AbstractCode`` node to attach to the imported node, as if it would have been run with | ||
| the ``code`` input in a real run. | ||
| :param metadata: Optional ``metadata`` inputs to set on the imported node, as if it would have been run with | ||
| the ``metadata`` input in a real run. | ||
| :returns: a dictionary with the parsed inputs nodes that match the input spec of the associated ``CalcJob``. | ||
| """ | ||
| from aiida_quantumespresso.tools.pwinputparser import create_builder_from_file | ||
|
|
||
| with tempfile.TemporaryDirectory() as tmppath: | ||
| dirpath = pathlib.Path(tmppath) / 'folder' | ||
| with remote_data.get_authinfo().get_transport() as transport: | ||
| transport.copytree(remote_data.get_remote_path(), dirpath) | ||
|
|
||
| builder = create_builder_from_file( | ||
| str(dirpath), input_file_name, code, metadata or {}, pseudo_folder_path=pseudo_folder_path | ||
| ) | ||
|
|
||
| inputs = dict(builder) | ||
| inputs['remote_folder'] = remote_data | ||
|
|
||
| return inputs | ||
This file contains hidden or 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 hidden or 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,26 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """Tests for the :class:`aiida_quantumespresso.calculations.importers.pw.PwCalculationImporter` class.""" | ||
| from pathlib import Path | ||
|
|
||
| from aiida.engine import run | ||
| from aiida.orm import RemoteData | ||
|
|
||
| from aiida_quantumespresso.calculations.importers.pw import PwCalculationImporter | ||
| from aiida_quantumespresso.calculations.pw import PwCalculation | ||
|
|
||
|
|
||
| def test_default(filepath_tests, fixture_code, aiida_localhost): | ||
| """Test importing a typical completed ``pw.x`` calculation.""" | ||
| aiida_localhost.configure() | ||
| filepath_remote = Path(filepath_tests) / 'calculations' / 'importers' / 'test_pw' / 'test_default' | ||
| remote_data = RemoteData(str(filepath_remote), computer=aiida_localhost) | ||
| input_file_name = 'aiida.in' | ||
| code = fixture_code('quantumespresso.pw') | ||
| pseudo_folder_path = filepath_remote / 'pseudo' | ||
| inputs = PwCalculationImporter().parse_remote_data( | ||
| remote_data, input_file_name, code, pseudo_folder_path=str(pseudo_folder_path) | ||
| ) | ||
| results, node = run.get_node(PwCalculation, **inputs) | ||
| assert node.is_finished_ok | ||
| assert node.is_imported | ||
| assert set(results.keys()) == {'output_band', 'output_trajectory', 'output_parameters', 'retrieved'} |
8 changes: 8 additions & 0 deletions
8
tests/calculations/importers/test_pw/test_default/_aiidasubmit.sh
This file contains hidden or 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,8 @@ | ||
| #!/bin/bash | ||
| exec > _scheduler-stdout.txt | ||
| exec 2> _scheduler-stderr.txt | ||
|
|
||
|
|
||
|
|
||
|
|
||
| '/home/sph/code/qe/qe-6.6/bin/pw.x' '-in' 'aiida.in' > 'aiida.out' |
27 changes: 27 additions & 0 deletions
27
tests/calculations/importers/test_pw/test_default/aiida.in
This file contains hidden or 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,27 @@ | ||
| &CONTROL | ||
| calculation = 'scf' | ||
| outdir = './out/' | ||
| prefix = 'aiida' | ||
| pseudo_dir = './pseudo/' | ||
| verbosity = 'high' | ||
| / | ||
| &SYSTEM | ||
| ecutrho = 2.4000000000d+02 | ||
| ecutwfc = 3.0000000000d+01 | ||
| ibrav = 0 | ||
| nat = 2 | ||
| ntyp = 1 | ||
| / | ||
| &ELECTRONS | ||
| / | ||
| ATOMIC_SPECIES | ||
| Si 28.085 Si.UPF | ||
| ATOMIC_POSITIONS angstrom | ||
| Si 0.0000000000 0.0000000000 0.0000000000 | ||
| Si 1.3575000000 1.3575000000 1.3575000000 | ||
| K_POINTS automatic | ||
| 2 2 2 0 0 0 | ||
| CELL_PARAMETERS angstrom | ||
| 0.0000000000 2.7150000000 2.7150000000 | ||
| 2.7150000000 0.0000000000 2.7150000000 | ||
| 2.7150000000 2.7150000000 0.0000000000 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.