Skip to content
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

Unrelated builders interfere with each other #4420

Closed
greschd opened this issue Oct 2, 2020 · 1 comment · Fixed by #4984
Closed

Unrelated builders interfere with each other #4420

greschd opened this issue Oct 2, 2020 · 1 comment · Fixed by #4984

Comments

@greschd
Copy link
Member

greschd commented Oct 2, 2020

Describe the bug

The ProcessBuilderNamespace of unrelated processes can interfere with each other, because their properties are set on the ProcessBuilderNamespace class instead of the specific instance.

Steps to reproduce

WorkChain code:

class First(WorkChain):
    @classmethod
    def define(cls, spec):
        super().define(spec)
        spec.input('a', default=lambda: orm.Int(1))
        spec.input('b')


class Second(WorkChain):
    @classmethod
    def define(cls, spec):
        super().define(spec)
        spec.input('a', default=lambda: orm.Int(2))
        spec.input('c')

Inspect builder behavior:

In [1]: from test_proc import First, Second                                                                                                                                                                                           

In [2]: builder = First.get_builder() 

In [3]: Second.get_builder() # We simply construct this builder, and do nothing with it.                                                                                                           

In [5]: builder.a() # The default for 'a' has changed to the lambda defined in `Second`.
Out[5]: <Int: uuid: fb6a1556-9f34-4d32-b7ea-cc2800ee00ef (unstored) value: 2> 

In [6]: builder.c # This should raise, since `First` doesn't have a 'c' input.

EDIT: When actually running the workchain, the default is populated correctly, and validation is also correct. I guess this slightly lowers the severity, but depending on how the user manipulates the builder it could still lead to incorrect inputs.

Your environment

  • Operating system: Ubuntu-18.04 on WSL2
  • Python version: 3.7.3
  • aiida-core version: develop branch

Additional context

This is a follow-up from a discussion from #4419

@greschd greschd added type/bug priority/critical-blocking must be resolved before next release topic/processes labels Oct 2, 2020
@greschd greschd added priority/important and removed priority/critical-blocking must be resolved before next release labels Oct 2, 2020
@greschd
Copy link
Member Author

greschd commented Oct 2, 2020

@sphuber one option to resolve this would be just implementing a __getattr__ instead of the dynamically-created properties. But I think this would break auto-completion - am I right in thinking this was the reason to go with the properties in the first place?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants