-
Notifications
You must be signed in to change notification settings - Fork 208
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
builder
returns wrong values of inputs defaults when namespaces are used in expose_inputs
#5263
Comments
Thanks @bosonie . Can you have another look at your example and I cannot reproduce the problem. In [1]: 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()
In [2]: b
Out[2]: {'metadata': {}, 'dddd': {'metadata': {}}, 'aaaa': {'metadata': {}}}
In [3]: b.www()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-087b93e24a03> in <module>
----> 1 b.www()
AttributeError: 'ProcessBuilder-1051c00d-78f5-4878-8f87-6254f37ee16' object has no attribute 'www' The resulting namespace looks ok to me. And calling |
The fact you call is due to the fact that the default is a |
Not sure if we want to release a patch 1.6.6 with a backport or we leave it for now since |
Closing this since v2.0 has been released |
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:
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 linespec.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 forb._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
The text was updated successfully, but these errors were encountered: