aiidateam / aiida-quantumespresso

The official AiiDA plugin for Quantum ESPRESSO
https://aiida-quantumespresso.readthedocs.io
Other
55 stars 80 forks source link

Further documentation on the 'parent_folder' input for PhCalculation #500

Closed rglusic closed 4 years ago

rglusic commented 4 years ago

I've recently started working with aiida-quantumespresso and I've been playing with the workchains, however whenever I try to pass a parent_folder as an input to the PhCalculation, it always tells me there was no parent calculation. I'm calling this an issue as I can't seem to find any documentation giving a suggestion on what to actually pass for parent_folder. So far I've tried RemoteData(parent_calc.get_remote_workdir(), computer) but as I can't find any documentation regarding this, I am unsure what the proper thing to pass here would be. I'm assuming that as this fails and tells me that the parent_folder has no parent calculation, this is not the correct way of passing the parent_folder. Any help or improvement of the documentation would be greatly appreciated. I apologize if I simply overlooked something in the documentation.

Thanks,

Ryan Glusic

sphuber commented 4 years ago

Could you please post the output of verdi process show <PK> of the particular PhCalculation that apparently does not have a parent calculation? What would also be helpful is if you could share how you launched that PhCalculation, i.e. what were the inputs that you passed?

rglusic commented 4 years ago

Hello Sphuber,

Here's my code. I tried to keep it simple before putting it into a workchain. It's mostly modified from the outdated tutorial on the readthedocs site:

from aiida import load_profile
from aiida.orm.utils import load_node
import aiida.orm as orm
from aiida.engine import submit, run

load_profile()

from aiida.orm import Code, RemoteData
from aiida.plugins import CalculationFactory, DataFactory

parent_id = 110

code = Code.get_from_string('ph.x')

builder = code.get_builder()

Dict = DataFactory('dict')
parameters = Dict(dict={
            'INPUTPH': {
                'tr2_ph' : 1.0e-8,
                'epsil' : True,
                'ldisp' : True,
                'nq1' : 4,
                'nq2' : 4,
                'nq3' : 4,
                }})

QEPwCalc = CalculationFactory('quantumespresso.pw')
KpointsData  = DataFactory('array.kpoints')

parentcalc = load_node(parent_id)

builder.metadata.options.resources = {'num_machines': 1}
builder.metadata.options.max_wallclock_seconds = 1800
builder.metadata.label = 'generic'
builder.metadata.description ='example'

builder.parameters = parameters

qpoints = KpointsData()
qpoints.set_kpoints_mesh([4,4,4])
builder.qpoints = qpoints

folder = RemoteData(parentcalc.get_remote_workdir(), computer=parentcalc.computer)

builder.parent_folder = folder

calc = submit(builder)

print("created calculation with PK={}".format(calc.pk))

Output reported by verdi:

*** 622 [generic]: None
*** Scheduler output: N/A
*** Scheduler errors: N/A
*** 1 LOG MESSAGES:
+-> REPORT at 2020-04-07 07:14:53.761633+00:00
 | [622|PhCalculation|on_except]: Traceback (most recent call last):
 |   File "/home/ryang/research/aiida-core/aiida/engine/processes/calcjobs/tasks.py", line 78, in do_upload
 |     calc_info, script_filename = process.presubmit(folder)
 |   File "/home/ryang/research/aiida-core/aiida/engine/processes/calcjobs/calcjob.py", line 312, in presubmit
 |     calc_info = self.prepare_for_submission(folder)
 |   File "/home/ryang/research/aiida-quantumespresso/aiida_quantumespresso/calculations/ph.py", line 105, in prepare_for_submission
 |     raise exceptions.NotExistent('parent_folder<{}> has no parent calculation'.format(parent_folder.pk))
 | aiida.common.exceptions.NotExistent: parent_folder<621> has no parent calculation
 | 
 | The above exception was the direct cause of the following exception:
 | 
 | Traceback (most recent call last):
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/plumpy/processes.py", line 1084, in step
 |     next_state = yield self._run_task(self._state.execute)
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1055, in run
 |     value = future.result()
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/concurrent.py", line 238, in result
 |     raise_exc_info(self._exc_info)
 |   File "<string>", line 4, in raise_exc_info
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1063, in run
 |     yielded = self.gen.throw(*exc_info)
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/plumpy/processes.py", line 503, in _run_task
 |     result = yield tornado.stack_context.run_with_stack_context(
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1055, in run
 |     value = future.result()
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/concurrent.py", line 238, in result
 |     raise_exc_info(self._exc_info)
 |   File "<string>", line 4, in raise_exc_info
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1063, in run
 |     yielded = self.gen.throw(*exc_info)
 |   File "/home/ryang/research/aiida-core/aiida/engine/processes/calcjobs/tasks.py", line 351, in execute
 |     calc_info, script_filename = yield self._launch_task(task_upload_job, self.process, transport_queue)
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1055, in run
 |     value = future.result()
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/concurrent.py", line 238, in result
 |     raise_exc_info(self._exc_info)
 |   File "<string>", line 4, in raise_exc_info
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1063, in run
 |     yielded = self.gen.throw(*exc_info)
 |   File "/home/ryang/research/aiida-core/aiida/engine/processes/calcjobs/tasks.py", line 403, in _launch_task
 |     result = yield self._task
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1055, in run
 |     value = future.result()
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/concurrent.py", line 238, in result
 |     raise_exc_info(self._exc_info)
 |   File "<string>", line 4, in raise_exc_info
 |   File "/home/ryang/research/aiida-core/aiida/engine/utils.py", line 113, in execute_coroutine
 |     result = yield coro(future)
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1055, in run
 |     value = future.result()
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/concurrent.py", line 238, in result
 |     raise_exc_info(self._exc_info)
 |   File "<string>", line 4, in raise_exc_info
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1063, in run
 |     yielded = self.gen.throw(*exc_info)
 |   File "/home/ryang/research/aiida-core/aiida/engine/processes/calcjobs/tasks.py", line 89, in task_upload_job
 |     result = yield exponential_backoff_retry(
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1055, in run
 |     value = future.result()
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/concurrent.py", line 238, in result
 |     raise_exc_info(self._exc_info)
 |   File "<string>", line 4, in raise_exc_info
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1063, in run
 |     yielded = self.gen.throw(*exc_info)
 |   File "/home/ryang/research/aiida-core/aiida/engine/utils.py", line 172, in exponential_backoff_retry
 |     result = yield coro()
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1055, in run
 |     value = future.result()
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/concurrent.py", line 238, in result
 |     raise_exc_info(self._exc_info)
 |   File "<string>", line 4, in raise_exc_info
 |   File "/home/ryang/research/aiida-work/env/lib/python3.8/site-packages/tornado/gen.py", line 1069, in run
 |     yielded = self.gen.send(value)
 |   File "/home/ryang/research/aiida-core/aiida/engine/processes/calcjobs/tasks.py", line 80, in do_upload
 |     raise PreSubmitException('exception occurred in presubmit call') from exception
 | aiida.engine.processes.calcjobs.tasks.PreSubmitException: exception occurred in presubmit call
rglusic commented 4 years ago

verdi process show:

Property     Value
-----------  ---------------------------------------------------------------------------------------------------------------------------------
type         PhCalculation
state        Excepted <Traceback (most recent call last):
               File "/home/ryang/research/aiida-core/aiida/engine/processes/calcjobs/tasks.py", line 78, in do_upload
                 calc_info, script_filename = process.presubmit(folder)
               File "/home/ryang/research/aiida-core/aiida/engine/processes/calcjobs/calcjob.py", line 312, in presubmit
                 calc_info = self.prepare_for_submission(folder)
               File "/home/ryang/research/aiida-quantumespresso/aiida_quantumespresso/calculations/ph.py", line 105, in prepare_for_submission
                 raise exceptions.NotExistent('parent_folder<{}> has no parent calculation'.format(parent_folder.pk))
             aiida.common.exceptions.NotExistent: parent_folder<621> has no parent calculation

             The above exception was the direct cause of the following exception:

             aiida.engine.processes.calcjobs.tasks.PreSubmitException: exception occurred in presubmit call
             >
pk           622
uuid         4aa2d039-1060-467b-8bca-def77afebff1
label        generic
description  example
ctime        2020-04-07 07:14:53.373106+00:00
mtime        2020-04-07 07:14:53.800491+00:00
computer     [1] localhost

Inputs           PK  Type
-------------  ----  -----------
code            116  Code
parameters      619  Dict
parent_folder   621  RemoteData
qpoints         620  KpointsData

Log messages
---------------------------------------------
There are 1 log messages for this calculation
Run 'verdi process report 622' to see them
sphuber commented 4 years ago

I cannot see what the type is of the node that you load as parentcalc = load_node(parent_id), but that should be an instance of PwCalculation. If that is true than you should just be able to pass builder.parent_folder = parentcalc.outputs.remote_folder. This remote folder is the working directory of the pw.x calculation that is necessary to run before you can run a ph.x. By telling AiiDA the location of that remote folder, the engine will copy over the necessary files to the scratch working space of the ph.x you are to submit, such that it can properly restart.

rglusic commented 4 years ago

You are correct, that work perfectly. Thank you for your assistance. Hopefully if anyone has the same issue, they'll find this post and it'll help them. I should have thought to do a dir(parentcalc.outputs).

I greatly appreciate your assistance. Have a wonderful day,

Ryan

sphuber commented 4 years ago

Not to worry, happy to help, thanks to you for reporting. In the near future I hope I will find the time to update and improve the documentation!