Hi all,
I’ve started converting my workchains to BaseRestartWorkChains and I’m generally confused about how to grab the outputs from the calcjobs I define in the _process_class.
I’m currently using the orca plugin in a work chain to relax a molecule and extract the homo/lumo energy values:
OrcaCalculation = CalculationFactory("orca.orca")
class HomoLumoWorkChain(BaseRestartWorkChain):
_process_class = OrcaCalculation
@classmethod
def define(cls, spec):
""" Homo Lumo Calculation WorkChain """
super().define(spec)
spec.input('structure', valid_type=StructureData)
spec.input('code', valid_type=AbstractCode)
spec.input('parameters', valid_type=Dict)
spec.input('resources', valid_type=Dict) # keep this a regular dictionary
spec.outline(
cls.setup,
while_(cls.should_run_process)(
cls.run_process,
cls.inspect_process,
),
cls.extract_homo_lumo,
cls.results,
)
spec.expose_outputs(OrcaCalculation)
spec.output('homo', valid_type=Float)
spec.output('lumo', valid_type=Float)
def setup(self):
super().setup()
wallclock_seconds = 60 * 60 * 8 # 8 hours
for param in self.inputs.parameters.get_dict()["input_keywords"]:
if param.startswith("PAL"):
nprocs = int(param[-1])
metadata = {
"options": {
"resources": self.inputs.resources.get_dict(),
"max_wallclock_seconds": wallclock_seconds,
"withmpi": False,
"max_memory_kb": int(3.8 * 1e6 * nprocs),
"account": "account_xxxx"
}
}
self.ctx.inputs = {'structure': self.inputs.structure, 'code': self.inputs.code, 'parameters':
self.inputs.parameters, "metadata": metadata}
def extract_homo_lumo(self):
outputs = self.exposed_outputs(OrcaCalculation)
outputdata = outputs["output_parameters"]
E_homo = get_homo(outputdata)
E_lumo = get_lumo(outputdata)
self.out('homo', E_homo)
self.out('lumo', E_lumo)
I just ran this workchain and was met with this (contracted) error:
File "/home/coopy/envs/aiida/lib/python3.10/site-packages/plumpy/workchains.py", line 246, in step
return True, self._fn(self._workchain)
File "/home/coopy/onedrive/Research/Batteries/aiida/WorkChains/HomoLumoWorkChain.py", line 104, in extract_homo_lumo
# outputs = self.get_outputs(OrcaCalculation)
File "/home/coopy/envs/aiida/lib/python3.10/site-packages/aiida/engine/processes/workchains/restart.py", line 316, in get_outputs
return self.exposed_outputs(node, self.process_class)
File "/home/coopy/envs/aiida/lib/python3.10/site-packages/aiida/engine/processes/process.py", line 965, in exposed_outputs
process_outputs_dict = node.base.links.get_outgoing(link_type=link_types).nested()
AttributeError: type object 'OrcaCalculation' has no attribute 'base'
I’ve also tried taking the outputs in the extract_homo_lumo() method using:
outputs = self.get_outputs(OrcaCalculation)
which also failed with a similar error message.
How should I be extracting the outputs and processing them in other steps? I’ve searched pretty thoroughly through the docs and think this may be a hole in the current documentation. Let me know if I missed something.
Thanks!