Description
Describe the bug
Several misleading behaviors (fairly weird I would say) have been detected when playing with default of inputs ports that have been exposed inside a namespace. See below to reproduce them.
Steps to reproduce
In verdi shell:
from aiida import orm
from aiida.engine import WorkChain
class ClassA(WorkChain):
@classmethod
def define(cls, spec):
super().define(spec)
spec.input("www",valid_type=Float,default=lambda: Float(1.0))
spec.outline(cls.brun)
def brun(self):
return None
class ClassB(WorkChain):
@classmethod
def define(cls, spec):
super().define(spec)
spec.expose_inputs(ClassA,namespace="dddd")
spec.expose_inputs(ClassA,namespace="aaaa")
spec.inputs["dddd"]["www"].default = lambda: Float(33.0)
spec.outline(cls.run)
def run(self):
self.report("w")
b=ClassB.get_builder()
First of all, typing b.www()
returns something. It shouldn't be since the input is exposed in a namespace.
Second, b.dddd.www()
does not return the correct default. Please note that the error is introduced only when the line spec.expose_inputs(ClassA,namespace="aaaa")
is present. If removed, the default is correctly returned.
Expected behavior
Should be clear from above
Important node
The bug is only on the value returned by the builder. In fact ClassB.spec().inputs._ports["dddd"]["www"].default()
correctly shows the right default. Same for b._process_spec.inputs._ports["dddd"]["www"].default()
. And also, when the workchain is launched, the correct inputs are used.
Therefore it only seems a problem of "updating" what is returned by the "getter".
Your environment
- Operating system [e.g. Linux]: Linux
- Python version [e.g. 3.7.1]: 3.7.10
- aiida-core version [e.g. 1.2.1]: 1.6.5